Merge upstream/dev: custom and holiday themes, chat backgrounds
Upstream's theme system (two-color custom themes, holiday themes, picture icons, chat backgrounds) next to the tth terminal theme: - a user's custom theme wins; without one, themeMode 'terminal' is still the dark theme (main.dart); - MeshTheme.buildFrom (terminal base) builds with the stock bubble, icon and map extensions, like dark()/light(); - terminal avatars also show a theme slot's glyph; the bottom bar stays 44 px without labels in the terminal theme, 76/60 otherwise; - map overlays: terminal panels stay square and black, otherwise upstream's palette/follow-theme logic; channel list keeps the terminal padding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
675342e745
144 files changed
+13281
-732
No files matched your search
@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import '../theme/terminal_theme.dart';
|
||||
import '../theme/theme_icons.dart';
|
||||
|
||||
/// MeshCore shared design kit.
|
||||
///
|
||||
@@ -124,6 +125,46 @@ class MeshCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Tinted pill chip for statuses: a dot or icon plus a short label.
|
||||
/// Contrast ratio between two opaque colors (WCAG definition).
|
||||
double meshContrastRatio(Color a, Color b) {
|
||||
final la = a.computeLuminance();
|
||||
final lb = b.computeLuminance();
|
||||
return (math.max(la, lb) + 0.05) / (math.min(la, lb) + 0.05);
|
||||
}
|
||||
|
||||
/// [accent] darkened (on light backgrounds) or lightened (on dark ones) until
|
||||
/// it reaches [minContrast] against [background]. WCAG asks 4.5 for text and
|
||||
/// 3 for icons. Accents such as amber are bright enough for the dark theme but
|
||||
/// unreadable on their own pale tint in the light theme.
|
||||
Color readableAccent(
|
||||
Color accent,
|
||||
Color background, {
|
||||
double minContrast = 4.5,
|
||||
}) {
|
||||
if (meshContrastRatio(accent, background) >= minContrast) return accent;
|
||||
final darken = background.computeLuminance() > 0.18;
|
||||
final hsl = HSLColor.fromColor(accent);
|
||||
for (var step = 1; step <= 20; step++) {
|
||||
final lightness = (hsl.lightness + (darken ? -0.05 : 0.05) * step).clamp(
|
||||
0.0,
|
||||
1.0,
|
||||
);
|
||||
final candidate = hsl.withLightness(lightness).toColor();
|
||||
if (meshContrastRatio(candidate, background) >= minContrast) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return darken ? Colors.black : Colors.white;
|
||||
}
|
||||
|
||||
/// The background of a [tint] alpha wash of [accent] drawn on a card.
|
||||
Color _tintedCardBackground(BuildContext context, Color accent, double tint) {
|
||||
return Color.alphaBlend(
|
||||
accent.withValues(alpha: tint),
|
||||
Theme.of(context).colorScheme.surfaceContainerLow,
|
||||
);
|
||||
}
|
||||
|
||||
class StatusChip extends StatelessWidget {
|
||||
final String label;
|
||||
final Color color;
|
||||
@@ -142,6 +183,11 @@ class StatusChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// The label uses the normal text color: colored text on a tint of the
|
||||
// same color is hard to read. The icon or dot carries the color, adjusted
|
||||
// to stay visible on the tint.
|
||||
final background = _tintedCardBackground(context, color, 0.12);
|
||||
final markColor = readableAccent(color, background, minContrast: 3);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
@@ -153,9 +199,9 @@ class StatusChip extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null)
|
||||
Icon(icon, size: fontSize + 2, color: color)
|
||||
Icon(icon, size: fontSize + 2, color: markColor)
|
||||
else
|
||||
PulseDot(color: color, size: 7, animate: pulse),
|
||||
PulseDot(color: markColor, size: 7, animate: pulse),
|
||||
const SizedBox(width: 5),
|
||||
Flexible(
|
||||
child: Text(
|
||||
@@ -165,7 +211,7 @@ class StatusChip extends StatelessWidget {
|
||||
style: MeshTheme.mono(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -256,12 +302,14 @@ class StatTile extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Initials avatar with a deterministic per-name hue, or a fixed [color]
|
||||
/// for node-type coloring. Optional [icon] replaces initials.
|
||||
/// for node-type coloring. Optional [icon] or themeable [iconSlot] replaces
|
||||
/// initials.
|
||||
class AvatarCircle extends StatelessWidget {
|
||||
final String name;
|
||||
final double size;
|
||||
final Color? color;
|
||||
final IconData? icon;
|
||||
final ThemeIconSlot? iconSlot;
|
||||
|
||||
const AvatarCircle({
|
||||
super.key,
|
||||
@@ -269,6 +317,7 @@ class AvatarCircle extends StatelessWidget {
|
||||
this.size = 40,
|
||||
this.color,
|
||||
this.icon,
|
||||
this.iconSlot,
|
||||
});
|
||||
|
||||
static const _hues = [
|
||||
@@ -299,8 +348,8 @@ class AvatarCircle extends StatelessWidget {
|
||||
width: s,
|
||||
height: s,
|
||||
child: Center(
|
||||
child: icon != null
|
||||
? Icon(icon, size: s * 0.85, color: accent)
|
||||
child: (icon ?? iconSlot?.icon) != null
|
||||
? Icon(icon ?? iconSlot!.icon, size: s * 0.85, color: accent)
|
||||
: Text(
|
||||
initials,
|
||||
style: MeshTheme.mono(
|
||||
@@ -313,6 +362,30 @@ class AvatarCircle extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
final background = _tintedCardBackground(context, accent, 0.14);
|
||||
// A theme picture (e.g. a holiday marker) fills the whole circle, the
|
||||
// same as on the map, rather than sitting small inside the tint.
|
||||
final picture = iconSlot == null
|
||||
? null
|
||||
: themePictureOf(MeshIconTheme.of(context)[iconSlot!]);
|
||||
if (picture != null) {
|
||||
return SizedBox.square(
|
||||
dimension: size,
|
||||
child: ClipOval(
|
||||
child: Image(
|
||||
image: picture,
|
||||
fit: BoxFit.cover,
|
||||
gaplessPlayback: true,
|
||||
filterQuality: FilterQuality.medium,
|
||||
errorBuilder: (_, _, _) => Icon(
|
||||
iconSlot!.icon,
|
||||
size: size * 0.5,
|
||||
color: readableAccent(accent, background, minContrast: 3),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
@@ -322,14 +395,24 @@ class AvatarCircle extends StatelessWidget {
|
||||
border: Border.all(color: accent.withValues(alpha: 0.4)),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: icon != null
|
||||
? Icon(icon, size: size * 0.5, color: accent)
|
||||
child: iconSlot != null
|
||||
? ThemedIcon(
|
||||
iconSlot!,
|
||||
size: size * 0.55,
|
||||
color: readableAccent(accent, background, minContrast: 3),
|
||||
)
|
||||
: icon != null
|
||||
? Icon(
|
||||
icon,
|
||||
size: size * 0.5,
|
||||
color: readableAccent(accent, background, minContrast: 3),
|
||||
)
|
||||
: Text(
|
||||
initials,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: size * 0.36,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: accent,
|
||||
color: readableAccent(accent, background),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user