V3-01: activity type per ride
Adds Activity (motorcycle/bicycle/scooter/skateboard/running/walking/other) as a column on Trip, and threads it through as real behaviour rather than a label: ActivityProfile (domain/activity_profile.dart) carries a noise floor, accuracy gate, histogram bucket width, and elevation smoothing window/threshold per activity, consumed by sanitizeSpeedKmh, isUsableFix, computeSummary, Accumulator and speedHistogram. The motorcycle profile reproduces the exact constants the app shipped with before this existed, and a test asserts they never drift apart. This is the port's first real migration: schemaVersion 1 -> 2, m.addColumn(trips, trips.activity) with a motorcycle default so every existing row survives unmodified. Proven with a hand-built v1 SQLite file (raw sqlite3, not drift_dev's schema tooling) that a real database with real rides upgrades and keeps every trip, segment and point. No picker in front of Start: a new trip defaults to whichever activity was most recently used, derived live from the trips table rather than duplicated into a Config field. Editable afterwards on trip detail, which recomputes aggregates under the new profile immediately -- a walking pace that reads as noise under a motorcycle's floor reads as real movement once the activity is corrected, and there's a test proving exactly that transition. The widget-test pass for the activity-picker sheet caught a real overflow bug: seven options overflowed a Column-based bottom sheet the same way the record screen once did. Fixed with a scrollable ListView + isScrollControlled, same shape as that earlier fix. 188 tests (171 -> 188): 2 migration, 5 ActivityProfile, 3 profile-threading proofs in computeSummary, 5 repository, 2 widget. Analyze clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:rippr/src/app/providers.dart';
|
||||
import 'package:rippr/src/data/database.dart';
|
||||
import 'package:rippr/src/data/trip_repository.dart';
|
||||
import 'package:rippr/src/domain/models.dart';
|
||||
import 'package:rippr/src/ui/activity_display.dart';
|
||||
import 'package:rippr/src/recording/location_source.dart';
|
||||
import 'package:rippr/src/ui/detail/trip_detail_screen.dart';
|
||||
import 'package:rippr/src/ui/record/record_screen.dart';
|
||||
@@ -282,6 +283,27 @@ void main() {
|
||||
|
||||
expect(await repo.tripById(a), isNull);
|
||||
});
|
||||
|
||||
screenTest('a tile shows its own activity icon (V3-01)', (tester) async {
|
||||
final motorcycleTrip =
|
||||
await seedCompletedTrip(startedAt: 1000, endedAt: 5000, name: 'Ride');
|
||||
final bikeTrip =
|
||||
await seedCompletedTrip(startedAt: 10000, endedAt: 15000, name: 'Bike');
|
||||
await repo.setActivity(bikeTrip, Activity.bicycle);
|
||||
|
||||
await tester.pumpWidget(host(const TripsScreen()));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Icon iconFor(int tripId) => tester.widget<Icon>(
|
||||
find.descendant(
|
||||
of: find.byKey(Key('trip-$tripId')),
|
||||
matching: find.byType(Icon),
|
||||
),
|
||||
);
|
||||
|
||||
expect(iconFor(motorcycleTrip).icon, activityIcon(Activity.motorcycle));
|
||||
expect(iconFor(bikeTrip).icon, activityIcon(Activity.bicycle));
|
||||
});
|
||||
});
|
||||
|
||||
group('trip detail', () {
|
||||
@@ -340,5 +362,23 @@ void main() {
|
||||
expect(find.text('Coast run'), findsOneWidget);
|
||||
expect((await repo.tripById(id))!.name, 'Coast run');
|
||||
});
|
||||
|
||||
screenTest('editing the activity updates the row and recomputes aggregates',
|
||||
(tester) async {
|
||||
final id = await seedCompletedTrip(startedAt: 1000, endedAt: 5000);
|
||||
|
||||
await tester.pumpWidget(host(TripDetailScreen(tripId: id), map: false));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(activityLabel(Activity.motorcycle)), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('activity-row')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(Key('activity-${Activity.walking.name}')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(activityLabel(Activity.walking)), findsOneWidget);
|
||||
expect((await repo.tripById(id))!.activity, Activity.walking);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user