Send button: fixed size in every design and a clear 3px gap to its usage ring
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1394,12 +1394,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
child: IconButton.filled(
|
||||
onLongPress: open,
|
||||
key: const Key('chat-composer-primary'),
|
||||
style: tinted == null
|
||||
? null
|
||||
: IconButton.styleFrom(
|
||||
backgroundColor: tinted.primary,
|
||||
foregroundColor: tinted.onPrimary,
|
||||
),
|
||||
style: chatSendButtonStyle(
|
||||
background: tinted?.primary,
|
||||
foreground: tinted?.onPrimary,
|
||||
),
|
||||
onPressed: enabled ? press : null,
|
||||
icon: const Icon(Icons.arrow_upward),
|
||||
),
|
||||
|
||||
@@ -132,15 +132,23 @@ class _ChatSendUsageRingState extends State<ChatSendUsageRing> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The filled send button's visible circle: a Material 3 icon button's 40
|
||||
/// logical pixels adjusted by its visual density, inside a target that may
|
||||
/// be padded beyond it.
|
||||
double chatSendButtonDiameter(BuildContext context) {
|
||||
final density =
|
||||
IconButtonTheme.of(context).style?.visualDensity ??
|
||||
Theme.of(context).visualDensity;
|
||||
return 40 + density.baseSizeAdjustment.dx;
|
||||
}
|
||||
/// The send button's visible size in every design: the composer pins it
|
||||
/// ([chatSendButtonStyle]), so the ring's gap is the same everywhere.
|
||||
const double chatSendButtonSize = 40;
|
||||
|
||||
/// The send button's fixed size, whatever the design's density.
|
||||
ButtonStyle chatSendButtonStyle({Color? background, Color? foreground}) =>
|
||||
IconButton.styleFrom(
|
||||
backgroundColor: background,
|
||||
foregroundColor: foreground,
|
||||
fixedSize: const Size.square(chatSendButtonSize),
|
||||
minimumSize: const Size.square(chatSendButtonSize),
|
||||
maximumSize: const Size.square(chatSendButtonSize),
|
||||
padding: EdgeInsets.zero,
|
||||
);
|
||||
|
||||
/// The filled send button's visible size.
|
||||
double chatSendButtonDiameter(BuildContext context) => chatSendButtonSize;
|
||||
|
||||
/// The ring: a faint full track and the used arc clockwise from the top, a
|
||||
/// hairline gap outside the button's circle of diameter [circle], centred
|
||||
@@ -164,7 +172,10 @@ class ChatUsageRingPainter extends CustomPainter {
|
||||
final double? cornerRadius;
|
||||
|
||||
static const double stroke = 2;
|
||||
static const double gap = 1;
|
||||
|
||||
/// A clear gap between the button and the ring, so the ring reads as its
|
||||
/// own feature.
|
||||
static const double gap = 3;
|
||||
|
||||
/// The ring's centre-line radius.
|
||||
double get radius => circle / 2 + gap + stroke / 2;
|
||||
|
||||
@@ -103,7 +103,11 @@ void main() {
|
||||
await tester.pumpWidget(composerThread(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
final send = find.byKey(const Key('chat-composer-primary'));
|
||||
expect(tester.widget<IconButton>(send).style, isNull);
|
||||
// Only the fixed size is set: no colours, so the host's filled colours
|
||||
// apply.
|
||||
final style = tester.widget<IconButton>(send).style!;
|
||||
expect(style.backgroundColor, isNull);
|
||||
expect(style.foregroundColor, isNull);
|
||||
expect(chatSchemeOf(tester.element(send), null), isNull);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user