From 60b4c495f1ffc480564cd8e9e1f35ea69fc31e28 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 10 Nov 2026 02:33:14 +0000 Subject: [PATCH] Colour the send button with the chat colour A coloured chat's send button uses the chat's seeded primary and its on-colour, like the focus ring; stop stays the host's error red and uncoloured chats keep the host button. --- .../chat/conversation/chat_bar_tint.dart | 15 +++++++-- .../chat/conversation/chat_composer_bar.dart | 19 ++++++++--- .../chat_composer_focus_ring_test.dart | 33 ++++++++++++++++++- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/app/lib/features/chat/conversation/chat_bar_tint.dart b/app/lib/features/chat/conversation/chat_bar_tint.dart index b538db6d..af706fc9 100644 --- a/app/lib/features/chat/conversation/chat_bar_tint.dart +++ b/app/lib/features/chat/conversation/chat_bar_tint.dart @@ -84,6 +84,14 @@ ChatBarTint? chatBarTintOf(BuildContext context, String? name) { /// The composer's focus ring: the seeded scheme's `primary` for a coloured /// chat, else the host's primary colour; always drawn at full opacity. +/// The seeded scheme of a coloured chat in this context, or null for a chat +/// with no colour (which keeps the host's own controls). +ColorScheme? chatSchemeOf(BuildContext context, String? name) { + final shade = chatColorShade(context, name); + if (shade == null) return null; + return chatSeededScheme(shade, dark: chatColorDarkSurface(context)); +} + Color chatFocusRingColor(BuildContext context, String? name) { final shade = chatColorShade(context, name); if (shade != null) { @@ -105,7 +113,9 @@ class ChatPaneActivity extends InheritedWidget { final bool inactive; static bool inactiveOf(BuildContext context) => - context.dependOnInheritedWidgetOfExactType()?.inactive ?? + context + .dependOnInheritedWidgetOfExactType() + ?.inactive ?? false; @override @@ -148,6 +158,5 @@ class ChatBarTintScope extends InheritedWidget { .foreground; @override - bool updateShouldNotify(ChatBarTintScope oldWidget) => - tint != oldWidget.tint; + bool updateShouldNotify(ChatBarTintScope oldWidget) => tint != oldWidget.tint; } diff --git a/app/lib/features/chat/conversation/chat_composer_bar.dart b/app/lib/features/chat/conversation/chat_composer_bar.dart index dbba87f5..27ec374b 100644 --- a/app/lib/features/chat/conversation/chat_composer_bar.dart +++ b/app/lib/features/chat/conversation/chat_composer_bar.dart @@ -983,7 +983,6 @@ class _ChatComposerBarState extends State { ), ); - /// The attach control: a host button that opens the picker, disabled when the /// host has no picker or one prompt is already awaiting its reply. Widget _attach(BuildContext context, bool cupertino) { @@ -1335,6 +1334,9 @@ class _ChatComposerBarState extends State { ? chatRunShellLabel : chatSendLabel; final key = Key(stop ? 'chat-composer-stop' : 'chat-composer-primary'); + // A coloured chat's send button takes the chat's colour (its seeded + // primary, like the focus ring); stop stays the host's error red. + final tinted = chatSchemeOf(context, widget.chatColor); if (cupertino) { return Semantics( button: true, @@ -1355,13 +1357,17 @@ class _ChatComposerBarState extends State { ), color: stop ? CupertinoColors.systemRed.resolveFrom(context) - : null, + : tinted?.primary, onPressed: enabled ? press : null, child: stop ? const ChatStopIcon( child: Icon(CupertinoIcons.stop_fill, size: 18), ) - : const Icon(CupertinoIcons.arrow_up, size: 18), + : Icon( + CupertinoIcons.arrow_up, + size: 18, + color: enabled ? tinted?.onPrimary : null, + ), ), ), ), @@ -1376,7 +1382,12 @@ class _ChatComposerBarState extends State { backgroundColor: scheme.error, foregroundColor: scheme.onError, ) - : null, + : tinted == null + ? null + : IconButton.styleFrom( + backgroundColor: tinted.primary, + foregroundColor: tinted.onPrimary, + ), onPressed: enabled ? press : null, icon: stop ? const ChatStopIcon(child: Icon(Icons.stop)) diff --git a/app/test/features/chat/conversation/chat_composer_focus_ring_test.dart b/app/test/features/chat/conversation/chat_composer_focus_ring_test.dart index a1368007..f038e2b5 100644 --- a/app/test/features/chat/conversation/chat_composer_focus_ring_test.dart +++ b/app/test/features/chat/conversation/chat_composer_focus_ring_test.dart @@ -68,7 +68,9 @@ void main() { await tester.pumpAndSettle(); await _focusField(tester); - final context = tester.element(find.byKey(const Key('chat-composer-field'))); + final context = tester.element( + find.byKey(const Key('chat-composer-field')), + ); final teal = chatColorShade(context, 'teal')!; final expected = chatSeededScheme(teal, dark: false).primary; expect(_ring(tester).side.color, expected); @@ -77,6 +79,35 @@ void main() { expect(expected, isNot(teal)); }); + testWidgets('a coloured chat\'s send button takes the chat colour', ( + tester, + ) async { + await tester.pumpWidget( + composerThread(gateway, session: {'id': 's', 'color': 'teal'}), + ); + await tester.pumpAndSettle(); + await tester.enterText( + find.byKey(const Key('chat-composer-field')), + 'hello', + ); + await tester.pumpAndSettle(); + final send = find.byKey(const Key('chat-composer-primary')); + final context = tester.element(send); + final scheme = chatSchemeOf(context, 'teal')!; + final button = tester.widget(send); + final states = {}; + expect(button.style!.backgroundColor!.resolve(states), scheme.primary); + expect(button.style!.foregroundColor!.resolve(states), scheme.onPrimary); + }); + + testWidgets('an uncoloured chat keeps the host send button', (tester) async { + await tester.pumpWidget(composerThread(gateway)); + await tester.pumpAndSettle(); + final send = find.byKey(const Key('chat-composer-primary')); + expect(tester.widget(send).style, isNull); + expect(chatSchemeOf(tester.element(send), null), isNull); + }); + testWidgets('the ring fades out again when focus leaves', (tester) async { await tester.pumpWidget(composerThread(gateway)); await tester.pumpAndSettle();