miler map

This commit is contained in:
2026-09-09 12:55:23 +05:30
parent 074cc0eccf
commit 127fa062ed
143 changed files with 4315 additions and 2291 deletions

View File

@@ -0,0 +1,109 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:miler/views/Dashboard/home/trip.dart';
import 'package:miler/views/Dashboard/home/trip_brief_strip.dart';
import 'package:miler/views/Dashboard/home/trip_card.dart';
/// ─────────────────────────────────────────────────────────────────────────
/// AN UNFILLED SLOT LOOKS LIKE A FILLED ONE, AT ZERO
///
/// Home's trip panel used to change shape depending on whether the hub had got
/// to the slot yet: a filled slot got the brief, an unfilled one got a single
/// line reading `Not assigned yet`, which made the panel a 32pt stub under a
/// tab twice its height — and repeated a sentence the illustration below it
/// already carried.
///
/// The brief of an empty slot is a real brief. Every figure it draws is derived
/// from the stops, so an empty list gives `0 stops left`, an empty progress
/// track and an em dash under everything with nothing to report — with no
/// second "empty" layout to keep in step with the real one.
///
/// What this holds is the property that makes it worth doing: the panel is the
/// **same height** either way, so when the hub assigns the trip the figures
/// fill in where the dashes were instead of the page changing shape under the
/// rider's thumb.
/// ─────────────────────────────────────────────────────────────────────────
void main() {
Trip filled() => Trip.fromStops(
id: 't1',
stops: [
for (var i = 0; i < 3; i++)
{
'orderid': 'S$i',
'pickupid': 'S$i',
'pickupcustomer': 'Sri Balaji Stores',
'pickupaddress': '19, Thadagam Road, Coimbatore',
'orderstatus': 'pending',
'Quantity': '2',
'collectionamt': '450',
},
],
);
/// What `homepage.dart` builds for a slot the hub has not filled.
Trip unassigned() => Trip.fromStops(id: 'unassigned-1', stops: const []);
Future<void> pump(WidgetTester tester, Trip trip) async {
tester.view.physicalSize = const Size(390 * 3, 844 * 3);
tester.view.devicePixelRatio = 3.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
ScreenUtilInit(
designSize: const Size(390, 844),
builder: (_, _) => MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: TripCard(trip: trip).buildSummary(onBrand: true),
),
),
),
),
);
await tester.pumpAndSettle();
}
testWidgets('an unfilled slot reads zero, not empty', (tester) async {
await pump(tester, unassigned());
expect(find.text('0 stops left'), findsOneWidget);
// The count is a real zero; the three figures that have nothing to report
// print the em dash every other figure in the app prints, because `None`
// set in figure type reads as data.
expect(find.text('0'), findsOneWidget);
expect(find.text('—'), findsNWidgets(3));
// And it is still the brief, not a special case: the same four labels.
for (final label in const [
'Duration',
'Distance',
'Parcels',
'Payment',
]) {
expect(find.text(label), findsOneWidget);
}
expect(tester.takeException(), isNull);
});
testWidgets('and it is the same height as a filled one', (tester) async {
// `buildSummary` returns the strip itself — [TripCard] is a builder, and
// never enters the tree.
await pump(tester, unassigned());
final empty = tester.getSize(find.byType(TripBriefStrip)).height;
await pump(tester, filled());
final full = tester.getSize(find.byType(TripBriefStrip)).height;
expect(
empty,
closeTo(full, 0.5),
reason:
'the panel must not change shape when the hub assigns the trip — the '
'figures fill in where the dashes were, and nothing below it moves',
);
});
}