UI-07: rebuild Rides History with search, activity filter, and real ride thumbnails
Restyles TripsScreen toward Map HUD's GlassPanel language: a search bar and activity-filter dropdown, four distinct summary stat cards (replacing the mockup's four-identical-cards artifact), and per-ride RideMap thumbnails showing each ride's own recorded path instead of stock photos. RideHistorySummary is a pure function rather than a provider, since folding over an already-fetched trip list is cheap regardless of history length, and it makes the aggregation directly unit-testable. Average speed is distance-weighted across the whole history rather than averaging each ride's own average. Adds a showAttribution flag to RideMap (default true) to suppress the TileAttribution control on tiny list thumbnails, where it was both a UX problem and a test collision with each card's own activity icon. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Xki7YAcc2TiN2PRZJ2tXr
This commit is contained in:
43
test/ride_history_summary_test.dart
Normal file
43
test/ride_history_summary_test.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rippr/src/domain/models.dart';
|
||||
import 'package:rippr/src/ui/trips/trips_screen.dart';
|
||||
|
||||
/// UI-07: `RideHistorySummary.compute` is a pure function specifically so it can be
|
||||
/// tested directly against a hand-computed total, rather than through a screen.
|
||||
void main() {
|
||||
test('compute matches a hand-computed total over a fixed set of trips', () {
|
||||
final trips = [
|
||||
const Trip(
|
||||
id: 1,
|
||||
startedAt: 0,
|
||||
endedAt: 3600000,
|
||||
distanceM: 20000,
|
||||
movingMillis: 3600000,
|
||||
),
|
||||
const Trip(
|
||||
id: 2,
|
||||
startedAt: 0,
|
||||
endedAt: 1800000,
|
||||
distanceM: 5000,
|
||||
movingMillis: 1800000,
|
||||
),
|
||||
];
|
||||
|
||||
final summary = RideHistorySummary.compute(trips);
|
||||
|
||||
expect(summary.rideCount, 2);
|
||||
expect(summary.totalDistanceM, 25000);
|
||||
expect(summary.totalMovingMillis, 5400000);
|
||||
// Distance-weighted, not an average of each ride's own average: 25 km over 1.5 h.
|
||||
expect(summary.avgSpeedKmh, closeTo(25 / 1.5, 0.0001));
|
||||
});
|
||||
|
||||
test('an empty history has zero average speed, not a division error', () {
|
||||
final summary = RideHistorySummary.compute(const []);
|
||||
|
||||
expect(summary.rideCount, 0);
|
||||
expect(summary.totalDistanceM, 0);
|
||||
expect(summary.totalMovingMillis, 0);
|
||||
expect(summary.avgSpeedKmh, 0);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user