ca2f7eee32
AppDesign builds each design's light and dark ThemeData with an AppDesignTokens extension (corner radius, flat surfaces, frame colour, ANSI accents, prompt glyph). Settings gains a Design picker stored per device; the theme hosts rebuild live. Terminal is monospace (bundled RobotoMono), near-black or paper, flat 1px frames with 3px corners, and draws the chat transcript as prompt lines, tool dot/result lines and bracketed follow-up lines. Default keeps its exact themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
130 lines
3.9 KiB
Dart
130 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/app_design_tokens.dart';
|
|
|
|
/// The leading circle every list row uses, as large as a native contact
|
|
/// avatar ([CircleAvatar]'s default).
|
|
const double kAppListAvatarSize = 40;
|
|
|
|
/// A list row's leading identity: an icon or an initial on a tinted circle,
|
|
/// with an optional corner badge (a chat's activity indicator).
|
|
///
|
|
/// [foreground] colours the icon/initial; the circle is [background], or the
|
|
/// foreground at 14% when omitted, so a status colour reads as a soft tint.
|
|
class AppListAvatar extends StatelessWidget {
|
|
const AppListAvatar({
|
|
super.key,
|
|
required this.child,
|
|
this.foreground,
|
|
this.background,
|
|
this.badge,
|
|
});
|
|
|
|
/// The first character of [name] (or `?`), large and bold enough to read
|
|
/// at a glance in the circle.
|
|
factory AppListAvatar.initial(
|
|
String name, {
|
|
Key? key,
|
|
required Color color,
|
|
Widget? badge,
|
|
}) {
|
|
final trimmed = name.trimLeft();
|
|
final initial = trimmed.isEmpty
|
|
? '?'
|
|
: String.fromCharCode(trimmed.runes.first).toUpperCase();
|
|
return AppListAvatar(
|
|
key: key,
|
|
foreground: color,
|
|
badge: badge,
|
|
child: Text(initial),
|
|
);
|
|
}
|
|
|
|
final Widget child;
|
|
final Color? foreground;
|
|
final Color? background;
|
|
final Widget? badge;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final mark = foreground ?? Theme.of(context).colorScheme.onSurfaceVariant;
|
|
final fill =
|
|
background ??
|
|
(foreground == null
|
|
? Theme.of(context).colorScheme.surfaceContainerHighest
|
|
: mark.withValues(alpha: 0.14));
|
|
final initialStyle =
|
|
(Theme.of(context).textTheme.titleMedium ?? const TextStyle()).copyWith(
|
|
color: mark,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w700,
|
|
height: 1,
|
|
);
|
|
// A flat design (Terminal) frames the mark in a square box instead of a
|
|
// tinted circle.
|
|
final tokens = AppDesignTokens.of(context);
|
|
final decoration = tokens.flat
|
|
? BoxDecoration(
|
|
border: Border.all(color: mark.withValues(alpha: 0.55)),
|
|
borderRadius: tokens.corners(BorderRadius.zero),
|
|
)
|
|
: BoxDecoration(color: fill, shape: BoxShape.circle);
|
|
final circle = SizedBox.square(
|
|
dimension: kAppListAvatarSize,
|
|
child: DecoratedBox(
|
|
decoration: decoration,
|
|
child: Center(
|
|
// The glyph is identity, not reading text: it scales down to stay
|
|
// inside the circle under large text instead of overflowing it.
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8),
|
|
child: FittedBox(
|
|
fit: BoxFit.scaleDown,
|
|
child: IconTheme.merge(
|
|
data: IconThemeData(color: mark, size: 22),
|
|
child: DefaultTextStyle(style: initialStyle, child: child),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
if (badge == null) return circle;
|
|
return Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
circle,
|
|
PositionedDirectional(end: -2, bottom: -2, child: badge!),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A small coloured dot that leads a row's subtitle (a latest-run state) or
|
|
/// trails it (unread). It follows text scaling and carries its own label.
|
|
class AppListStatusDot extends StatelessWidget {
|
|
const AppListStatusDot({
|
|
super.key,
|
|
required this.color,
|
|
this.semanticLabel,
|
|
this.size = 8,
|
|
});
|
|
|
|
final Color color;
|
|
final String? semanticLabel;
|
|
final double size;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final dimension = MediaQuery.textScalerOf(context).scale(size);
|
|
final dot = DecoratedBox(
|
|
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
|
child: SizedBox.square(dimension: dimension),
|
|
);
|
|
if (semanticLabel == null) return ExcludeSemantics(child: dot);
|
|
return Semantics(
|
|
label: semanticLabel,
|
|
child: ExcludeSemantics(child: dot),
|
|
);
|
|
}
|
|
}
|