Merge main (Notebook) into High contrast; snap theme switches into and out of it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,13 +22,26 @@ const double kChatStackLabelGap = 10;
|
||||
/// through each other, and its rim separates them. A raised design drops a
|
||||
/// short shadow; a flat one casts none, and its avatar frames itself.
|
||||
class ChatStackDisc extends StatelessWidget {
|
||||
const ChatStackDisc({super.key, required this.child, this.ring});
|
||||
const ChatStackDisc({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.ring,
|
||||
this.lift,
|
||||
this.liftRing,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
|
||||
/// The rim's colour when it marks the current chat; null for the surface.
|
||||
final Color? ring;
|
||||
|
||||
/// While dragged (0 at rest, 1 lifted): a deeper shadow, or under a flat
|
||||
/// design a frame in the primary colour.
|
||||
final Animation<double>? lift;
|
||||
|
||||
/// A drop target's ring colour, worn as [lift] runs.
|
||||
final Color? liftRing;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
@@ -42,16 +55,20 @@ class ChatStackDisc extends StatelessWidget {
|
||||
);
|
||||
final ring = this.ring;
|
||||
final shape = chatStackShape(tokens);
|
||||
final rest = ShapeDecoration(
|
||||
color: ring ?? base,
|
||||
// A flat design's avatar frames itself; the rim stays bare.
|
||||
shape: shape,
|
||||
shadows: !tokens.flat ? chatStackShadows(scheme) : null,
|
||||
);
|
||||
final lift = this.lift;
|
||||
return SizedBox.square(
|
||||
dimension: kChatStackSlot,
|
||||
child: Center(
|
||||
child: DecoratedBox(
|
||||
decoration: ShapeDecoration(
|
||||
color: ring ?? base,
|
||||
// A flat design's avatar frames itself; the rim stays bare.
|
||||
shape: shape,
|
||||
shadows: !tokens.flat ? chatStackShadows(scheme) : null,
|
||||
),
|
||||
child: chatStackLifted(
|
||||
lift,
|
||||
rest,
|
||||
chatStackRaised(rest, tokens, scheme, ring: liftRing),
|
||||
child: SizedBox.square(
|
||||
dimension: kChatStackDisc,
|
||||
child: Center(
|
||||
@@ -93,6 +110,59 @@ List<BoxShadow> chatStackShadows(ColorScheme scheme) => [
|
||||
),
|
||||
];
|
||||
|
||||
/// A short, close shadow's lifted form: deeper and softer, as a card
|
||||
/// picked up off the column.
|
||||
List<BoxShadow> chatStackLiftShadows(ColorScheme scheme) => [
|
||||
BoxShadow(
|
||||
color: scheme.shadow.withValues(alpha: .20),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
BoxShadow(
|
||||
color: scheme.shadow.withValues(alpha: .14),
|
||||
blurRadius: 22,
|
||||
offset: const Offset(0, 12),
|
||||
),
|
||||
];
|
||||
|
||||
/// [rest] as a dragged item wears it: the lifted shadow, or under a flat
|
||||
/// design (which casts none) a frame in the primary colour. With [ring] (a
|
||||
/// drop target) every design gets a ring in that colour.
|
||||
ShapeDecoration chatStackRaised(
|
||||
ShapeDecoration rest,
|
||||
AppDesignTokens tokens,
|
||||
ColorScheme scheme, {
|
||||
Color? ring,
|
||||
}) {
|
||||
final shape = rest.shape;
|
||||
final side = ring != null
|
||||
? BorderSide(color: ring, width: 2)
|
||||
: tokens.flat
|
||||
? BorderSide(color: scheme.primary, width: 1.5)
|
||||
: null;
|
||||
return ShapeDecoration(
|
||||
color: rest.color,
|
||||
shape: side != null && shape is OutlinedBorder
|
||||
? shape.copyWith(side: side)
|
||||
: shape,
|
||||
shadows: tokens.flat ? null : chatStackLiftShadows(scheme),
|
||||
);
|
||||
}
|
||||
|
||||
/// [child] over [rest], or blending to [raised] as [lift] runs: repaints
|
||||
/// only.
|
||||
Widget chatStackLifted(
|
||||
Animation<double>? lift,
|
||||
ShapeDecoration rest,
|
||||
ShapeDecoration raised, {
|
||||
required Widget child,
|
||||
}) => lift == null
|
||||
? DecoratedBox(decoration: rest, child: child)
|
||||
: DecoratedBoxTransition(
|
||||
decoration: DecorationTween(begin: rest, end: raised).animate(lift),
|
||||
child: child,
|
||||
);
|
||||
|
||||
/// The name beside an avatar in the open column: a small pill tinted with
|
||||
/// the chat's colour over an opaque face, one line, ellipsised.
|
||||
class ChatStackLabel extends StatelessWidget {
|
||||
@@ -101,12 +171,28 @@ class ChatStackLabel extends StatelessWidget {
|
||||
required this.text,
|
||||
this.color,
|
||||
this.emphasized = false,
|
||||
this.lift,
|
||||
this.liftRing,
|
||||
this.detail,
|
||||
this.trailing,
|
||||
});
|
||||
|
||||
final String text;
|
||||
|
||||
/// A muted note after the text (a group's chat count).
|
||||
final String? detail;
|
||||
|
||||
/// A small control at the end (the group header's menu).
|
||||
final Widget? trailing;
|
||||
|
||||
/// A drop target's ring colour, worn as [lift] runs.
|
||||
final Color? liftRing;
|
||||
final Color? color;
|
||||
final bool emphasized;
|
||||
|
||||
/// While dragged, as [ChatStackDisc.lift].
|
||||
final Animation<double>? lift;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
@@ -125,29 +211,59 @@ class ChatStackLabel extends StatelessWidget {
|
||||
color: scheme.onSurface,
|
||||
fontWeight: emphasized ? FontWeight.w700 : FontWeight.w500,
|
||||
);
|
||||
return DecoratedBox(
|
||||
decoration: ShapeDecoration(
|
||||
color: fill,
|
||||
shape: _labelShape(
|
||||
tokens,
|
||||
outlined ? BorderSide(color: color, width: 3) : null,
|
||||
),
|
||||
shadows: tokens.flat ? null : chatStackShadows(scheme),
|
||||
final rest = ShapeDecoration(
|
||||
color: fill,
|
||||
shape: _labelShape(
|
||||
tokens,
|
||||
outlined ? BorderSide(color: color, width: 3) : null,
|
||||
),
|
||||
shadows: tokens.flat ? null : chatStackShadows(scheme),
|
||||
);
|
||||
return chatStackLifted(
|
||||
lift,
|
||||
rest,
|
||||
chatStackRaised(rest, tokens, scheme, ring: liftRing),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Text(
|
||||
text,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
style: style,
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: 12,
|
||||
end: trailing == null ? 12 : 2,
|
||||
top: 6,
|
||||
bottom: 6,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
text,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
style: style,
|
||||
),
|
||||
),
|
||||
if (detail case final detail?) ...[
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
detail,
|
||||
maxLines: 1,
|
||||
style: style.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (trailing case final trailing?) ...[
|
||||
const SizedBox(width: 2),
|
||||
trailing,
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ShapeBorder _labelShape(AppDesignTokens tokens, BorderSide? outline) {
|
||||
OutlinedBorder _labelShape(AppDesignTokens tokens, [BorderSide? outline]) {
|
||||
final side = outline ?? tokens.frameSide ?? BorderSide.none;
|
||||
final r = tokens.radius;
|
||||
return r == null
|
||||
|
||||
Reference in New Issue
Block a user