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

@@ -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;
});
}