fix(app): wide Cupertino sidebar, compact run tabs, web-like chat bubbles
This commit is contained in:
@@ -36,22 +36,118 @@ class ChatMessageView extends StatelessWidget {
|
||||
...content,
|
||||
],
|
||||
);
|
||||
// The web draws the operator's turn right-aligned in an accent-tinted bubble
|
||||
// and the agent's left-aligned on the neutral surface, both capped to a
|
||||
// readable measure. The role label stays outside the bubble.
|
||||
final contentBody = cupertino
|
||||
? DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
)
|
||||
: body;
|
||||
// A Material surface (not a bare DecoratedBox) so the disclosure ListTiles
|
||||
// inside the bubble keep their ink and background.
|
||||
final bubble = cupertino
|
||||
? Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: _bubbleDecoration(context, cupertino, user: user),
|
||||
child: contentBody,
|
||||
)
|
||||
: Material(
|
||||
color: _bubbleColor(context, cupertino, user: user),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: _bubbleShape(context, cupertino, user: user),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
child: contentBody,
|
||||
),
|
||||
);
|
||||
return Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
label: '$role message',
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: cupertino
|
||||
? DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: body,
|
||||
)
|
||||
: body,
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Align(
|
||||
alignment: user
|
||||
? AlignmentDirectional.centerEnd
|
||||
: AlignmentDirectional.centerStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 560),
|
||||
child: bubble,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Color _bubbleColor(BuildContext context, bool cupertino, {required bool user}) {
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final surface = cupertino
|
||||
? CupertinoColors.secondarySystemGroupedBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerLow;
|
||||
return user ? accent.withValues(alpha: 0.16) : surface;
|
||||
}
|
||||
|
||||
ShapeBorder _bubbleShape(
|
||||
BuildContext context,
|
||||
bool cupertino, {
|
||||
required bool user,
|
||||
}) {
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final border = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
return RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
color: user ? accent.withValues(alpha: 0.4) : border,
|
||||
),
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(12),
|
||||
topRight: const Radius.circular(12),
|
||||
bottomLeft: Radius.circular(user ? 12 : 4),
|
||||
bottomRight: Radius.circular(user ? 4 : 12),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
BoxDecoration _bubbleDecoration(
|
||||
BuildContext context,
|
||||
bool cupertino, {
|
||||
required bool user,
|
||||
}) {
|
||||
final Color accent;
|
||||
final Color surface;
|
||||
final Color border;
|
||||
if (cupertino) {
|
||||
accent = CupertinoTheme.of(context).primaryColor;
|
||||
surface = CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
);
|
||||
border = CupertinoColors.separator.resolveFrom(context);
|
||||
} else {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
accent = scheme.primary;
|
||||
surface = scheme.surfaceContainerLow;
|
||||
border = scheme.outlineVariant;
|
||||
}
|
||||
final radius = BorderRadius.only(
|
||||
topLeft: const Radius.circular(12),
|
||||
topRight: const Radius.circular(12),
|
||||
bottomLeft: Radius.circular(user ? 12 : 4),
|
||||
bottomRight: Radius.circular(user ? 4 : 12),
|
||||
);
|
||||
return BoxDecoration(
|
||||
color: user ? accent.withValues(alpha: 0.16) : surface,
|
||||
border: Border.all(color: user ? accent.withValues(alpha: 0.4) : border),
|
||||
borderRadius: radius,
|
||||
);
|
||||
}
|
||||
|
||||
TextStyle? _roleStyle(BuildContext context, bool cupertino) =>
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
|
||||
@@ -125,7 +125,10 @@ class ScrollWhenOverflowing extends StatelessWidget {
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: constraints.maxWidth),
|
||||
// Content width, not the pane width: the web's tabs are compact
|
||||
// and left-aligned, not a full-width segmented bar. The scroll
|
||||
// view still reveals every segment on a narrow pane.
|
||||
constraints: const BoxConstraints(),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -52,29 +52,10 @@ class RunsList extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: NeedsYouRunsHeading(
|
||||
rows: controller.runs,
|
||||
frames: controller.repository.gateway.frames,
|
||||
onOpen: (entry) => onSelected(entry.runId),
|
||||
syncToken: syncToken,
|
||||
store: attentionStore,
|
||||
now: attentionNow,
|
||||
notifications: notifications,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (controller.usage != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text('Usage: ${controller.usage}'),
|
||||
),
|
||||
_heading(context),
|
||||
if (controller.error != null) _inlineError(context),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
|
||||
child: usesCupertinoHost(context)
|
||||
? CupertinoSearchTextField(
|
||||
placeholder: 'Filter runs',
|
||||
@@ -92,8 +73,10 @@ class RunsList extends StatelessWidget {
|
||||
Expanded(
|
||||
child: controller.visibleRuns.isEmpty
|
||||
? const Center(child: Text('No runs found.'))
|
||||
: ListView.builder(
|
||||
: ListView.separated(
|
||||
itemCount: controller.visibleRuns.length,
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(height: 1),
|
||||
itemBuilder: (context, index) =>
|
||||
_runTile(context, controller.visibleRuns[index]),
|
||||
),
|
||||
@@ -102,6 +85,29 @@ class RunsList extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _heading(BuildContext context) => Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: controller.usage == null
|
||||
? const SizedBox.shrink()
|
||||
: Text('Usage: ${controller.usage}'),
|
||||
),
|
||||
NeedsYouRunsHeading(
|
||||
rows: controller.runs,
|
||||
frames: controller.repository.gateway.frames,
|
||||
onOpen: (entry) => onSelected(entry.runId),
|
||||
syncToken: syncToken,
|
||||
store: attentionStore,
|
||||
now: attentionNow,
|
||||
notifications: notifications,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Widget _emptyError(BuildContext context) => Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -99,22 +99,35 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
CupertinoTabBar(
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(AppDestination.values[value]),
|
||||
items: _items((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return BottomNavigationBarItem(
|
||||
icon: Icon(item.cupertinoIcon),
|
||||
label: item.label,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: wide
|
||||
// The web keeps a destination rail on a wide window. A native
|
||||
// Cupertino sidebar list is the same idea with the host's own
|
||||
// controls; the tab bar stays the narrow-window navigation.
|
||||
? Row(
|
||||
children: [
|
||||
_CupertinoSidebar(
|
||||
selected: _selected,
|
||||
onSelected: _select,
|
||||
),
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Expanded(child: _destinationStack(contents, index)),
|
||||
CupertinoTabBar(
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(AppDestination.values[value]),
|
||||
items: _items((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return BottomNavigationBarItem(
|
||||
icon: Icon(item.cupertinoIcon),
|
||||
label: item.label,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -172,3 +185,48 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
Widget _destinationStack(List<Widget> contents, int index) =>
|
||||
IndexedStack(index: index, children: contents);
|
||||
}
|
||||
|
||||
/// The wide-window Cupertino destination list: the web's 200px rail with the
|
||||
/// host's own grouped list controls.
|
||||
class _CupertinoSidebar extends StatelessWidget {
|
||||
const _CupertinoSidebar({required this.selected, required this.onSelected});
|
||||
|
||||
final AppDestination selected;
|
||||
final ValueChanged<AppDestination> onSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Container(
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
),
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
children: [
|
||||
for (final destination in AppDestination.values)
|
||||
CupertinoListTile(
|
||||
key: ValueKey('shell.destination.${destination.name}'),
|
||||
leading: Icon(destinationDetails(destination).cupertinoIcon),
|
||||
title: Text(destinationDetails(destination).label),
|
||||
trailing: destination == selected
|
||||
? Icon(
|
||||
CupertinoIcons.checkmark_alt,
|
||||
color: theme.primaryColor,
|
||||
)
|
||||
: null,
|
||||
onTap: () => onSelected(destination),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,16 +38,42 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('Cupertino shell uses native navigation controls', (
|
||||
testWidgets('Cupertino shell uses a tab bar on a narrow window', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino shell uses a sidebar on a wide window', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1280, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
expect(find.byType(CupertinoTabBar), findsNothing);
|
||||
expect(
|
||||
find.byKey(const ValueKey('shell.destination.pipelines')),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino content stays inside safe area', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
tester.view.padding = const FakeViewPadding(top: 36, bottom: 28);
|
||||
addTearDown(tester.view.resetPadding);
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
|
||||
Reference in New Issue
Block a user