diff --git a/app/lib/features/chat/conversation/chat_bar_control_style.dart b/app/lib/features/chat/conversation/chat_bar_control_style.dart index a70a9f68..ca00650a 100644 --- a/app/lib/features/chat/conversation/chat_bar_control_style.dart +++ b/app/lib/features/chat/conversation/chat_bar_control_style.dart @@ -9,12 +9,16 @@ import 'chat_bar_tint.dart'; /// /// Material: a [TextButton] style in the role the bar's icon buttons use /// (`onSurfaceVariant`). -ButtonStyle chatBarTextButtonStyle(BuildContext context) => - TextButton.styleFrom( - foregroundColor: - ChatBarTintScope.foregroundOf(context) ?? - Theme.of(context).colorScheme.onSurfaceVariant, - ); +ButtonStyle chatBarTextButtonStyle( + BuildContext context, { + bool compact = false, +}) => TextButton.styleFrom( + foregroundColor: + ChatBarTintScope.foregroundOf(context) ?? + Theme.of(context).colorScheme.onSurfaceVariant, + padding: compact ? null : EdgeInsets.zero, + minimumSize: compact ? null : const Size.square(kMinInteractiveDimension), +); /// Cupertino: [content] (a [CupertinoButton]'s child) in the label colour /// instead of the button's tint. diff --git a/app/lib/features/chat/conversation/chat_mode_control.dart b/app/lib/features/chat/conversation/chat_mode_control.dart index 4fd35c06..6c87bdaa 100644 --- a/app/lib/features/chat/conversation/chat_mode_control.dart +++ b/app/lib/features/chat/conversation/chat_mode_control.dart @@ -126,7 +126,7 @@ class _ChatModeControlState extends State { child: ExcludeSemantics( child: CupertinoButton( key: key, - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.zero, onPressed: _open, child: chatBarCupertinoContent(context, content), ), @@ -143,7 +143,7 @@ class _ChatModeControlState extends State { message: 'Change mode (currently $label)', child: TextButton( key: key, - style: chatBarTextButtonStyle(context), + style: chatBarTextButtonStyle(context, compact: iconOnly), onPressed: _open, child: content, ), diff --git a/app/lib/features/chat/conversation/chat_model_control.dart b/app/lib/features/chat/conversation/chat_model_control.dart index ddd09936..5f7d1915 100644 --- a/app/lib/features/chat/conversation/chat_model_control.dart +++ b/app/lib/features/chat/conversation/chat_model_control.dart @@ -139,7 +139,7 @@ class _ChatModelControlState extends State { child: ExcludeSemantics( child: CupertinoButton( key: key, - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.zero, onPressed: _open, child: chatBarCupertinoContent(context, content), ), @@ -156,7 +156,7 @@ class _ChatModelControlState extends State { message: 'Change model (currently $label)', child: TextButton( key: key, - style: chatBarTextButtonStyle(context), + style: chatBarTextButtonStyle(context, compact: compact), onPressed: _open, child: content, ), diff --git a/app/lib/features/chat/conversation/chat_thread_header.dart b/app/lib/features/chat/conversation/chat_thread_header.dart index 344bc99f..709c9396 100644 --- a/app/lib/features/chat/conversation/chat_thread_header.dart +++ b/app/lib/features/chat/conversation/chat_thread_header.dart @@ -67,6 +67,20 @@ class ChatThreadHeader extends StatelessWidget { builder: (context, constraints) { final textScale = MediaQuery.textScalerOf(context).scale(14) / 14; final compact = constraints.maxWidth / textScale < 800; + final actionChildren = [ + ...actions, + for (final action in moreActions) + if (action is! SegmentedOverflowable) action, + if (moreActions.whereType().isNotEmpty) + SegmentedMoreButton( + cupertino: cupertino, + entries: [ + for (final action + in moreActions.whereType()) + action.overflowEntry, + ], + ), + ]; final Widget bar = SegmentedBar( cupertino: cupertino, pillColor: tint?.fill, @@ -96,6 +110,7 @@ class ChatThreadHeader extends StatelessWidget { ChatWorkspacePaneActionBar( child: _ControlIsland( key: const Key('chat-model-permission-island'), + gap: compact ? 0 : 8, children: controls, ), ), @@ -105,22 +120,10 @@ class ChatThreadHeader extends StatelessWidget { key: const Key('chat-actions-island'), mainAxisSize: MainAxisSize.min, children: [ - ...actions, - // Unknown action widgets retain their original behavior and stay - // visible; only the explicit overflow contract becomes a menu. - for (final action in moreActions) - if (action is! SegmentedOverflowable) action, - if (moreActions - .whereType() - .isNotEmpty) - SegmentedMoreButton( - cupertino: cupertino, - entries: [ - for (final action - in moreActions.whereType()) - action.overflowEntry, - ], - ), + for (final (index, action) in actionChildren.indexed) ...[ + if (index > 0 && !compact) const SizedBox(width: 8), + action, + ], ], ), ), @@ -148,12 +151,18 @@ class ChatThreadHeader extends StatelessWidget { /// Related selectors share the available width. Each remains a real control; /// they never migrate into the unrelated actions menu. class _ControlIsland extends StatelessWidget { - const _ControlIsland({super.key, required this.children}); + const _ControlIsland({super.key, required this.children, required this.gap}); final List children; + final double gap; @override Widget build(BuildContext context) => Row( mainAxisSize: MainAxisSize.min, - children: [for (final child in children) Flexible(child: child)], + children: [ + for (final (index, child) in children.indexed) ...[ + if (index > 0) SizedBox(width: gap), + Flexible(child: child), + ], + ], ); } diff --git a/app/notes/even-spacing-between-chat-action-bar.md b/app/notes/even-spacing-between-chat-action-bar.md new file mode 100644 index 00000000..ac27da74 --- /dev/null +++ b/app/notes/even-spacing-between-chat-action-bar.md @@ -0,0 +1,10 @@ +# Even spacing between chat action bar controls + +Implemented one explicit 8dp gap between controls within the model/mode group, +between action widgets, and between the two action groups. Removed duplicate +horizontal padding from chat model/mode text controls while retaining native +minimum touch targets. + +Focused regression coverage is in +`test/features/chat/conversation/chat_thread_header_test.dart` for Material and +Cupertino at 1440x900. UI captures are owned by the UI review stage. diff --git a/app/test/features/chat/conversation/chat_thread_header_test.dart b/app/test/features/chat/conversation/chat_thread_header_test.dart index 65a45103..24381ac2 100644 --- a/app/test/features/chat/conversation/chat_thread_header_test.dart +++ b/app/test/features/chat/conversation/chat_thread_header_test.dart @@ -38,6 +38,59 @@ void _useNarrowText(WidgetTester tester) { } void main() { + for (final cupertino in [false, true]) { + testWidgets( + '${cupertino ? 'Cupertino' : 'Material'} wide header uses one explicit control gap', + (tester) async { + tester.view.physicalSize = const Size(1440, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + Widget control(String key) => + SizedBox(key: Key(key), width: 48, height: 48); + + await tester.pumpWidget( + _host( + ChatThreadHeader( + title: 'Chat', + folder: 'demo', + onInfo: () {}, + controls: [ + control('header-control-1'), + control('header-control-2'), + ], + actions: [control('header-action-1'), control('header-action-2')], + moreActions: [ + ChatBarAction( + label: 'More action', + onPressed: () {}, + materialIcon: Icons.more_horiz, + cupertinoIcon: CupertinoIcons.ellipsis, + ), + ], + ), + cupertino: cupertino, + ), + ); + await tester.pumpAndSettle(); + + double gap(String left, String right) => + tester.getTopLeft(find.byKey(Key(right))).dx - + tester.getTopRight(find.byKey(Key(left))).dx; + + expect(gap('header-control-1', 'header-control-2'), 8); + expect(gap('header-control-2', 'header-action-1'), 8); + expect(gap('header-action-1', 'header-action-2'), 8); + expect( + tester.getTopLeft(find.byKey(segmentedMoreKey).first).dx - + tester.getTopRight(find.byKey(const Key('header-action-2'))).dx, + 8, + ); + }, + ); + } + testWidgets('short large-text header keeps controls in its single row', ( tester, ) async {