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:
1 parent
a11f13af73
commit
2ca1ddc1b2
6 files changed
+266
-80
No files matched your search
@@ -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`) |
|
||||
| Own chat bubbles | `MeshBubbleTheme.of(context)` |
|
||||
| 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 |
|
||||
|
||||
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`.
|
||||
- **`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).
|
||||
- **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.
|
||||
- **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).
|
||||
- **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` 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`.
|
||||
- **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+.
|
||||
|
||||
@@ -1075,7 +1075,7 @@ class _ChannelMessagePathMapScreenState
|
||||
? l10n.channelPath_primaryPath(selectedIndex + 1)
|
||||
: l10n.channelPath_pathLabel(selectedIndex + 1);
|
||||
return Positioned(
|
||||
left: 16,
|
||||
left: pathMapTopOverlayInset(),
|
||||
right: 16,
|
||||
top: topOffset,
|
||||
child: SafeArea(
|
||||
@@ -1375,7 +1375,10 @@ class _ChannelMessagePathMapScreenState
|
||||
isImperial: isImperial,
|
||||
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,
|
||||
) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
if (hops.isEmpty) {
|
||||
return Center(child: Text(l10n.channelPath_noHopDetailsAvailable));
|
||||
}
|
||||
@@ -1459,7 +1463,7 @@ class _ChannelMessagePathMapScreenState
|
||||
color: index == highlightRow
|
||||
? highlightColor
|
||||
: isFocused
|
||||
? MeshPalette.blueBg
|
||||
? scheme.primary.withValues(alpha: 0.12)
|
||||
: Colors.transparent,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
@@ -1471,10 +1475,10 @@ class _ChannelMessagePathMapScreenState
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: MeshPalette.blueDim.withValues(alpha: 0.3),
|
||||
color: scheme.primary.withValues(alpha: 0.18),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: MeshPalette.blueDim.withValues(alpha: 0.5),
|
||||
color: scheme.primary.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
@@ -1482,8 +1486,8 @@ class _ChannelMessagePathMapScreenState
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
hop.index.toString(),
|
||||
style: const TextStyle(
|
||||
color: MeshPalette.ink,
|
||||
style: TextStyle(
|
||||
color: scheme.onSurface,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -1516,7 +1520,7 @@ class _ChannelMessagePathMapScreenState
|
||||
].join(' · '),
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: MeshPalette.ink3,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
@@ -1235,7 +1235,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_isLoading)
|
||||
CircularProgressIndicator(color: MeshPalette.blue),
|
||||
CircularProgressIndicator(color: scheme.primary),
|
||||
const SizedBox(height: 16),
|
||||
if (!_isLoading && _failed2Loaded)
|
||||
Text(
|
||||
@@ -1803,7 +1803,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
style: MeshTheme.mono(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
color: MeshPalette.ink,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
combined: combined,
|
||||
@@ -1880,6 +1880,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
itemCount: pathTraceData.pathData.length + 1,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final snrUi = snrUiFromSNR(
|
||||
index < pathTraceData.snrData.length
|
||||
? pathTraceData.snrData[index]
|
||||
@@ -1894,15 +1895,18 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
index >= pathTraceData.snrData.length / 2
|
||||
? Icons.call_received
|
||||
: Icons.call_made,
|
||||
color: MeshPalette.ink2,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
title: Text(
|
||||
formatDirectionText(pathTraceData, index),
|
||||
style: MeshTheme.mono(fontSize: 13, color: MeshPalette.ink),
|
||||
style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
|
||||
),
|
||||
subtitle: Text(
|
||||
formatDirectionSubText(pathTraceData, index),
|
||||
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3),
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
trailing: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -1943,6 +1947,7 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
itemCount: path.totalTransmissions,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
String title;
|
||||
String subtitle;
|
||||
Widget? trailing;
|
||||
@@ -2017,11 +2022,14 @@ class _PathTraceMapScreenState extends State<PathTraceMapScreen>
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: MeshTheme.mono(fontSize: 13, color: MeshPalette.ink),
|
||||
style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
|
||||
),
|
||||
subtitle: Text(
|
||||
subtitle,
|
||||
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3),
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
trailing: trailing,
|
||||
);
|
||||
|
||||
@@ -30,6 +30,16 @@ bool isDesktopMapPlatform([TargetPlatform? platform]) {
|
||||
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)
|
||||
/// or not a real fix (SELF_INFO reports 0,0 without GPS).
|
||||
LatLng? plausibleSelfPoint(MeshCoreConnector connector) {
|
||||
@@ -168,37 +178,38 @@ class PathMapDesktopControls extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Positioned(
|
||||
top: 16,
|
||||
left: 16,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: MeshPalette.bg1.withValues(alpha: 0.90),
|
||||
color: scheme.surfaceContainerLow.withValues(alpha: 0.94),
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
border: Border.all(color: MeshPalette.line2),
|
||||
border: Border.all(color: scheme.outlineVariant),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
child: IconTheme(
|
||||
data: const IconThemeData(color: MeshPalette.ink),
|
||||
data: IconThemeData(color: scheme.onSurface),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add),
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
tooltip: l10n.map_zoomIn,
|
||||
onPressed: onZoomIn,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.remove),
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
tooltip: l10n.map_zoomOut,
|
||||
onPressed: onZoomOut,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.my_location),
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
tooltip: l10n.map_centerMap,
|
||||
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
|
||||
/// multi-path summary, and the hop list.
|
||||
///
|
||||
/// Sets dark-panel text/icon/divider colours explicitly so content does not
|
||||
/// inherit light-theme colours.
|
||||
/// Uses the theme's card surface and sets text/icon/divider colours from the
|
||||
/// [ColorScheme] so the panel matches light, dark and custom themes.
|
||||
class PathMapBottomPanel extends StatelessWidget {
|
||||
final Widget header;
|
||||
final bool combined;
|
||||
@@ -334,6 +345,7 @@ class PathMapBottomPanel extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final maxHeight =
|
||||
MediaQuery.of(context).size.height * (combined ? 0.45 : 0.35);
|
||||
const hopRowHeight = 60.0;
|
||||
@@ -348,7 +360,7 @@ class PathMapBottomPanel extends StatelessWidget {
|
||||
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;
|
||||
|
||||
return Positioned(
|
||||
@@ -360,26 +372,26 @@ class PathMapBottomPanel extends StatelessWidget {
|
||||
height: cardHeight,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: MeshPalette.bg1.withValues(alpha: 0.96),
|
||||
color: scheme.surfaceContainerLow.withValues(alpha: 0.96),
|
||||
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||
border: Border.all(color: MeshPalette.line2),
|
||||
border: Border.all(color: scheme.outlineVariant),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: DefaultTextStyle.merge(
|
||||
style: const TextStyle(color: MeshPalette.ink),
|
||||
style: TextStyle(color: scheme.onSurface),
|
||||
child: IconTheme(
|
||||
data: const IconThemeData(color: MeshPalette.ink),
|
||||
data: IconThemeData(color: scheme.onSurface),
|
||||
child: DividerTheme(
|
||||
data: const DividerThemeData(color: MeshPalette.line),
|
||||
data: DividerThemeData(color: scheme.outlineVariant),
|
||||
child: ListTileTheme(
|
||||
data: const ListTileThemeData(
|
||||
iconColor: MeshPalette.ink2,
|
||||
textColor: MeshPalette.ink,
|
||||
data: ListTileThemeData(
|
||||
iconColor: scheme.onSurfaceVariant,
|
||||
textColor: scheme.onSurface,
|
||||
),
|
||||
child: TextButtonTheme(
|
||||
data: TextButtonThemeData(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: MeshPalette.ink,
|
||||
foregroundColor: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
@@ -445,7 +457,7 @@ class PathMapBottomPanel extends StatelessWidget {
|
||||
? Icons.close_fullscreen
|
||||
: Icons.open_in_full,
|
||||
),
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
tooltip: isExpanded
|
||||
? l10n.pathMap_showMap
|
||||
: l10n.pathMap_expandHopList,
|
||||
@@ -457,7 +469,7 @@ class PathMapBottomPanel extends StatelessWidget {
|
||||
? Icons.expand_less
|
||||
: Icons.expand_more,
|
||||
),
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
tooltip: collapsed
|
||||
? l10n.pathMap_expandPanel
|
||||
: l10n.pathMap_collapsePanel,
|
||||
@@ -489,10 +501,10 @@ class PathMapBottomPanel extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icon(
|
||||
Icons.gps_off,
|
||||
size: 16,
|
||||
color: MeshPalette.warn,
|
||||
color: scheme.tertiary,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../models/display_path.dart';
|
||||
import '../models/path_playback.dart';
|
||||
import '../theme/mesh_theme.dart';
|
||||
import 'mesh_ui.dart';
|
||||
import 'path_map_scaffold.dart';
|
||||
|
||||
/// Shared UI for the path map screens (live path trace and received-message
|
||||
/// path map): packet-flow animation overlays, single/combined view toggle,
|
||||
@@ -232,6 +233,7 @@ void showSharedNodeSheet(
|
||||
required ValueChanged<DisplayPath> onSelect,
|
||||
}) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (sheetContext) => SafeArea(
|
||||
@@ -246,7 +248,7 @@ void showSharedNodeSheet(
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -254,7 +256,7 @@ void showSharedNodeSheet(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
l10n.pathMap_sharedNodeCount(paths.length),
|
||||
style: TextStyle(fontSize: 12, color: MeshPalette.ink3),
|
||||
style: TextStyle(fontSize: 12, color: scheme.onSurfaceVariant),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -264,11 +266,14 @@ void showSharedNodeSheet(
|
||||
leading: _colorDot(path.color),
|
||||
title: Text(
|
||||
path.label,
|
||||
style: MeshTheme.mono(fontSize: 13, color: MeshPalette.ink),
|
||||
style: MeshTheme.mono(fontSize: 13, color: scheme.onSurface),
|
||||
),
|
||||
trailing: Text(
|
||||
l10n.pathMap_hopCount(path.totalTransmissions),
|
||||
style: MeshTheme.mono(fontSize: 12, color: MeshPalette.ink3),
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -302,33 +307,40 @@ class PathViewModeToggle extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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(
|
||||
top: 12,
|
||||
left: 0,
|
||||
right: 0,
|
||||
left: inset,
|
||||
right: inset,
|
||||
child: Center(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: MeshPalette.bg1.withValues(alpha: 0.92),
|
||||
borderRadius: BorderRadius.circular(MeshRadii.pill),
|
||||
),
|
||||
child: SegmentedButton<PathViewMode>(
|
||||
style: const ButtonStyle(
|
||||
visualDensity: VisualDensity(horizontal: -3, vertical: -3),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerLow.withValues(alpha: 0.94),
|
||||
borderRadius: BorderRadius.circular(MeshRadii.pill),
|
||||
),
|
||||
showSelectedIcon: false,
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: PathViewMode.single,
|
||||
label: MeshSegmentLabel(l10n.pathMap_viewSingle),
|
||||
child: SegmentedButton<PathViewMode>(
|
||||
style: const ButtonStyle(
|
||||
visualDensity: VisualDensity(horizontal: -3, vertical: -3),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: PathViewMode.combined,
|
||||
label: MeshSegmentLabel(l10n.pathMap_viewCombined),
|
||||
),
|
||||
],
|
||||
selected: {mode},
|
||||
onSelectionChanged: (selection) => onChanged(selection.first),
|
||||
showSelectedIcon: false,
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: PathViewMode.single,
|
||||
label: MeshSegmentLabel(l10n.pathMap_viewSingle),
|
||||
),
|
||||
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,
|
||||
builder: (context, _) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final enabled = animationEnabled && playback.hasPath;
|
||||
final path = selected;
|
||||
String? hopLabel;
|
||||
@@ -408,8 +421,8 @@ class PathAnimationControls extends StatelessWidget {
|
||||
? l10n.pathMap_animationOff
|
||||
: l10n.pathMap_animationOn,
|
||||
color: animationEnabled
|
||||
? MeshPalette.blue
|
||||
: MeshPalette.ink4,
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
onPressed: onToggleAnimation,
|
||||
),
|
||||
controlButton(
|
||||
@@ -441,7 +454,7 @@ class PathAnimationControls extends StatelessWidget {
|
||||
tooltip: followEnabled
|
||||
? l10n.pathMap_unfollowPacket
|
||||
: l10n.pathMap_followPacket,
|
||||
color: followEnabled ? MeshPalette.blue : null,
|
||||
color: followEnabled ? scheme.primary : null,
|
||||
onPressed: enabled ? onToggleFollow : null,
|
||||
),
|
||||
TextButton(
|
||||
@@ -468,7 +481,7 @@ class PathAnimationControls extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12,
|
||||
color: MeshPalette.ink2,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -494,16 +507,14 @@ class PathMiniLegend extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
Widget item(Widget swatch, String text) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
swatch,
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(fontSize: 12, color: MeshPalette.ink3),
|
||||
),
|
||||
child: Text(text, style: TextStyle(fontSize: 12, color: muted)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -515,7 +526,7 @@ class PathMiniLegend extends StatelessWidget {
|
||||
width: 5,
|
||||
height: 3,
|
||||
margin: const EdgeInsets.only(right: 2),
|
||||
color: MeshPalette.ink3,
|
||||
color: muted,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -571,6 +582,7 @@ class PathSummaryList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -580,7 +592,10 @@ class PathSummaryList extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
l10n.pathMap_observedPaths(paths.length),
|
||||
style: MeshTheme.accentLabel(color: MeshPalette.ink3),
|
||||
style: MeshTheme.accentLabel(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
if (hiddenIds.isNotEmpty)
|
||||
@@ -607,6 +622,7 @@ class PathSummaryList extends StatelessWidget {
|
||||
|
||||
Widget _buildRow(BuildContext context, DisplayPath path) {
|
||||
final l10n = context.l10n;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final isSelected = path.id == selectedId;
|
||||
final hidden = hiddenIds.contains(path.id);
|
||||
final timestamp = path.record?.timestamp;
|
||||
@@ -622,7 +638,9 @@ class PathSummaryList extends StatelessWidget {
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 1),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? MeshPalette.bg3 : Colors.transparent,
|
||||
color: isSelected
|
||||
? scheme.surfaceContainerHighest
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(MeshRadii.sm),
|
||||
),
|
||||
child: Row(
|
||||
@@ -641,7 +659,7 @@ class PathSummaryList extends StatelessWidget {
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w700
|
||||
: FontWeight.w500,
|
||||
color: MeshPalette.ink,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -655,7 +673,10 @@ class PathSummaryList extends StatelessWidget {
|
||||
parts.join(' · '),
|
||||
maxLines: 1,
|
||||
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(
|
||||
hidden ? Icons.visibility_off : Icons.visibility,
|
||||
size: 20,
|
||||
color: hidden ? MeshPalette.ink4 : MeshPalette.ink3,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
tooltip: hidden ? l10n.pathMap_showPath : l10n.pathMap_hidePath,
|
||||
padding: EdgeInsets.zero,
|
||||
|
||||
@@ -1,8 +1,41 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/l10n/app_localizations.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_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() {
|
||||
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;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user