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.
This commit is contained in:
2026-11-10 02:33:14 +00:00
parent 87519985bf
commit 60b4c495f1
3 changed files with 59 additions and 8 deletions
@@ -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<ChatPaneActivity>()?.inactive ??
context
.dependOnInheritedWidgetOfExactType<ChatPaneActivity>()
?.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;
}
@@ -983,7 +983,6 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
),
);
/// 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<ChatComposerBar> {
? 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<ChatComposerBar> {
),
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<ChatComposerBar> {
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))