Update codebase

This commit is contained in:
Hamza-Ayed
2026-08-05 14:12:41 +03:00
parent 58928cd258
commit 95e2e4f35d
51 changed files with 3141 additions and 390 deletions
@@ -10,10 +10,13 @@ import '../../../core/ui/status_banner.dart';
import '../../../core/ui/tripz_button.dart';
import '../cubit/ride_cubit.dart';
import '../cubit/ride_state.dart';
import '../cubit/trip_simulator.dart';
import '../data/models/geo_point.dart';
import '../data/models/route_info.dart';
import 'widgets/active_trip_sheet.dart';
import 'widgets/center_pin.dart';
import 'widgets/confirm_sheet.dart';
import 'widgets/place_search_dialog.dart';
import 'widgets/planner_sheet.dart';
import 'widgets/ride_map.dart';
import 'widgets/searching_sheet.dart';
@@ -30,8 +33,16 @@ class RidePage extends StatefulWidget {
State<RidePage> createState() => _RidePageState();
}
/// نصيب الورقة السفلية من ارتفاع الشاشة — الخريطة تأخذ ما تبقّى (~67%).
///
/// قرار المالك 2026-08-05: الخريطة تُرفع عن القاع بالثلث كي تبقى مساحة
/// الورقة خالصة لها. سيرو يرفعها بـ20%، وتريبز بـ33% لأن ورقته تعرض
/// خطوطاً أكثر (الخط الزمني + الأنواع + السعر).
const double _sheetFraction = 0.33;
class _RidePageState extends State<RidePage> with WidgetsBindingObserver {
late final RideCubit _cubit = sl<RideCubit>()..init();
late final TripSimulator _simulator = TripSimulator(_cubit);
GeoPoint? _mapCenter;
@override
@@ -43,6 +54,7 @@ class _RidePageState extends State<RidePage> with WidgetsBindingObserver {
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_simulator.stop();
_cubit.close();
super.dispose();
}
@@ -65,47 +77,82 @@ class _RidePageState extends State<RidePage> with WidgetsBindingObserver {
body: Stack(
children: [
// ── الخريطة ────────────────────────────────────────────────
BlocSelector<RideCubit, RideState, _MapData>(
selector: (s) => _MapData(
origin: s.origin,
destination: s.destination,
driver: s.driverLocation,
route: s.route,
camera: s.cameraTarget,
originLabel: s.originLabel,
destinationLabel: s.destinationLabel,
),
builder: (context, data) => RideMap(
origin: data.origin,
destination: data.destination,
driver: data.driver,
route: data.route,
cameraTarget: data.camera,
onCameraIdle: (p) => _mapCenter = p,
// الورقة تغطّي نحو ثلث الشاشة — يُحسب منه إطار المسار كي لا
// يختفي نصفه تحتها.
bottomInset: MediaQuery.sizeOf(context).height * 0.34,
originLabel: data.originLabel,
destinationLabel: data.destinationLabel,
),
),
//
// **مرفوعة عن القاع بمقدار [_sheetFraction]** لا مالئةً الشاشة:
// الثلث السفلي مساحة الورقة وحدها، فلا تغطّي الورقةُ الخريطةَ
// (نمط سيرو — `Positioned(bottom: Get.height * .2, top: 0)` في
// `google_map_passenger_widget.dart`).
//
// والدبّوس **داخل نفس المنطقة** لا في الـ`Stack` الخارجي: مركز
// الكاميرا (`onCameraIdle`) هو مركز ودجت الخريطة، فلو بقي
// الدبّوس متمركزاً على الشاشة لأشار إلى نقطة غير التي تُؤكَّد.
Positioned(
top: 0,
left: 0,
right: 0,
bottom: MediaQuery.sizeOf(context).height * _sheetFraction,
child: Stack(
children: [
BlocSelector<RideCubit, RideState, _MapData>(
selector: (s) => _MapData(
origin: s.origin,
destination: s.destination,
driver: s.driverLocation,
route: s.route,
pickupRoute: s.pickupRoute,
camera: s.cameraTarget,
originLabel: s.originLabel,
destinationLabel: s.destinationLabel,
),
builder: (context, data) => RideMap(
origin: data.origin,
destination: data.destination,
driver: data.driver,
route: data.route,
pickupRoute: data.pickupRoute,
cameraTarget: data.camera,
onCameraIdle: (p) => _mapCenter = p,
// الورقة لم تعد تغطّي الخريطة — تبقى حشوة تنفّس فقط
// كي لا يلتصق المسار بحافّة الخريطة السفلية.
bottomInset: Space.xxl,
originLabel: data.originLabel,
destinationLabel: data.destinationLabel,
),
),
// ── دبّوس الاختيار ─────────────────────────────────────────
BlocSelector<RideCubit, RideState, bool>(
selector: (s) => s.phase == RidePhase.pickingOnMap,
builder: (context, picking) =>
picking ? const CenterPin() : const SizedBox.shrink(),
// ── دبّوس الاختيار ─────────────────────────────────────
BlocSelector<RideCubit, RideState, bool>(
selector: (s) => s.phase == RidePhase.pickingOnMap,
builder: (context, picking) =>
picking ? const CenterPin() : const SizedBox.shrink(),
),
],
),
),
// زر القائمة — يطفو فوق الخريطة، ويحترم المنطقة الآمنة.
SafeArea(
child: Padding(
padding: Space.page,
child: Builder(
builder: (context) => _MapFab(
icon: Icons.menu_rounded,
onTap: Scaffold.of(context).openDrawer,
),
child: Row(
children: [
Builder(
builder: (context) => _MapFab(
icon: Icons.menu_rounded,
onTap: Scaffold.of(context).openDrawer,
),
),
// زرّ المحاكاة — يظهر فقط مع
// `--dart-define=SIMULATE_TRIP=true`. الشرط `const` فيُحذف
// هو وما تحته من بناء الإنتاج.
if (RideCubit.simulationEnabled) ...[
const SizedBox(width: Space.xs),
_MapFab(
icon: Icons.play_arrow_rounded,
onTap: () => _simulator.start(),
),
],
],
),
),
),
@@ -137,6 +184,7 @@ class _MapData {
this.destination,
this.driver,
this.route,
this.pickupRoute,
this.camera,
this.originLabel = '',
this.destinationLabel = '',
@@ -145,7 +193,8 @@ class _MapData {
final GeoPoint? origin;
final GeoPoint? destination;
final GeoPoint? driver;
final dynamic route;
final RouteInfo? route;
final RouteInfo? pickupRoute;
final GeoPoint? camera;
final String originLabel;
final String destinationLabel;
@@ -157,6 +206,7 @@ class _MapData {
other.destination == destination &&
other.driver == driver &&
other.route == route &&
other.pickupRoute == pickupRoute &&
other.camera == camera &&
other.originLabel == originLabel &&
other.destinationLabel == destinationLabel;
@@ -167,6 +217,7 @@ class _MapData {
destination,
driver,
route,
pickupRoute,
camera,
originLabel,
destinationLabel,
@@ -190,11 +241,20 @@ class _Sheet extends StatelessWidget {
RidePhase.pickingOnMap => _PickConfirm(onConfirm: onConfirmPick),
RidePhase.confirming => ConfirmSheet(state: state),
RidePhase.searching => const SearchingSheet(),
RidePhase.active => ActiveTripSheet(trip: state.trip!),
RidePhase.active => ActiveTripSheet(
trip: state.trip!,
pickupRoute: state.pickupRoute,
),
};
return Container(
width: double.infinity,
// الحدّ الأدنى = المساحة المحجوزة للورقة تحت الخريطة، وإلا ظهر فراغُ
// الـ`Scaffold` بينهما في المراحل قصيرة المحتوى (`idle` مثلاً).
// وهو حدّ أدنى لا ثابت: `active` و`confirming` يكبران فوقه بحرّية.
constraints: BoxConstraints(
minHeight: MediaQuery.sizeOf(context).height * _sheetFraction,
),
decoration: BoxDecoration(
color: context.colors.surface,
borderRadius: Radii.sheetTop,
@@ -299,21 +359,32 @@ class _Collapsed extends StatelessWidget {
),
const SizedBox(height: Space.sm),
],
// حقل بحث لا زرّ: الضغط عليه يفتح المخطّط والكيبورد معاً.
// حقل بحث لا زرّ: الضغط عليه يفتح بحث الأماكن بملء الشاشة مباشرةً
// (docs/40 §2) — لا ورقةً وسيطة ثم بحثاً داخلها.
//
// الحشوة سخيّة عمداً: الثلث السفلي صار مساحة الورقة وحدها بعد رفع
// الخريطة، وحقلٌ نحيف وسط فراغ يبدو مقصوصاً لا أنيقاً.
Material(
color: context.colors.surfaceContainerHighest,
borderRadius: Radii.card_,
child: InkWell(
onTap: cubit.openPlanner,
onTap: () => PlaceSearchDialog.show(
context,
target: PickTarget.destination,
),
borderRadius: Radii.card_,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: Space.md,
vertical: Space.sm,
vertical: Space.md,
),
child: Row(
children: [
Icon(Icons.search_rounded, color: context.colors.primary),
Icon(
Icons.search_rounded,
size: Sizes.icon,
color: context.colors.primary,
),
const SizedBox(width: Space.sm),
Expanded(
child: Text(
@@ -323,16 +394,63 @@ class _Collapsed extends StatelessWidget {
),
),
),
Icon(
Icons.chevron_left_rounded,
color: context.colors.onSurfaceVariant,
),
],
),
),
),
),
// الوجهات الأخيرة — نمط سيرو (`rp_favorites.dart: RpRecentsRow`).
// أكثر الرحلات تتكرّر، وبلا هذا يعيد الراكب كتابة الاسم نفسه كل مرة.
const _RecentsRow(),
],
);
}
}
/// صفّ أفقي للوجهات الأخيرة — يختفي كلياً حين لا توجد، فلا يترك فراغاً.
class _RecentsRow extends StatelessWidget {
const _RecentsRow();
@override
Widget build(BuildContext context) {
final cubit = context.read<RideCubit>();
final places = cubit.recentPlaces;
if (places.isEmpty) return const SizedBox.shrink();
return Padding(
padding: const EdgeInsets.only(top: Space.sm),
child: SizedBox(
height: Sizes.touchTarget,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: places.length,
separatorBuilder: (context, i) => const SizedBox(width: Space.xs),
itemBuilder: (context, i) {
final place = places[i];
return ActionChip(
avatar: Icon(
Icons.history_rounded,
size: Sizes.iconSm,
color: context.colors.onSurfaceVariant,
),
label: Text(
place.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
onPressed: () => cubit.pickPlace(place, PickTarget.destination),
);
},
),
),
);
}
}
class _PickConfirm extends StatelessWidget {
const _PickConfirm({required this.onConfirm});