Miler rider app: surface system, visible design language, backend lifecycle

Design system
- MilerSurface ladder (canvas → working → raised → floating) with MilerPanel
  as layer 1; canvas moved to #DEE3EA so white separates at 1.290:1.
- Visible vocabulary applied across Home, Deliveries, Activity, Account and
  the sheets: hero heads (tabular numeral + small caption, clamped at 1.3x),
  canvas wells for anything that opens, small filled tags for shelf labels,
  demoted placeholders. Recorded in DESIGN_SYSTEM.md §6.
- One icon family: 222 Material glyphs migrated to Lucide; none left outside
  lib/xpress.
- Colour semantics corrected: amber only for what is genuinely owed, brand red
  reserved for the live stop, disabled primaries go neutral rather than pale.

Data and lifecycle
- lib/data/lifecycle.dart reads mutations for what they prove; route_order.dart
  makes admin sequence the single ordering authority; service_day.dart, and
  stop_area.dart rewritten against live Coimbatore addresses (digit-token
  stripping, city stoplist, street suffixes, stammer collapse).
- countLabel states the load once, in bags.

Testing
- 1440 tests passing; golden shot harnesses for Home, Deliveries, Activity,
  sheets and verify, with test/failures/ now gitignored (diff debris).
- New pins: home_gutter_test, stop_area_test, plus updated structural bounds.

Note: this commit also carries pre-existing working-tree deletions that were
present before this work (API_SPEC.md, README.md, demo test fixtures).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-22 05:40:35 +05:30
parent c8350563d9
commit d7348e253f
387 changed files with 80693 additions and 12272 deletions

View File

