Path map: theme the panels and keep overlays clear of zoom buttons

- Bottom panel, zoom buttons, toggle and panel contents use ColorScheme roles
- On desktop, the observed-path selector and view toggle start past the
  zoom controls
This commit is contained in:
zjs81 committed 2026-11-22 18:09:17 -07:00
1 parent a11f13af73
commit 2ca1ddc1b2
6 files changed
+266 -80

No files matched your search

+3 -2
View File
@@ -29,6 +29,7 @@ The source of truth is `lib/theme/mesh_theme.dart` (theme), `lib/widgets/mesh_ui
| Good / bad signal | `MeshTheme.snrColor(snr, blocked:)`; `MeshPalette.signal`, `.warn`, `.alert` for status ramps (e.g. battery in `repeater_status_screen.dart`) | | Good / bad signal | `MeshTheme.snrColor(snr, blocked:)`; `MeshPalette.signal`, `.warn`, `.alert` for status ramps (e.g. battery in `repeater_status_screen.dart`) |
| Own chat bubbles | `MeshBubbleTheme.of(context)` | | Own chat bubbles | `MeshBubbleTheme.of(context)` |
| Map overlays and markers | `MapPalette`, `MeshMapTheme.of(context)`; line-of-sight charts use `LosPalette` | | Map overlays and markers | `MapPalette`, `MeshMapTheme.of(context)`; line-of-sight charts use `LosPalette` |
| Floating map chrome (zoom buttons, panels, toggles) | `ColorScheme` roles like a card: `surfaceContainerLow`, `outlineVariant`, `onSurface`. On desktop, overlays at the top of a path map start at `pathMapTopOverlayInset()` (`path_map_scaffold.dart`) so they clear the zoom buttons |
| Coloured text or icon on a tinted background | pass it through `readableAccent(color, background, minContrast:)` (`mesh_ui.dart`), 4.5 for text, 3 for icons | | Coloured text or icon on a tinted background | pass it through `readableAccent(color, background, minContrast:)` (`mesh_ui.dart`), 4.5 for text, 3 for icons |
Rules: Rules:
@@ -304,8 +305,8 @@ The current code does not yet follow this page everywhere:
- **Settings toggles in two sizes.** `FeatureToggleRow` (`widgets/elements_ui.dart`, used in `settings_screen.dart` dialogs) uses a `bodyMedium` w600 title and `bodySmall` subtitle with a 32px refresh button. `MeshNavTile` and themed `SwitchListTile`s use `bodyLarge` w600 / `bodyMedium`. Only App Settings, Message Filter and Repeater Settings wrap their body in `MeshSettingsTileTheme`. - **Settings toggles in two sizes.** `FeatureToggleRow` (`widgets/elements_ui.dart`, used in `settings_screen.dart` dialogs) uses a `bodyMedium` w600 title and `bodySmall` subtitle with a 32px refresh button. `MeshNavTile` and themed `SwitchListTile`s use `bodyLarge` w600 / `bodyMedium`. Only App Settings, Message Filter and Repeater Settings wrap their body in `MeshSettingsTileTheme`.
- **`ErrorRetryCard` is unused** and its fallback label is the hard-coded English `'Retry'` (`mesh_ui.dart`); screens show load errors in their own ways. - **`ErrorRetryCard` is unused** and its fallback label is the hard-coded English `'Retry'` (`mesh_ui.dart`); screens show load errors in their own ways.
- **Fixed-width label boxes.** `chat_screen.dart` `_buildInfoRow` (80px), `line_of_sight_map_screen.dart` endpoint label (54px, `fontSize: 12`), `channel_message_path_screen.dart` (72px, upper-cased `accentLabel` at its 11px default). - **Fixed-width label boxes.** `chat_screen.dart` `_buildInfoRow` (80px), `line_of_sight_map_screen.dart` endpoint label (54px, `fontSize: 12`), `channel_message_path_screen.dart` (72px, upper-cased `accentLabel` at its 11px default).
- **11px text.** `MeshTheme.accentLabel()` without `fontSize` gives 11px in `channel_message_path_screen.dart` and `widgets/path_map_ui.dart` (which also uses dark-only `MeshPalette.ink3`). The type scale's `labelSmall` (11) is used in `list_filter_widget.dart` section titles. - **11px text.** `MeshTheme.accentLabel()` without `fontSize` gives 11px in `channel_message_path_screen.dart`. The type scale's `labelSmall` (11) is used in `list_filter_widget.dart` section titles.
- **Hard-coded colours.** `SyncProgressAppBarBottom` uses `Colors.red`, `Colors.blue` and `Colors.green`; `AppBarTitle` subtitle uses `Colors.grey[600]` at a literal 14 instead of `onSurfaceVariant`; `telemetry_location_map.dart` uses raw `Colors.*`. `MeshPalette.ink/bg/line` appear directly in eight screen/widget files (mostly map panels, where they are intentional; also `channels_screen.dart` and `channel_chat_screen.dart` community dots with an 8px icon). - **Hard-coded colours.** `SyncProgressAppBarBottom` uses `Colors.red`, `Colors.blue` and `Colors.green`; `AppBarTitle` subtitle uses `Colors.grey[600]` at a literal 14 instead of `onSurfaceVariant`; `telemetry_location_map.dart` uses raw `Colors.*`. `MeshPalette.ink/bg/line` still appear directly in a few screen/widget files: map marker overlays (node name labels and shared-count badges in `path_map_scaffold.dart`, the hop badge on avatars in `channel_message_path_screen.dart`) and the `channels_screen.dart` and `channel_chat_screen.dart` community dots with an 8px icon. The path map chrome (`PathMapBottomPanel`, `PathMapDesktopControls`, `PathViewModeToggle` and the panel contents in `path_map_ui.dart` and both path map screens) uses `ColorScheme` roles: `surfaceContainerLow` background, `outlineVariant` border and dividers, `onSurface`/`onSurfaceVariant` text and icons, `primary` for active toggles and `tertiary` for warnings.
- **Literal sizes instead of the theme.** About 300 literal `fontSize:` values in `lib/screens` and `lib/widgets` (most 12–14), e.g. `EmptyState` subtitle at 13.5; and 36 `BorderRadius.circular(<number>)` calls (8 and 12 most common) instead of `MeshRadii`. - **Literal sizes instead of the theme.** About 300 literal `fontSize:` values in `lib/screens` and `lib/widgets` (most 12–14), e.g. `EmptyState` subtitle at 13.5; and 36 `BorderRadius.circular(<number>)` calls (8 and 12 most common) instead of `MeshRadii`.
- **Navigation bar theme.** `navigationBarTheme` colours selected labels `onPrimary`, which is white-on-white in light mode; `QuickSwitchBar` overrides it. Any other `NavigationBar` would inherit the problem. - **Navigation bar theme.** `navigationBarTheme` colours selected labels `onPrimary`, which is white-on-white in light mode; `QuickSwitchBar` overrides it. Any other `NavigationBar` would inherit the problem.
- **Two badge styles.** `QuickSwitchBar` uses Material `Badge` capped at 99+; `UnreadBadge` caps at 9999+. - **Two badge styles.** `QuickSwitchBar` uses Material `Badge` capped at 99+; `UnreadBadge` caps at 9999+.
+12 -8
View File
@@ -1075,7 +1075,7 @@ class _ChannelMessagePathMapScreenState
? l10n.channelPath_primaryPath(selectedIndex + 1) ? l10n.channelPath_primaryPath(selectedIndex + 1)
: l10n.channelPath_pathLabel(selectedIndex + 1); : l10n.channelPath_pathLabel(selectedIndex + 1);
return Positioned( return Positioned(
left: 16, left: pathMapTopOverlayInset(),
right: 16, right: 16,
top: topOffset, top: topOffset,
child: SafeArea( child: SafeArea(
@@ -1375,7 +1375,10 @@ class _ChannelMessagePathMapScreenState
isImperial: isImperial, isImperial: isImperial,
l10n: l10n, l10n: l10n,
), ),
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink2), style: MeshTheme.mono(
fontSize: 12,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
), ),
], ],
), ),
@@ -1430,6 +1433,7 @@ class _ChannelMessagePathMapScreenState
Map<int, int> hopUseCount, Map<int, int> hopUseCount,
) { ) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
if (hops.isEmpty) { if (hops.isEmpty) {
return Center(child: Text(l10n.channelPath_noHopDetailsAvailable)); return Center(child: Text(l10n.channelPath_noHopDetailsAvailable));
} }
@@ -1459,7 +1463,7 @@ class _ChannelMessagePathMapScreenState
color: index == highlightRow color: index == highlightRow
? highlightColor ? highlightColor
: isFocused : isFocused
? MeshPalette.blueBg ? scheme.primary.withValues(alpha: 0.12)
: Colors.transparent, : Colors.transparent,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 12, horizontal: 12,
@@ -1471,10 +1475,10 @@ class _ChannelMessagePathMapScreenState
width: 30, width: 30,
height: 30, height: 30,
decoration: BoxDecoration( decoration: BoxDecoration(
color: MeshPalette.blueDim.withValues(alpha: 0.3), color: scheme.primary.withValues(alpha: 0.18),
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all( border: Border.all(
color: MeshPalette.blueDim.withValues(alpha: 0.5), color: scheme.primary.withValues(alpha: 0.5),
), ),
), ),
alignment: Alignment.center, alignment: Alignment.center,
@@ -1482,8 +1486,8 @@ class _ChannelMessagePathMapScreenState
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
child: Text( child: Text(
hop.index.toString(), hop.index.toString(),
style: const TextStyle( style: TextStyle(
color: MeshPalette.ink, color: scheme.onSurface,
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
), ),
@@ -1516,7 +1520,7 @@ class _ChannelMessagePathMapScreenState
].join(' · '), ].join(' · '),
style: MeshTheme.mono( style: MeshTheme.mono(
fontSize: 12, fontSize: 12,
color: MeshPalette.ink3, color: scheme.onSurfaceVariant,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
+15 -7
View File
@@ -1235,7 +1235,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (_isLoading) if (_isLoading)
CircularProgressIndicator(color: MeshPalette.blue), CircularProgressIndicator(color: scheme.primary),
const SizedBox(height: 16), const SizedBox(height: 16),
if (!_isLoading && _failed2Loaded) if (!_isLoading && _failed2Loaded)
Text( Text(
@@ -1803,7 +1803,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
style: MeshTheme.mono( style: MeshTheme.mono(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 13, fontSize: 13,
color: MeshPalette.ink, color: Theme.of(context).colorScheme.onSurface,
), ),
), ),
combined: combined, combined: combined,
@@ -1880,6 +1880,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
itemCount: pathTraceData.pathData.length + 1, itemCount: pathTraceData.pathData.length + 1,
separatorBuilder: (_, _) => const Divider(height: 1), separatorBuilder: (_, _) => const Divider(height: 1),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final scheme = Theme.of(context).colorScheme;
final snrUi = snrUiFromSNR( final snrUi = snrUiFromSNR(
index < pathTraceData.snrData.length index < pathTraceData.snrData.length
? pathTraceData.snrData[index] ? pathTraceData.snrData[index]
@@ -1894,15 +1895,18 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
index >= pathTraceData.snrData.length / 2 index >= pathTraceData.snrData.length / 2
? Icons.call_received ? Icons.call_received
: Icons.call_made, : Icons.call_made,
color: MeshPalette.ink2, color: scheme.onSurfaceVariant,
), ),
title: Text( title: Text(
formatDirectionText(pathTraceData, index), formatDirectionText(pathTraceData, index),
style: MeshTheme.mono(fontSize: 13, color: MeshPalette.ink), style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
), ),
subtitle: Text( subtitle: Text(
formatDirectionSubText(pathTraceData, index), formatDirectionSubText(pathTraceData, index),
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3), style: MeshTheme.mono(
fontSize: 12,
color: scheme.onSurfaceVariant,
),
), ),
trailing: Column( trailing: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -1943,6 +1947,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
itemCount: path.totalTransmissions, itemCount: path.totalTransmissions,
separatorBuilder: (_, _) => const Divider(height: 1), separatorBuilder: (_, _) => const Divider(height: 1),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final scheme = Theme.of(context).colorScheme;
String title; String title;
String subtitle; String subtitle;
Widget? trailing; Widget? trailing;
@@ -2017,11 +2022,14 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
), ),
title: Text( title: Text(
title, title,
style: MeshTheme.mono(fontSize: 13, color: MeshPalette.ink), style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
), ),
subtitle: Text( subtitle: Text(
subtitle, subtitle,
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3), style: MeshTheme.mono(
fontSize: 12,
color: scheme.onSurfaceVariant,
),
), ),
trailing: trailing, trailing: trailing,
); );
+35 -23
View File
@@ -30,6 +30,16 @@ bool isDesktopMapPlatform([TargetPlatform? platform]) {
p == TargetPlatform.macOS; p == TargetPlatform.macOS;
} }
/// Left edge of the [PathMapDesktopControls] column plus its 48px buttons
/// and a gap; overlays at the top of the map start here on desktop so they
/// don't cover the zoom buttons.
const double kPathMapDesktopControlsInset = 16 + 48 + 8;
/// Horizontal inset for overlays stacked at the top of a path map: clears
/// the desktop zoom controls, otherwise the usual 16px margin.
double pathMapTopOverlayInset([TargetPlatform? platform]) =>
isDesktopMapPlatform(platform) ? kPathMapDesktopControlsInset : 16;
/// The connected radio's position, or null when it is unknown (disconnected) /// The connected radio's position, or null when it is unknown (disconnected)
/// or not a real fix (SELF_INFO reports 0,0 without GPS). /// or not a real fix (SELF_INFO reports 0,0 without GPS).
LatLng? plausibleSelfPoint(MeshCoreConnector connector) { LatLng? plausibleSelfPoint(MeshCoreConnector connector) {
@@ -168,37 +178,38 @@ class PathMapDesktopControls extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
return Positioned( return Positioned(
top: 16, top: 16,
left: 16, left: 16,
child: DecoratedBox( child: DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
color: MeshPalette.bg1.withValues(alpha: 0.90), color: scheme.surfaceContainerLow.withValues(alpha: 0.94),
borderRadius: BorderRadius.circular(MeshRadii.md), borderRadius: BorderRadius.circular(MeshRadii.md),
border: Border.all(color: MeshPalette.line2), border: Border.all(color: scheme.outlineVariant),
), ),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(MeshRadii.md), borderRadius: BorderRadius.circular(MeshRadii.md),
child: IconTheme( child: IconTheme(
data: const IconThemeData(color: MeshPalette.ink), data: IconThemeData(color: scheme.onSurface),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
IconButton( IconButton(
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
color: MeshPalette.ink, color: scheme.onSurface,
tooltip: l10n.map_zoomIn, tooltip: l10n.map_zoomIn,
onPressed: onZoomIn, onPressed: onZoomIn,
), ),
IconButton( IconButton(
icon: const Icon(Icons.remove), icon: const Icon(Icons.remove),
color: MeshPalette.ink, color: scheme.onSurface,
tooltip: l10n.map_zoomOut, tooltip: l10n.map_zoomOut,
onPressed: onZoomOut, onPressed: onZoomOut,
), ),
IconButton( IconButton(
icon: const Icon(Icons.my_location), icon: const Icon(Icons.my_location),
color: MeshPalette.ink, color: scheme.onSurface,
tooltip: l10n.map_centerMap, tooltip: l10n.map_centerMap,
onPressed: onReset, onPressed: onReset,
), ),
@@ -280,12 +291,12 @@ class PathSharedCountBadge extends StatelessWidget {
} }
} }
/// Dark, collapsible bottom panel shared by the path map screens: header /// Collapsible bottom panel shared by the path map screens: header
/// with distance and legend, playback controls, warnings, optional /// with distance and legend, playback controls, warnings, optional
/// multi-path summary, and the hop list. /// multi-path summary, and the hop list.
/// ///
/// Sets dark-panel text/icon/divider colours explicitly so content does not /// Uses the theme's card surface and sets text/icon/divider colours from the
/// inherit light-theme colours. /// [ColorScheme] so the panel matches light, dark and custom themes.
class PathMapBottomPanel extends StatelessWidget { class PathMapBottomPanel extends StatelessWidget {
final Widget header; final Widget header;
final bool combined; final bool combined;
@@ -334,6 +345,7 @@ class PathMapBottomPanel extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final maxHeight = final maxHeight =
MediaQuery.of(context).size.height * (combined ? 0.45 : 0.35); MediaQuery.of(context).size.height * (combined ? 0.45 : 0.35);
const hopRowHeight = 60.0; const hopRowHeight = 60.0;
@@ -348,7 +360,7 @@ class PathMapBottomPanel extends StatelessWidget {
cardHeight = max(196.0, min(maxHeight, estimatedHeight)); cardHeight = max(196.0, min(maxHeight, estimatedHeight));
} }
final warnStyle = const TextStyle(fontSize: 12, color: MeshPalette.warn); final warnStyle = TextStyle(fontSize: 12, color: scheme.tertiary);
final unresolved = selected?.unresolvedHops ?? 0; final unresolved = selected?.unresolvedHops ?? 0;
return Positioned( return Positioned(
@@ -360,26 +372,26 @@ class PathMapBottomPanel extends StatelessWidget {
height: cardHeight, height: cardHeight,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: MeshPalette.bg1.withValues(alpha: 0.96), color: scheme.surfaceContainerLow.withValues(alpha: 0.96),
borderRadius: BorderRadius.circular(MeshRadii.md), borderRadius: BorderRadius.circular(MeshRadii.md),
border: Border.all(color: MeshPalette.line2), border: Border.all(color: scheme.outlineVariant),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: DefaultTextStyle.merge( child: DefaultTextStyle.merge(
style: const TextStyle(color: MeshPalette.ink), style: TextStyle(color: scheme.onSurface),
child: IconTheme( child: IconTheme(
data: const IconThemeData(color: MeshPalette.ink), data: IconThemeData(color: scheme.onSurface),
child: DividerTheme( child: DividerTheme(
data: const DividerThemeData(color: MeshPalette.line), data: DividerThemeData(color: scheme.outlineVariant),
child: ListTileTheme( child: ListTileTheme(
data: const ListTileThemeData( data: ListTileThemeData(
iconColor: MeshPalette.ink2, iconColor: scheme.onSurfaceVariant,
textColor: MeshPalette.ink, textColor: scheme.onSurface,
), ),
child: TextButtonTheme( child: TextButtonTheme(
data: TextButtonThemeData( data: TextButtonThemeData(
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: MeshPalette.ink, foregroundColor: scheme.onSurface,
), ),
), ),
child: LayoutBuilder( child: LayoutBuilder(
@@ -445,7 +457,7 @@ class PathMapBottomPanel extends StatelessWidget {
? Icons.close_fullscreen ? Icons.close_fullscreen
: Icons.open_in_full, : Icons.open_in_full,
), ),
color: MeshPalette.ink, color: scheme.onSurface,
tooltip: isExpanded tooltip: isExpanded
? l10n.pathMap_showMap ? l10n.pathMap_showMap
: l10n.pathMap_expandHopList, : l10n.pathMap_expandHopList,
@@ -457,7 +469,7 @@ class PathMapBottomPanel extends StatelessWidget {
? Icons.expand_less ? Icons.expand_less
: Icons.expand_more, : Icons.expand_more,
), ),
color: MeshPalette.ink, color: scheme.onSurface,
tooltip: collapsed tooltip: collapsed
? l10n.pathMap_expandPanel ? l10n.pathMap_expandPanel
: l10n.pathMap_collapsePanel, : l10n.pathMap_collapsePanel,
@@ -489,10 +501,10 @@ class PathMapBottomPanel extends StatelessWidget {
), ),
child: Row( child: Row(
children: [ children: [
const Icon( Icon(
Icons.gps_off, Icons.gps_off,
size: 16, size: 16,
color: MeshPalette.warn, color: scheme.tertiary,
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
Expanded( Expanded(
+61 -40
View File
@@ -8,6 +8,7 @@ import '../models/display_path.dart';
import '../models/path_playback.dart'; import '../models/path_playback.dart';
import '../theme/mesh_theme.dart'; import '../theme/mesh_theme.dart';
import 'mesh_ui.dart'; import 'mesh_ui.dart';
import 'path_map_scaffold.dart';
/// Shared UI for the path map screens (live path trace and received-message /// Shared UI for the path map screens (live path trace and received-message
/// path map): packet-flow animation overlays, single/combined view toggle, /// path map): packet-flow animation overlays, single/combined view toggle,
@@ -232,6 +233,7 @@ void showSharedNodeSheet(
required ValueChanged<DisplayPath> onSelect, required ValueChanged<DisplayPath> onSelect,
}) { }) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (sheetContext) => SafeArea( builder: (sheetContext) => SafeArea(
@@ -246,7 +248,7 @@ void showSharedNodeSheet(
style: MeshTheme.mono( style: MeshTheme.mono(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: MeshPalette.ink, color: scheme.onSurface,
), ),
), ),
), ),
@@ -254,7 +256,7 @@ void showSharedNodeSheet(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text( child: Text(
l10n.pathMap_sharedNodeCount(paths.length), l10n.pathMap_sharedNodeCount(paths.length),
style: TextStyle(fontSize: 12, color: MeshPalette.ink3), style: TextStyle(fontSize: 12, color: scheme.onSurfaceVariant),
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@@ -264,11 +266,14 @@ void showSharedNodeSheet(
leading: _colorDot(path.color), leading: _colorDot(path.color),
title: Text( title: Text(
path.label, path.label,
style: MeshTheme.mono(fontSize: 13, color: MeshPalette.ink), style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
), ),
trailing: Text( trailing: Text(
l10n.pathMap_hopCount(path.totalTransmissions), l10n.pathMap_hopCount(path.totalTransmissions),
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3), style: MeshTheme.mono(
fontSize: 12,
color: scheme.onSurfaceVariant,
),
), ),
onTap: () { onTap: () {
Navigator.pop(sheetContext); Navigator.pop(sheetContext);
@@ -302,33 +307,40 @@ class PathViewModeToggle extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
// Symmetric insets keep the toggle centred while clearing the desktop
// zoom controls in the top-left corner.
final inset = isDesktopMapPlatform() ? kPathMapDesktopControlsInset : 0.0;
return Positioned( return Positioned(
top: 12, top: 12,
left: 0, left: inset,
right: 0, right: inset,
child: Center( child: Center(
child: DecoratedBox( child: FittedBox(
decoration: BoxDecoration( fit: BoxFit.scaleDown,
color: MeshPalette.bg1.withValues(alpha: 0.92), child: DecoratedBox(
borderRadius: BorderRadius.circular(MeshRadii.pill), decoration: BoxDecoration(
), color: scheme.surfaceContainerLow.withValues(alpha: 0.94),
child: SegmentedButton<PathViewMode>( borderRadius: BorderRadius.circular(MeshRadii.pill),
style: const ButtonStyle(
visualDensity: VisualDensity(horizontal: -3, vertical: -3),
), ),
showSelectedIcon: false, child: SegmentedButton<PathViewMode>(
segments: [ style: const ButtonStyle(
ButtonSegment( visualDensity: VisualDensity(horizontal: -3, vertical: -3),
value: PathViewMode.single,
label: MeshSegmentLabel(l10n.pathMap_viewSingle),
), ),
ButtonSegment( showSelectedIcon: false,
value: PathViewMode.combined, segments: [
label: MeshSegmentLabel(l10n.pathMap_viewCombined), ButtonSegment(
), value: PathViewMode.single,
], label: MeshSegmentLabel(l10n.pathMap_viewSingle),
selected: {mode}, ),
onSelectionChanged: (selection) => onChanged(selection.first), ButtonSegment(
value: PathViewMode.combined,
label: MeshSegmentLabel(l10n.pathMap_viewCombined),
),
],
selected: {mode},
onSelectionChanged: (selection) => onChanged(selection.first),
),
), ),
), ),
), ),
@@ -363,6 +375,7 @@ class PathAnimationControls extends StatelessWidget {
animation: playback, animation: playback,
builder: (context, _) { builder: (context, _) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final enabled = animationEnabled && playback.hasPath; final enabled = animationEnabled && playback.hasPath;
final path = selected; final path = selected;
String? hopLabel; String? hopLabel;
@@ -408,8 +421,8 @@ class PathAnimationControls extends StatelessWidget {
? l10n.pathMap_animationOff ? l10n.pathMap_animationOff
: l10n.pathMap_animationOn, : l10n.pathMap_animationOn,
color: animationEnabled color: animationEnabled
? MeshPalette.blue ? scheme.primary
: MeshPalette.ink4, : scheme.onSurfaceVariant,
onPressed: onToggleAnimation, onPressed: onToggleAnimation,
), ),
controlButton( controlButton(
@@ -441,7 +454,7 @@ class PathAnimationControls extends StatelessWidget {
tooltip: followEnabled tooltip: followEnabled
? l10n.pathMap_unfollowPacket ? l10n.pathMap_unfollowPacket
: l10n.pathMap_followPacket, : l10n.pathMap_followPacket,
color: followEnabled ? MeshPalette.blue : null, color: followEnabled ? scheme.primary : null,
onPressed: enabled ? onToggleFollow : null, onPressed: enabled ? onToggleFollow : null,
), ),
TextButton( TextButton(
@@ -468,7 +481,7 @@ class PathAnimationControls extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: MeshTheme.mono( style: MeshTheme.mono(
fontSize: 12, fontSize: 12,
color: MeshPalette.ink2, color: scheme.onSurfaceVariant,
), ),
), ),
), ),
@@ -494,16 +507,14 @@ class PathMiniLegend extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
Widget item(Widget swatch, String text) => Row( Widget item(Widget swatch, String text) => Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
swatch, swatch,
const SizedBox(width: 4), const SizedBox(width: 4),
Flexible( Flexible(
child: Text( child: Text(text, style: TextStyle(fontSize: 12, color: muted)),
text,
style: TextStyle(fontSize: 12, color: MeshPalette.ink3),
),
), ),
], ],
); );
@@ -515,7 +526,7 @@ class PathMiniLegend extends StatelessWidget {
width: 5, width: 5,
height: 3, height: 3,
margin: const EdgeInsets.only(right: 2), margin: const EdgeInsets.only(right: 2),
color: MeshPalette.ink3, color: muted,
), ),
], ],
); );
@@ -571,6 +582,7 @@ class PathSummaryList extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -580,7 +592,10 @@ class PathSummaryList extends StatelessWidget {
children: [ children: [
Text( Text(
l10n.pathMap_observedPaths(paths.length), l10n.pathMap_observedPaths(paths.length),
style: MeshTheme.accentLabel(color: MeshPalette.ink3), style: MeshTheme.accentLabel(
color: scheme.onSurfaceVariant,
fontSize: 12,
),
), ),
const Spacer(), const Spacer(),
if (hiddenIds.isNotEmpty) if (hiddenIds.isNotEmpty)
@@ -607,6 +622,7 @@ class PathSummaryList extends StatelessWidget {
Widget _buildRow(BuildContext context, DisplayPath path) { Widget _buildRow(BuildContext context, DisplayPath path) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final isSelected = path.id == selectedId; final isSelected = path.id == selectedId;
final hidden = hiddenIds.contains(path.id); final hidden = hiddenIds.contains(path.id);
final timestamp = path.record?.timestamp; final timestamp = path.record?.timestamp;
@@ -622,7 +638,9 @@ class PathSummaryList extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 1), margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 1),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2), padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? MeshPalette.bg3 : Colors.transparent, color: isSelected
? scheme.surfaceContainerHighest
: Colors.transparent,
borderRadius: BorderRadius.circular(MeshRadii.sm), borderRadius: BorderRadius.circular(MeshRadii.sm),
), ),
child: Row( child: Row(
@@ -641,7 +659,7 @@ class PathSummaryList extends StatelessWidget {
fontWeight: isSelected fontWeight: isSelected
? FontWeight.w700 ? FontWeight.w700
: FontWeight.w500, : FontWeight.w500,
color: MeshPalette.ink, color: scheme.onSurface,
), ),
), ),
], ],
@@ -655,7 +673,10 @@ class PathSummaryList extends StatelessWidget {
parts.join(' · '), parts.join(' · '),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3), style: MeshTheme.mono(
fontSize: 12,
color: scheme.onSurfaceVariant,
),
), ),
), ),
), ),
@@ -663,7 +684,7 @@ class PathSummaryList extends StatelessWidget {
icon: Icon( icon: Icon(
hidden ? Icons.visibility_off : Icons.visibility, hidden ? Icons.visibility_off : Icons.visibility,
size: 20, size: 20,
color: hidden ? MeshPalette.ink4 : MeshPalette.ink3, color: scheme.onSurfaceVariant,
), ),
tooltip: hidden ? l10n.pathMap_showPath : l10n.pathMap_hidePath, tooltip: hidden ? l10n.pathMap_showPath : l10n.pathMap_hidePath,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@@ -1,8 +1,41 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/l10n/app_localizations.dart'; import 'package:meshcore_open/l10n/app_localizations.dart';
import 'package:meshcore_open/models/path_playback.dart'; import 'package:meshcore_open/models/path_playback.dart';
import 'package:meshcore_open/theme/mesh_theme.dart';
import 'package:meshcore_open/widgets/path_map_scaffold.dart'; import 'package:meshcore_open/widgets/path_map_scaffold.dart';
import 'package:meshcore_open/widgets/path_map_ui.dart';
Widget _panel(PathPlaybackController playback) => PathMapBottomPanel(
header: const Text('3 hops (2.00 km)'),
combined: false,
showInferredLegend: true,
collapsed: false,
onToggleCollapsed: () {},
playback: playback,
selected: null,
animationEnabled: true,
onToggleAnimation: () {},
followEnabled: false,
onToggleFollow: () {},
showNoSelfGpsNote: false,
pathCount: 1,
hopRowCount: 1,
summary: null,
hopList: const SizedBox.shrink(),
);
BoxDecoration _boxDecorationAbove(WidgetTester tester, Finder finder) {
return tester
.widget<DecoratedBox>(
find
.ancestor(of: finder, matching: find.byType(DecoratedBox))
.first,
)
.decoration
as BoxDecoration;
}
void main() { void main() {
for (final scenario in [ for (final scenario in [
@@ -141,4 +174,111 @@ void main() {
}, },
); );
} }
for (final theme in [
(name: 'light', data: MeshTheme.light()),
(name: 'dark', data: MeshTheme.dark()),
]) {
testWidgets('map chrome follows the ${theme.name} theme', (tester) async {
final playback = PathPlaybackController(const TestVSync());
addTearDown(playback.dispose);
final scheme = theme.data.colorScheme;
await tester.pumpWidget(
MaterialApp(
theme: theme.data,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Stack(
children: [
PathMapDesktopControls(
onZoomIn: () {},
onZoomOut: () {},
onReset: () {},
),
_panel(playback),
],
),
),
),
);
final panelBox = tester.widget<Container>(
find
.descendant(
of: find.byType(PathMapBottomPanel),
matching: find.byType(Container),
)
.first,
);
final panelDecoration = panelBox.decoration! as BoxDecoration;
expect(
panelDecoration.color,
scheme.surfaceContainerLow.withValues(alpha: 0.96),
);
expect(panelDecoration.border, Border.all(color: scheme.outlineVariant));
final controlsDecoration = _boxDecorationAbove(
tester,
find.widgetWithIcon(IconButton, Icons.add),
);
expect(
controlsDecoration.color,
scheme.surfaceContainerLow.withValues(alpha: 0.94),
);
final zoomIn = tester.widget<IconButton>(
find.widgetWithIcon(IconButton, Icons.add),
);
expect(zoomIn.color, scheme.onSurface);
});
}
testWidgets('top overlays clear the desktop zoom controls', (tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
addTearDown(() => debugDefaultTargetPlatformOverride = null);
tester.view.physicalSize = const Size(320, 640);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
const selectorKey = ValueKey('selector');
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Stack(
children: [
PathMapDesktopControls(
onZoomIn: () {},
onZoomOut: () {},
onReset: () {},
),
PathViewModeToggle(mode: PathViewMode.single, onChanged: (_) {}),
Positioned(
left: pathMapTopOverlayInset(),
right: 16,
top: 60,
child: const SizedBox(key: selectorKey, height: 120),
),
],
),
),
),
);
expect(tester.takeException(), isNull);
final controls = tester
.getRect(find.widgetWithIcon(IconButton, Icons.add))
.expandToInclude(
tester.getRect(find.widgetWithIcon(IconButton, Icons.my_location)),
);
final toggle = tester.getRect(find.byType(SegmentedButton<PathViewMode>));
final selector = tester.getRect(find.byKey(selectorKey));
expect(controls.overlaps(toggle), isFalse);
expect(controls.overlaps(selector), isFalse);
expect(pathMapTopOverlayInset(TargetPlatform.android), 16);
debugDefaultTargetPlatformOverride = null;
});
} }