b382ae7e03
Tint the bar's glass pieces with the chat shade over the raised surface (0.16 light and dark, then the 0.82 glass opacity) and draw its labels in the seeded scheme's onPrimaryContainer; Cupertino takes it as the bar's primary colour. Inactive split panes keep half the tint. Remove ChatColorWash. The composer focus ring is the seeded primary at full opacity, 2 px, with no glow. Contrast test asserts AA for every palette colour on both hosts in light and dark.
63 lines
2.1 KiB
Dart
63 lines
2.1 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
/// The composer's focus indication: a solid ring in the chat's accent colour
|
|
/// along the pill's edge, so a focused field shows as such without relying
|
|
/// on its caret alone. It fades in and out with focus; at rest unfocused
|
|
/// nothing visible is drawn.
|
|
///
|
|
/// The accent is the focus colour of the chat's own colour (the `primary`
|
|
/// of a scheme seeded from it, `chatFocusRingColor`) when it has one, else
|
|
/// the host's primary colour. It is drawn at full opacity, so it keeps 3:1
|
|
/// against the page for every chat colour in light and dark.
|
|
class ComposerFocusRing extends StatelessWidget {
|
|
const ComposerFocusRing({
|
|
super.key,
|
|
required this.focus,
|
|
required this.accent,
|
|
required this.shape,
|
|
required this.child,
|
|
});
|
|
|
|
/// The field's focus node; the ring follows its [FocusNode.hasFocus].
|
|
final FocusNode focus;
|
|
|
|
/// The ring's colour while focused.
|
|
final Color accent;
|
|
|
|
/// The pill's shape, so the ring hugs its edge.
|
|
final OutlinedBorder shape;
|
|
final Widget child;
|
|
|
|
/// How long the ring takes to appear or fade.
|
|
static const Duration duration = Duration(milliseconds: 160);
|
|
|
|
/// The ring's stroke, drawn just inside the pill's edge over its hairline.
|
|
static const double ringWidth = 2;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: focus,
|
|
child: child,
|
|
builder: (context, child) {
|
|
final focused = focus.hasFocus;
|
|
// The decoration keeps the same shape and stroke while only its colour
|
|
// changes, so the container lerps it into one fade.
|
|
return AnimatedContainer(
|
|
key: const Key('chat-composer-focus-ring'),
|
|
duration: duration,
|
|
curve: Curves.easeOutCubic,
|
|
// Over the child: the pill's fill would otherwise cover the ring.
|
|
foregroundDecoration: ShapeDecoration(
|
|
shape: shape.copyWith(
|
|
side: BorderSide(
|
|
color: accent.withValues(alpha: focused ? 1 : 0),
|
|
width: ringWidth,
|
|
),
|
|
),
|
|
),
|
|
child: child,
|
|
);
|
|
},
|
|
);
|
|
}
|