feat(app): segmented glass top bar across the app
Extract the chat's segmented bar into lib/ui/adaptive (SegmentedBar, GlassPill, SegmentedBarOverlay) and use it for the shell bar, DetailPane and every page-level bar. Pieces are frosted glass over a fading scrim; only pills take taps. Actions keep their natural width so the title gives way before a model name. The chat transcript scrolls behind its header.
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dar
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../native_back.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
@@ -215,13 +216,10 @@ void main() {
|
||||
find.byType(NavigationRail),
|
||||
cupertino ? findsNothing : findsOneWidget,
|
||||
);
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(AppBar), findsNothing);
|
||||
} else {
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||
}
|
||||
// The shell's bar and the conversation's own header.
|
||||
expect(find.byType(SegmentedBar), findsNWidgets(2));
|
||||
expect(find.byType(AppBar), findsNothing);
|
||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||
expect(find.byKey(const Key('chat-thread-header')), findsOneWidget);
|
||||
expect(findNativeBack(), findsNothing);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../features/pipelines/fixtures.dart';
|
||||
import '../features/pipelines/test_helpers.dart' show selectableText;
|
||||
import 'pipelines_app_test.dart' show webServer;
|
||||
import 'pipelines_replies.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
@@ -56,21 +57,17 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
expect(
|
||||
find.text('2 stages · 1 schedule'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
||||
expect(sockets, 1);
|
||||
|
||||
// The shell owns the only navigation bar; the embedded screen adds no
|
||||
// second AppBar or CupertinoNavigationBar.
|
||||
// second bar.
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
||||
expect(find.byType(Material), findsNothing);
|
||||
} else {
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.byType(Scaffold), findsOneWidget);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
import 'pipelines_app_test.dart' show webServer, requestOf;
|
||||
import 'pipelines_replies.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
@@ -65,10 +66,7 @@ void main() {
|
||||
}
|
||||
expect(find.text('Settings — Not implemented'), findsNothing);
|
||||
expect(sockets, 1);
|
||||
expect(
|
||||
cupertino ? find.byType(CupertinoNavigationBar) : find.byType(AppBar),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
final ping = requestOf(channel, 'ping')!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
@@ -19,6 +18,7 @@ import '../features/templates/ui/template_gallery_test_support.dart'
|
||||
show GalleryGateway, galleryTemplates, pumpGallery, templatesReply;
|
||||
import 'pipelines_app_test.dart' show webServer;
|
||||
import 'pipelines_replies.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
List<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
|
||||
channel.outgoing
|
||||
@@ -152,7 +152,7 @@ void main() {
|
||||
);
|
||||
await pumpGallery(tester, gateway);
|
||||
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pump();
|
||||
expect(find.text('Definition source'), findsOneWidget);
|
||||
@@ -204,10 +204,7 @@ void main() {
|
||||
expect(find.text('Release workflow'), findsOneWidget);
|
||||
// One visible navigation bar: the Templates page owns it, the shell is
|
||||
// preserved underneath.
|
||||
expect(
|
||||
find.byType(cupertino ? CupertinoNavigationBar : AppBar),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
if (cupertino) {
|
||||
expect(find.byType(Material), findsNothing);
|
||||
}
|
||||
|
||||
@@ -281,7 +281,14 @@ void main() {
|
||||
// Drag like an operator: a programmatic scroll is undone by the
|
||||
// view's follow-to-latest, while a user drag stops following.
|
||||
final list = find.byKey(const ValueKey<String>('chat-thread-s'));
|
||||
final viewport = tester.getRect(list);
|
||||
// The transcript scrolls behind the floating header; only the part
|
||||
// below it is visible.
|
||||
final viewport = Rect.fromLTRB(
|
||||
tester.getRect(list).left,
|
||||
tester.getRect(find.byKey(const Key('chat-thread-header'))).bottom,
|
||||
tester.getRect(list).right,
|
||||
tester.getRect(list).bottom,
|
||||
);
|
||||
for (var i = 0; i < 10; i++) {
|
||||
final rect = tester.getRect(control);
|
||||
if (rect.top >= viewport.top && rect.bottom <= viewport.bottom) break;
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/graph/domain/stage_definition.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
JsonMap _graph() => <String, dynamic>{
|
||||
'stages': <dynamic>[
|
||||
@@ -174,7 +175,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_text('plan definition'), findsOneWidget);
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.byType(BackButton), findsOneWidget);
|
||||
final route = ModalRoute.of(
|
||||
tester.element(find.byType(StageDefinitionView)),
|
||||
@@ -215,7 +216,7 @@ void main() {
|
||||
|
||||
expect(_text('Success definition'), findsOneWidget);
|
||||
expect(_text('#success definition'), findsNothing);
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoNavigationBarBackButton), findsOneWidget);
|
||||
expect(_text('Incoming routes'), findsOneWidget);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/screen.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||
import 'run_detail_finders.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
@@ -310,7 +311,9 @@ void main() {
|
||||
await _mountList(tester, gateway);
|
||||
|
||||
expect(find.byType(CupertinoPageScaffold), findsNWidgets(2));
|
||||
expect(find.byType(CupertinoNavigationBar), findsNWidgets(2));
|
||||
// The host's own bar and the detail pane's segmented bar.
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.text('Loading run details…'), findsOneWidget);
|
||||
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
|
||||
expect(find.text('Back to list'), findsOneWidget);
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('renders idle settings without opening a connection', (
|
||||
@@ -241,7 +242,7 @@ void main() {
|
||||
|
||||
await _pump(tester, client, platform: TargetPlatform.iOS);
|
||||
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.byType(FilledButton), findsNothing);
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:pipelines_app/features/templates/ui/template_detail.dart';
|
||||
|
||||
import '../data/template_test_support.dart' show source;
|
||||
import 'template_gallery_test_support.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('loading shows the exact line, then the server catalogue', (
|
||||
@@ -210,7 +211,7 @@ void main() {
|
||||
);
|
||||
await pumpGallery(tester, gateway, embedded: true);
|
||||
|
||||
expect(find.byType(AppBar), findsNothing);
|
||||
expect(find.byType(SegmentedBar), findsNothing);
|
||||
expect(find.byKey(templatesRefreshKey), findsOneWidget);
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
||||
|
||||
void _size(WidgetTester tester, double width, {double scale = 1}) {
|
||||
tester.view.physicalSize = Size(width, 700);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = scale;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
}
|
||||
|
||||
bool _ellipsised(WidgetTester tester, String text) {
|
||||
final paragraph = tester.renderObject<RenderParagraph>(find.text(text));
|
||||
return paragraph.didExceedMaxLines ||
|
||||
paragraph.size.width <
|
||||
(TextPainter(
|
||||
text: TextSpan(text: text, style: paragraph.text.style),
|
||||
textDirection: TextDirection.ltr,
|
||||
textScaler: paragraph.textScaler,
|
||||
)..layout()).width -
|
||||
0.5;
|
||||
}
|
||||
|
||||
Widget _modelAction(String model) => TextButton(
|
||||
onPressed: () {},
|
||||
child: Text(model, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
);
|
||||
|
||||
void main() {
|
||||
// The test font draws every glyph a square, so names run wider than in
|
||||
// a browser; each width takes the longest id that fits it there.
|
||||
for (final (width, model) in [
|
||||
(390.0, 'gpt-5.6-luna'),
|
||||
(560.0, 'claude-opus-5-5'),
|
||||
]) {
|
||||
testWidgets('a long model name ($model) shows whole at ${width}px', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, width);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: const BackButton(),
|
||||
title: 'A conversation with a rather long title indeed',
|
||||
subtitle: 'tank',
|
||||
actions: [_modelAction(model)],
|
||||
),
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(_ellipsised(tester, model), isFalse);
|
||||
// The title gives way first.
|
||||
expect(
|
||||
_ellipsised(tester, 'A conversation with a rather long title indeed'),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('320px at 2x text lays out without overflow', (tester) async {
|
||||
_size(tester, 320, scale: 2);
|
||||
for (final cupertino in [false, true]) {
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
leading: SegmentedBackButton(cupertino: cupertino, onPressed: () {}),
|
||||
title: 'A long conversation title',
|
||||
subtitle: 'a-working-folder',
|
||||
subtitleIcon: Icons.folder_outlined,
|
||||
onTitlePressed: () {},
|
||||
actions: cupertino
|
||||
? [
|
||||
CupertinoButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
'gpt-5.6-luna',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
]
|
||||
: [
|
||||
_modelAction('gpt-5.6-luna'),
|
||||
IconButton(onPressed: () {}, icon: const Icon(Icons.refresh)),
|
||||
],
|
||||
);
|
||||
// A Cupertino bar over content (the conversation's own) scales its
|
||||
// text; as a navigation bar the scaffold turns scaling off.
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: SegmentedBarOverlay(
|
||||
bar: bar,
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: bar,
|
||||
body: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull, reason: 'cupertino: $cupertino');
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('taps between the pieces reach the content behind', (
|
||||
tester,
|
||||
) async {
|
||||
_size(tester, 560);
|
||||
var behind = 0;
|
||||
var back = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
leading: BackButton(onPressed: () => back++),
|
||||
title: 'Short',
|
||||
),
|
||||
body: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => behind++,
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final barRect = tester.getRect(find.byType(SegmentedBar));
|
||||
// The empty middle of the bar, right of the short title.
|
||||
await tester.tapAt(Offset(barRect.width * 0.75, barRect.center.dy));
|
||||
expect(behind, 1);
|
||||
await tester.tap(find.byType(BackButton));
|
||||
expect(back, 1);
|
||||
expect(behind, 1);
|
||||
});
|
||||
|
||||
testWidgets('content starts below the bar at rest', (tester) async {
|
||||
_size(tester, 560);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SegmentedBarOverlay(
|
||||
bar: const SegmentedBar(cupertino: false, title: 'Overlay'),
|
||||
child: ListView(
|
||||
children: const [ListTile(title: Text('First row'))],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
final bar = tester.getRect(find.byType(SegmentedBar));
|
||||
final row = tester.getRect(find.text('First row'));
|
||||
expect(row.top, greaterThanOrEqualTo(bar.bottom));
|
||||
// The list itself reaches the top, behind the bar.
|
||||
expect(tester.getRect(find.byType(ListView)).top, 0);
|
||||
});
|
||||
|
||||
testWidgets('pieces are frosted glass, solid under high contrast', (
|
||||
tester,
|
||||
) async {
|
||||
Widget app(bool highContrast) => CupertinoApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(highContrast: highContrast),
|
||||
child: const CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(cupertino: true, title: 'Glass'),
|
||||
child: SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(app(false));
|
||||
expect(find.byType(GlassPill), findsOneWidget);
|
||||
expect(find.byType(BackdropFilter), findsOneWidget);
|
||||
// The Cupertino bar draws no Material widget.
|
||||
expect(find.byType(Material), findsNothing);
|
||||
|
||||
await tester.pumpWidget(app(true));
|
||||
expect(find.byType(BackdropFilter), findsNothing);
|
||||
});
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pipelines_app/main.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
void main() {
|
||||
for (final width in [390.0, 1000.0]) {
|
||||
@@ -46,7 +47,8 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user