@@ -14,10 +14,10 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
Map<String, dynamic> booking(String id) => {
'orderid': id,
'pickupcustomer': 'Sri Balaji Stores',
'pickupaddress': '19, Thadagam Road, Coimbatore',
};
'orderid': id,
'pickupcustomer': 'Sri Balaji Stores',
'pickupaddress': '19, Thadagam Road, Coimbatore',
};
String today() {
final t = DateTime.now();
@@ -64,6 +64,25 @@ void main() {
expect(await getCompletedBookings(), hasLength(1));
});
// ── What Home stamps over a lagging queue ──
//
// Home reads these ids and rewrites `orderstatus` to 'picked' on any stop the
// queue is still reporting as live. Without it the row the rider has just
// confirmed sits on Home wearing its LIVE mark until the backend catches up,
// which reads as the confirm not having worked.
test('the finished ids are readable on their own', () async {
await addCompletedBookings([booking('A')]);
await addCompletedBookings([booking('B')], cancelled: true);
// Both count as closed: a stop written off is as finished, for Home's
// purposes, as one picked up.
expect(await getCompletedOrderIds(), {'A', 'B'});
});
test('nothing finished is an empty set, not a null', () async {
expect(await getCompletedOrderIds(), isEmpty);
});
// ── The timings ──
//
// Activity's stop detail can only answer "when did I get there" and "how long
@@ -72,72 +91,90 @@ void main() {
// moment they can be captured — and capturing a stale one is worse than
// capturing none, because another stop's clock reads as fact.
group('timings', () {
Map<String, dynamic> withPickup(String id) =>
{...booking(id), 'pickupid': '77'};
Map<String, dynamic> withPickup(String id) => {
...booking(id),
'pickupid': '77',
};
test('the departure and arrival stamps are carried onto the record',
() async {
SharedPreferences.setMockInitialValues({
kStopStartedKey('77'): '2026-08-06T09:12:00.000',
kStopArrivedKey('77'): '2026-08-06T09:31:00.000',
});
test(
'the departure and arrival stamps are carried onto the record',
() async {
SharedPreferences.setMockInitialValues({
kStopStartedKey('77'): '2026-08-06T09:12:00.000',
kStopArrivedKey('77'): '2026-08-06T09:31:00.000',
});
await addCompletedBookings([withPickup('A')]);
await addCompletedBookings([withPickup('A')]);
final done = await getCompletedBookings();
expect(done.single['startedat'], '2026-08-06T09:12:00.000');
expect(done.single['arrivedat'], '2026-08-06T09:31:00.000');
});
final done = await getCompletedBookings();
expect(done.single['startedat'], '2026-08-06T09:12:00.000');
expect(done.single['arrivedat'], '2026-08-06T09:31:00.000');
},
);
test('the keys are cleared, so the next stop cannot inherit them',
() async {
SharedPreferences.setMockInitialValues({
kStopStartedKey('77'): '2026-08-06T09:12:00.000',
kStopArrivedKey('77'): '2026-08-06T09:31:00.000',
});
test(
'the keys are cleared, so the next stop cannot inherit them',
() async {
SharedPreferences.setMockInitialValues({
kStopStartedKey('77'): '2026-08-06T09:12:00.000',
kStopArrivedKey('77'): '2026-08-06T09:31:00.000',
});
await addCompletedBookings([withPickup('A')]);
await addCompletedBookings([withPickup('A')]);
final prefs = await SharedPreferences.getInstance();
expect(prefs.getString(kStopStartedKey('77')), isNull);
expect(prefs.getString(kStopArrivedKey('77')), isNull);
final prefs = await SharedPreferences.getInstance();
expect(prefs.getString(kStopStartedKey('77')), isNull);
expect(prefs.getString(kStopArrivedKey('77')), isNull);
// A second stop sharing the pickup id — a resumed skip worked twice in
// one day — must not report the first attempt's clock.
await addCompletedBookings([withPickup('B')]);
final second = (await getCompletedBookings())
.firstWhere((b) => b['orderid'] == 'B');
expect(second['startedat'], isNull);
});
// A second stop sharing the pickup id — a resumed skip worked twice in
// one day — must not report the first attempt's clock.
await addCompletedBookings([withPickup('B')]);
final second = (await getCompletedBookings()).firstWhere(
(b) => b['orderid'] == 'B',
);
expect(second['startedat'], isNull);
},
);
test('a stop closed without ever opening the map claims no timings',
() async {
// Bulk-completed from Home: nothing wrote a departure, so nothing is
// claimed, and the detail panel says "not recorded" instead of inventing
// a figure that cannot be caught.
await addCompletedBookings([withPickup('A')]);
test(
'a stop closed without ever opening the map claims no timings',
() async {
// Bulk-completed from Home: nothing wrote a departure, so nothing is
// claimed, and the detail panel says "not recorded" instead of inventing
// a figure that cannot be caught.
await addCompletedBookings([withPickup('A')]);
final done = await getCompletedBookings();
expect(done.single['startedat'], isNull);
expect(done.single['arrivedat'], isNull);
});
final done = await getCompletedBookings();
expect(done.single['startedat'], isNull);
expect(done.single['arrivedat'], isNull);
},
);
});
// The store is per-day: yesterday's work is not today's activity, and a store
// that never forgets grows for the life of the install.
test('yesterday is dropped, today is kept', () async {
SharedPreferences.setMockInitialValues({
'completed_bookings': jsonEncode([
{...booking('OLD'), 'completedday': '2020-01-01', 'orderstatus': 'picked'},
SharedPreferences.setMockInitialValues({});
await debugSeedStore(
'completed_bookings',
jsonEncode([
{
...booking('OLD'),
'completedday': '2020-01-01',
'orderstatus': 'picked',
},
{...booking('NEW'), 'completedday': today(), 'orderstatus': 'picked'},
]),
});
);
final done = await getCompletedBookings();
expect(done.map((b) => b['orderid']).toList(), ['NEW']);
// And the prune is written back, not recomputed on every read.
final prefs = await SharedPreferences.getInstance();
expect(prefs.getString('completed_bookings'), isNot(contains('OLD')));
expect(
prefs.getString(await debugStoreKey('completed_bookings')),
isNot(contains('OLD')),
);
});
}