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
@@ -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<IconButton>(send);
final states = <WidgetState>{};
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<IconButton>(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();