feat(train): a workout's page as Strava's, maps readable and in the app's language, routes opening near the person (ADR 0030, D63)
- A workout with a track: its map to the foot of the screen under a sheet with its name; once the sheet settles, the map fits the track anew, eased, into what is left free; pulled up, the round buttons over the map fold into an app bar whose chevron lowers the sheet again. From expanded windows on, the map beside the rest. The page stays in Home but opens over the shell, without the floating bar. - What the map's source sees moves behind a question mark. - The map's credit on the app's theme: flutter_map's, built on flutter/material, never saw it (material_ui's Theme is a class of its own) and drew the theme's text on white; map_tiles read that Theme too, and so never chose the instance's dark map (D50). - Places named in the app's language (name:<language>) where OpenFreeMap's styles ask for the English name. - The route planner's hint behind a question mark; a new route's map opens at zoom 14 where the phone was last known to be, else where the newest workout with a track started; its details beside the map from expanded windows on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
30dd8c96eb
commit
3e90753b08
1 changed files with 1518 additions and 358 deletions
|
|
@ -56,9 +56,11 @@ import 'package:halkyon_train_flutter/src/feature/strength/model/strength_plan.d
|
|||
import 'package:halkyon_train_flutter/src/feature/weather/data/weather_gateway.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/weather/model/workout_weather.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/workout/data/workout_repository.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/workout/model/series_chunk.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/workout/model/workout.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/workout/widget/progress_cards.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/workout/widget/week_card.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/workout/widget/workout_screen.dart';
|
||||
import 'package:halkyon_train_flutter/src/tabs/maps_tab.dart';
|
||||
import 'package:halkyon_train_flutter/src/tabs/record_tab.dart';
|
||||
import 'package:halkyon_ui/halkyon_ui.dart';
|
||||
|
|
@ -289,6 +291,21 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// The route planner's help, behind its question mark rather than over
|
||||
/// the map (D63): opened, read and closed.
|
||||
Future<void> expectRouteHelp(WidgetTester tester) async {
|
||||
const help =
|
||||
'Tap the map to add a waypoint, tap one to take it off. Hold '
|
||||
'one to drag it, or hold the line to pull out another.';
|
||||
expect(find.text(help), findsNothing);
|
||||
await tester.tap(find.byTooltip("What's this?"));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Planning a route'), findsOneWidget);
|
||||
expect(find.text(help), findsOneWidget);
|
||||
await tester.tap(find.text('OK'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Goes to the tab [label] of the navigation bar (ADR 0030, D60).
|
||||
Future<void> goTab(WidgetTester tester, String label) async {
|
||||
await tester.tap(
|
||||
|
|
@ -2122,20 +2139,16 @@ void main() {
|
|||
await pass(tester);
|
||||
expect(find.text('Save this workout?'), findsOneWidget);
|
||||
|
||||
// Saved, its page opens, in Home's tab (D60).
|
||||
// Saved, its page opens, over the tabs (D63).
|
||||
await tester.tap(find.text('Save'));
|
||||
await pass(tester, 2);
|
||||
final ride = find.textContaining(RegExp('ride', caseSensitive: false));
|
||||
expect(
|
||||
find.descendant(of: find.byType(AppBar), matching: ride),
|
||||
findsOneWidget,
|
||||
);
|
||||
final page = find.byType(WorkoutScreen);
|
||||
expect(find.descendant(of: page, matching: ride), findsWidgets);
|
||||
expect(find.byType(FloatingNavigationBar), findsNothing);
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.descendant(of: find.byType(AppBar), matching: ride),
|
||||
findsNothing,
|
||||
);
|
||||
expect(page, findsNothing);
|
||||
expect(ride, findsWidgets);
|
||||
expect(startFor(), findsNothing);
|
||||
final saved = (await workouts.all()).single.content!;
|
||||
|
|
@ -2404,7 +2417,9 @@ void main() {
|
|||
StepKind.recovery,
|
||||
]);
|
||||
|
||||
// The workout, in Home.
|
||||
// The workout, over the tabs (D63), and again from Home.
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
await goTab(tester, 'Home');
|
||||
await tester.tap(find.text('0:50'));
|
||||
await tester.runAsync(pumpEventQueue);
|
||||
|
|
@ -3049,13 +3064,16 @@ void main() {
|
|||
folder.deleteSync(recursive: true);
|
||||
});
|
||||
|
||||
/// Maps, on a phone at [at] (null: a device that can't tell).
|
||||
/// Maps, on a phone at [at] (null: a device that can't tell), last known
|
||||
/// at [last], with [workouts].
|
||||
Future<void> openRoutes(
|
||||
WidgetTester tester, {
|
||||
({double lat, double lon})? at,
|
||||
({double lat, double lon})? last,
|
||||
OfflineMaps? offlineMaps,
|
||||
RouteFiles? routeFiles,
|
||||
PlaceSearchGateway? placeSearch,
|
||||
WorkoutRepository? workouts,
|
||||
}) async {
|
||||
await start(
|
||||
tester,
|
||||
|
|
@ -3065,10 +3083,13 @@ void main() {
|
|||
placeSearch: placeSearch,
|
||||
offlineMaps: offlineMaps,
|
||||
routeFiles: routeFiles,
|
||||
recording: at == null
|
||||
workouts: workouts,
|
||||
recording: at == null && last == null
|
||||
? null
|
||||
: (
|
||||
platform: FakeRecorderPlatform()..at = at,
|
||||
platform: FakeRecorderPlatform()
|
||||
..at = at
|
||||
..lastAt = last,
|
||||
file: File('${folder.path}/recording.txt'),
|
||||
devices: {
|
||||
for (final kind in DeviceKind.values)
|
||||
|
|
@ -3109,13 +3130,7 @@ void main() {
|
|||
);
|
||||
await tester.tap(find.text('New route'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text(
|
||||
'Tap the map to add a waypoint, tap one to take it off. Hold '
|
||||
'one to drag it, or hold the line to pull out another.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
await expectRouteHelp(tester);
|
||||
|
||||
await tester.enterText(find.byType(TextField).first, 'Tempelhof');
|
||||
// Past the pause after typing.
|
||||
|
|
@ -3154,13 +3169,7 @@ void main() {
|
|||
await tester.tap(find.text('New route'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
expect(
|
||||
find.text(
|
||||
'Tap the map to add a waypoint, tap one to take it off. Hold '
|
||||
'one to drag it, or hold the line to pull out another.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
await expectRouteHelp(tester);
|
||||
|
||||
await tapMap(tester, const Offset(60, 40));
|
||||
expect(
|
||||
|
|
@ -3203,6 +3212,82 @@ void main() {
|
|||
expect(route.content?.planned, isNotNull);
|
||||
});
|
||||
|
||||
group("a new route's map opens near the person (D63)", () {
|
||||
/// The planner's camera.
|
||||
MapCamera camera(WidgetTester tester) => MapCamera.of(
|
||||
tester.element(
|
||||
find.descendant(
|
||||
of: find.byType(FlutterMap),
|
||||
matching: find.byType(MarkerLayer),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('where the phone was last known, closer, before any fix', (
|
||||
tester,
|
||||
) async {
|
||||
await openRoutes(tester, last: (lat: 52.52, lon: 13.405));
|
||||
await tester.tap(find.text('New route'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(camera(tester).zoom, 14);
|
||||
expect(camera(tester).center.latitude, closeTo(52.52, 1e-6));
|
||||
expect(find.text('1'), findsNothing, reason: 'no waypoint set');
|
||||
});
|
||||
|
||||
testWidgets('else where the newest workout with a track started', (
|
||||
tester,
|
||||
) async {
|
||||
final workouts = WorkoutRepository(MemoryWorkoutGateway(), keys);
|
||||
final start = DateTime.utc(2026, 10, 20, 7);
|
||||
await workouts.save(
|
||||
WorkoutContent(
|
||||
activity: Activity.running,
|
||||
startedAt: start,
|
||||
endedAt: start.add(const Duration(minutes: 20)),
|
||||
),
|
||||
chunksOf(
|
||||
SeriesKind.position,
|
||||
start: start,
|
||||
times: const [0],
|
||||
columns: {
|
||||
'lat': [475500000],
|
||||
'lon': [96800000],
|
||||
},
|
||||
),
|
||||
);
|
||||
await openRoutes(tester, workouts: workouts);
|
||||
await tester.tap(find.text('New route'));
|
||||
await tester.runAsync(pumpEventQueue);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(camera(tester).zoom, 14);
|
||||
expect(camera(tester).center.latitude, closeTo(47.55, 1e-6));
|
||||
expect(camera(tester).center.longitude, closeTo(9.68, 1e-6));
|
||||
});
|
||||
|
||||
testWidgets('else the region, as before', (tester) async {
|
||||
await openRoutes(tester);
|
||||
await tester.tap(find.text('New route'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(camera(tester).zoom, lessThan(10));
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets("from expanded windows on, the planner's details beside its "
|
||||
'map (D63)', (tester) async {
|
||||
await openRoutes(tester);
|
||||
tester.view.physicalSize = const Size(1280, 800);
|
||||
await tester.tap(find.text('New route'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
tester.getTopRight(find.byType(FlutterMap)).dx,
|
||||
lessThanOrEqualTo(tester.getTopLeft(find.text('Name')).dx),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('the activity picks the profile, which plans the way again', (
|
||||
tester,
|
||||
) async {
|
||||
|
|
@ -3758,8 +3843,9 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
testWidgets('home and a workout’s page run on beneath the floating bar, '
|
||||
'their lists ending clear of it', (tester) async {
|
||||
testWidgets('home runs on beneath the floating bar, its list ending '
|
||||
"clear of it; a workout's page covers the bar, its sheet ending clear "
|
||||
"of the screen's foot (D63)", (tester) async {
|
||||
for (var day = 1; day <= 12; day++) {
|
||||
await saveRun(DateTime(2026, 10, day, 7, 30));
|
||||
}
|
||||
|
|
@ -3790,7 +3876,21 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Morning run').first);
|
||||
await tester.pumpAndSettle();
|
||||
await endsClearOfTheBar(find.byType(Scrollable).last);
|
||||
|
||||
expect(bar, findsNothing);
|
||||
final sheet = find.descendant(
|
||||
of: find.byType(DraggableScrollableSheet),
|
||||
matching: find.byType(Scrollable),
|
||||
);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
await tester.drag(sheet, const Offset(0, -5000));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
final items = find.descendant(of: sheet, matching: find.byType(Text));
|
||||
expect(
|
||||
tester.getBottomLeft(items.last).dy,
|
||||
lessThanOrEqualTo(screen - 48),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('above them, this week: its time, distance and workouts, and '
|
||||
|
|
@ -3891,14 +3991,18 @@ void main() {
|
|||
expect(find.text('2.50 km'), findsOneWidget);
|
||||
expect(find.text('20 m'), findsOneWidget);
|
||||
expect(find.text('whole time'), findsOneWidget);
|
||||
expect(
|
||||
find.text(
|
||||
// What the map's source sees, one tap away (D63).
|
||||
const sees =
|
||||
"Map by OpenFreeMap: it sees your device's address and the area "
|
||||
'shown, not your track.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
'shown, not your track.';
|
||||
expect(find.text(sees), findsNothing);
|
||||
await tester.tap(find.byTooltip("What's this?"));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('About the map'), findsOneWidget);
|
||||
expect(find.text(sees), findsOneWidget);
|
||||
expect(find.text('What OpenFreeMap keeps'), findsOneWidget);
|
||||
await tester.tap(find.text('OK'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.scrollUntilVisible(find.text('km 3'), 200);
|
||||
expect(find.text('Splits'), findsOneWidget);
|
||||
expect(find.text('km 1'), findsOneWidget);
|
||||
|
|
@ -3925,6 +4029,8 @@ void main() {
|
|||
|
||||
await tester.tap(find.text('Morning run'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byTooltip("What's this?"));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
find.text(
|
||||
|
|
@ -3936,6 +4042,115 @@ void main() {
|
|||
expect(find.textContaining('sees your device'), findsNothing);
|
||||
});
|
||||
|
||||
group("a workout's page as Strava's (D63)", () {
|
||||
MapCamera camera(WidgetTester tester) =>
|
||||
MapCamera.of(tester.element(find.byType(PolylineLayer)));
|
||||
|
||||
Future<void> openRun(WidgetTester tester) async {
|
||||
await saveRun(DateTime(2026, 10, 27, 7, 30));
|
||||
await startWith(tester);
|
||||
await tester.tap(find.text('Morning run'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('its map to the foot of the screen, under a sheet with its '
|
||||
'name; pulled down, the map fits the track anew, closer', (
|
||||
tester,
|
||||
) async {
|
||||
await openRun(tester);
|
||||
expect(
|
||||
tester.getBottomLeft(find.byType(FlutterMap)).dy,
|
||||
tester.view.physicalSize.height,
|
||||
);
|
||||
final sheet = find.byType(DraggableScrollableSheet);
|
||||
expect(
|
||||
find.descendant(of: sheet, matching: find.text('Morning run')),
|
||||
findsOneWidget,
|
||||
);
|
||||
final before = camera(tester);
|
||||
|
||||
await tester.drag(find.text('2.50 km'), const Offset(0, 400));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(camera(tester).zoom, greaterThan(before.zoom));
|
||||
expect(
|
||||
camera(tester).center.latitude,
|
||||
greaterThan(before.center.latitude),
|
||||
reason:
|
||||
'the track lower on the larger map: the map looks south of it',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("pulled up, the round back button turns into a bar's "
|
||||
'chevron that lowers the sheet again', (tester) async {
|
||||
await openRun(tester);
|
||||
expect(find.byTooltip('Back'), findsOneWidget);
|
||||
expect(find.byTooltip('Show the map'), findsNothing);
|
||||
|
||||
await tester.drag(find.text('2.50 km'), const Offset(0, -2000));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byTooltip('Show the map'), findsOneWidget);
|
||||
expect(find.byTooltip('Back'), findsNothing);
|
||||
|
||||
await tester.tap(find.byTooltip('Show the map'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byTooltip('Back'), findsOneWidget);
|
||||
await tester.tap(find.byTooltip('Back'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(WorkoutScreen), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('from expanded windows on, the map beside the rest', (
|
||||
tester,
|
||||
) async {
|
||||
await saveRun(DateTime(2026, 10, 27, 7, 30));
|
||||
await startWith(tester);
|
||||
tester.view.physicalSize = const Size(1280, 800);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Morning run').last);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(DraggableScrollableSheet), findsNothing);
|
||||
expect(
|
||||
tester.getTopRight(find.byType(FlutterMap)).dx,
|
||||
lessThanOrEqualTo(tester.getTopLeft(find.text('2.50 km')).dx),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("the map's credit opens on the theme's surface, in its "
|
||||
'colours', (tester) async {
|
||||
await openRun(tester);
|
||||
final credit = tester.widget<RichAttributionWidget>(
|
||||
find.byType(RichAttributionWidget),
|
||||
);
|
||||
final scheme = Theme.of(
|
||||
tester.element(find.byType(RichAttributionWidget)),
|
||||
).colorScheme;
|
||||
expect(credit.popupBackgroundColor, scheme.surfaceContainerHigh);
|
||||
|
||||
await tester.tap(find.byTooltip('Map credits'));
|
||||
await tester.pumpAndSettle();
|
||||
final text = find.textContaining('OpenFreeMap © OpenMapTiles');
|
||||
expect(text, findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byType(TextSourceAttribution),
|
||||
matching: find.byType(Text),
|
||||
)
|
||||
.first,
|
||||
)
|
||||
.style
|
||||
?.color,
|
||||
scheme.onSurface,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets("a workout with a strap shows the heart's average and highest "
|
||||
'rate, by split too, and its chart', (tester) async {
|
||||
await saveRun(DateTime(2026, 10, 27, 7, 30), strap: true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue