feat(apps): الخريطة وطلب الرحلة ودورة السائق — المرحلة 4
## حسم تعارض الخرائط (docs/38 §7) لصالح القرار الأحدث 2026-07-20: كل الخرائط — البلاطات والبحث والعكسي والمسار — مباشرة إلى map-saas بترويسة x-api-key، بلا مرور بباك إند تريبز. نقاط /maps/* في الباك إند لا تُستعمل، وإحداها (geocode) معطوبة على المنشور. العقد تُحقّق حيّاً بـcurl قبل كتابة سطر. ## النواة المشتركة - core/api/antlaq_api.dart: عميل منفصل بلا AuthInterceptor — توكن تريبز لا شأن لخادم الخرائط به، وإرساله إليه تسريب بلا مقابل - core/realtime: Socket.IO واحد (trip:update · driver:location · trip:offer · trip:offer_taken) - core/location: نقطة الموقع الوحيدة بمرشّح 25 متراً - features/trip/data: سبعة نماذج + MapsRepository + TripRepository متطابق حرفياً بين التوأمين ## الراكب RideCubit بستّ مراحل + RidePage وثمانية ويدجت: الخريطة · دبّوس المنتصف · المخطّط · الخط الزمني · اختيار النوع · التأكيد · البحث عن سائق · الرحلة. ## السائق DutyCubit بأربع مراحل + DutyPage: مفتاح الاتصال · العرض بمؤقّت · الرحلة. ## قرارات تحمي الأداء والصحّة - GeoPoint مستقلّ عن حزمة الخريطة؛ intaleq_maps مستوردة في ملف واحد فقط لكل تطبيق. تبديل محرّك الخريطة لا يلمس منطقاً - الخريطة خارج BlocBuilder الورقة ولها BlocSelector خاص: نبضة موقع كل 25م لا تعيد بناء الشاشة - مهلة بحث محليّة 90ث + استطلاع كل 5ث: الخادم قد لا يُطلق expired/no_drivers أبداً (ثغرة R1)، وانتظار حدث قد لا يصل = شاشة بحث أبدية - offeredDrivers == 0 جواب نهائي فوري بلا انتظار المهلة - الأجرة لا تُعرض إلا إن كانت صالحة: /tariff/quote يرجّع 200 بقيم null صامتة - موقع السائق بمسارين عمداً: REST لمطابقة Redis والسوكت لخريطة الراكب flutter analyze نظيف · الراكب 70 ملف/5,294 سطر · السائق 67 ملف/4,771 سطر. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c52338f3bb
commit
1156299d09
@@ -0,0 +1,140 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../core/design/tokens.dart';
|
||||
import '../../../core/design/tripz_colors.dart';
|
||||
import '../../../core/di.dart';
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
import '../../../core/ui/status_banner.dart';
|
||||
import '../cubit/duty_cubit.dart';
|
||||
import '../cubit/duty_state.dart';
|
||||
import '../data/models/geo_point.dart';
|
||||
import 'widgets/active_duty_sheet.dart';
|
||||
import 'widgets/duty_toggle.dart';
|
||||
import 'widgets/offer_sheet.dart';
|
||||
import 'widgets/ride_map.dart';
|
||||
|
||||
/// شاشة السائق: خريطة + مفتاح الاتصال أعلى + ورقة تتبدّل بالمرحلة.
|
||||
class DutyPage extends StatefulWidget {
|
||||
const DutyPage({super.key});
|
||||
|
||||
@override
|
||||
State<DutyPage> createState() => _DutyPageState();
|
||||
}
|
||||
|
||||
class _DutyPageState extends State<DutyPage> {
|
||||
late final DutyCubit _cubit = sl<DutyCubit>()..init();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_cubit.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider.value(
|
||||
value: _cubit,
|
||||
child: Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
// الخريطة معزولة عن بقية الحالة: نبضة موقع كل 25 متراً يجب ألّا
|
||||
// تعيد بناء الورقة والمفتاح معها.
|
||||
BlocSelector<DutyCubit, DutyState, GeoPoint?>(
|
||||
selector: (s) => s.myLocation,
|
||||
builder: (context, me) => RideMap(origin: me, cameraTarget: me),
|
||||
),
|
||||
|
||||
SafeArea(
|
||||
child: Padding(
|
||||
padding: Space.page,
|
||||
child: Column(
|
||||
children: [
|
||||
BlocSelector<DutyCubit, DutyState, ({bool online, bool busy})>(
|
||||
selector: (s) => (online: s.isOnline, busy: s.busy),
|
||||
builder: (context, d) => DutyToggle(
|
||||
isOnline: d.online,
|
||||
busy: d.busy,
|
||||
onToggle: _cubit.toggleOnline,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Space.xs),
|
||||
BlocSelector<DutyCubit, DutyState, bool>(
|
||||
selector: (s) => s.creditBlocked,
|
||||
builder: (context, blocked) => blocked
|
||||
? StatusBanner(
|
||||
message: context.l10n.errorGeneric,
|
||||
tone: BannerTone.danger,
|
||||
icon: Icons.account_balance_wallet_outlined,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: BlocBuilder<DutyCubit, DutyState>(
|
||||
builder: (context, state) => _Sheet(state: state),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Sheet extends StatelessWidget {
|
||||
const _Sheet({required this.state});
|
||||
|
||||
final DutyState state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
|
||||
final child = switch (state.phase) {
|
||||
DutyPhase.offline => const SizedBox.shrink(),
|
||||
DutyPhase.waiting => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: Space.md),
|
||||
child: Text(
|
||||
state.error == DutyError.offerTaken
|
||||
? l10n.driverOfferTaken
|
||||
: l10n.driverNoOffers,
|
||||
textAlign: TextAlign.center,
|
||||
style: context.texts.bodyMedium?.copyWith(
|
||||
color: context.colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
DutyPhase.offered => OfferSheet(offer: state.offer!),
|
||||
DutyPhase.active =>
|
||||
ActiveDutySheet(trip: state.trip!, busy: state.busy),
|
||||
};
|
||||
|
||||
if (state.phase == DutyPhase.offline) return const SizedBox.shrink();
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: context.colors.surface,
|
||||
borderRadius: Radii.sheetTop,
|
||||
),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: Space.page,
|
||||
child: AnimatedSize(
|
||||
duration: Motion.inScreen,
|
||||
curve: Motion.curve,
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../core/design/tokens.dart';
|
||||
import '../../../../core/design/tripz_colors.dart';
|
||||
import '../../../../core/design/typography.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/ui/tripz_button.dart';
|
||||
import '../../cubit/duty_cubit.dart';
|
||||
import '../../data/models/trip.dart';
|
||||
|
||||
/// الرحلة من طرف السائق: **زر واحد** يدفع آلة الحالات خطوة واحدة.
|
||||
/// السائق لا يختار الحالة التالية — الكيوبت يشتقّها (docs/38 §4).
|
||||
class ActiveDutySheet extends StatelessWidget {
|
||||
const ActiveDutySheet({super.key, required this.trip, required this.busy});
|
||||
|
||||
final Trip trip;
|
||||
final bool busy;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cubit = context.read<DutyCubit>();
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(_statusText(context), style: context.texts.titleMedium),
|
||||
if (trip.priceForDriver != null)
|
||||
Text(
|
||||
'${trip.priceForDriver} ${trip.currency}',
|
||||
style: numericStyle(context.texts.titleLarge).copyWith(
|
||||
color: context.tripzColors.success,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: Space.md),
|
||||
TripzButton.primary(
|
||||
label: _actionLabel(context, cubit),
|
||||
loading: busy,
|
||||
onPressed: cubit.nextStatus == null ? null : cubit.advanceTrip,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _statusText(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return switch (trip.status) {
|
||||
TripStatus.assigned || TripStatus.driverArriving => l10n.driverOnTheWay,
|
||||
TripStatus.driverArrived => l10n.tripDriverArrived,
|
||||
TripStatus.inProgress => l10n.tripInProgress,
|
||||
_ => l10n.tripCompleted,
|
||||
};
|
||||
}
|
||||
|
||||
String _actionLabel(BuildContext context, DutyCubit cubit) {
|
||||
final l10n = context.l10n;
|
||||
return switch (cubit.nextStatus) {
|
||||
TripStatus.driverArriving => l10n.driverOnTheWay,
|
||||
TripStatus.driverArrived => l10n.driverArrivedAction,
|
||||
TripStatus.inProgress => l10n.driverStartTrip,
|
||||
TripStatus.completed => l10n.driverEndTrip,
|
||||
_ => l10n.tripCompleted,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/design/tokens.dart';
|
||||
import '../../../../core/design/tripz_colors.dart';
|
||||
import '../../../../core/design/typography.dart';
|
||||
import '../../data/models/trip.dart';
|
||||
|
||||
/// بطاقة السائق ولوحة المركبة — أهم ما يبحث عنه الراكب في الشارع، فيأخذ
|
||||
/// أوضح موضع وأكبر تباين.
|
||||
class DriverBadge extends StatelessWidget {
|
||||
const DriverBadge({super.key, required this.trip});
|
||||
|
||||
final Trip trip;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (trip.driverName == null) return const SizedBox.shrink();
|
||||
return Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: context.colors.primaryContainer,
|
||||
child: Icon(
|
||||
Icons.person_rounded,
|
||||
color: context.colors.onPrimaryContainer,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Space.sm),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(trip.driverName!, style: context.texts.titleSmall),
|
||||
if (trip.vehicleModel != null)
|
||||
Text(
|
||||
trip.vehicleModel!,
|
||||
style: context.texts.bodySmall?.copyWith(
|
||||
color: context.colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
if (trip.driverRating != null)
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.star_rounded,
|
||||
size: Sizes.iconSm,
|
||||
color: context.tripzColors.warning,
|
||||
),
|
||||
const SizedBox(width: Space.xxs),
|
||||
Text(
|
||||
trip.driverRating!,
|
||||
style: numericStyle(context.texts.bodySmall),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trip.vehiclePlate != null) _Plate(plate: trip.vehiclePlate!),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// لوحة مرسومة لا نصّ عادي — تُقرأ من بعيد ومن زاوية.
|
||||
class _Plate extends StatelessWidget {
|
||||
const _Plate({required this.plate});
|
||||
|
||||
final String plate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: Space.sm,
|
||||
vertical: Space.xxs,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: Radii.field_,
|
||||
border: Border.all(color: context.colors.outline, width: 1.5),
|
||||
color: context.tripzColors.surfaceRaised,
|
||||
),
|
||||
child: Text(
|
||||
plate,
|
||||
textDirection: TextDirection.ltr,
|
||||
style: numericStyle(context.texts.titleMedium).copyWith(
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/design/tokens.dart';
|
||||
import '../../../../core/design/tripz_colors.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
|
||||
/// مفتاح الاتصال — أهم عنصر في تطبيق السائق، فيأخذ أعلى الشاشة وأوضح تباين.
|
||||
/// الحالة معروضة نصّاً ولوناً معاً: لا يعتمد السائق على لون وحده وهو يقود.
|
||||
class DutyToggle extends StatelessWidget {
|
||||
const DutyToggle({
|
||||
super.key,
|
||||
required this.isOnline,
|
||||
required this.busy,
|
||||
required this.onToggle,
|
||||
});
|
||||
|
||||
final bool isOnline;
|
||||
final bool busy;
|
||||
final VoidCallback onToggle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final colors = context.tripzColors;
|
||||
final color = isOnline ? colors.success : context.colors.onSurfaceVariant;
|
||||
|
||||
return Material(
|
||||
color: context.tripzColors.surfaceRaised,
|
||||
borderRadius: Radii.card_,
|
||||
child: InkWell(
|
||||
onTap: busy ? null : onToggle,
|
||||
borderRadius: Radii.card_,
|
||||
child: Padding(
|
||||
padding: Space.page,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
||||
),
|
||||
const SizedBox(width: Space.sm),
|
||||
Expanded(
|
||||
child: Text(
|
||||
isOnline ? l10n.driverOnline : l10n.driverOffline,
|
||||
style: context.texts.titleMedium?.copyWith(color: color),
|
||||
),
|
||||
),
|
||||
if (busy)
|
||||
const SizedBox(
|
||||
width: Sizes.iconSm,
|
||||
height: Sizes.iconSm,
|
||||
child: CircularProgressIndicator(strokeWidth: 2.2),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
isOnline ? l10n.driverGoOffline : l10n.driverGoOnline,
|
||||
style: context.texts.labelLarge?.copyWith(
|
||||
color: context.colors.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../core/design/tokens.dart';
|
||||
import '../../../../core/design/tripz_colors.dart';
|
||||
import '../../../../core/design/typography.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/ui/tripz_button.dart';
|
||||
import '../../cubit/duty_cubit.dart';
|
||||
import '../../data/models/trip.dart';
|
||||
|
||||
/// عرض رحلة: **رقم الأرباح أولاً**، ثم العناوين، ثم الأزرار. السائق يقرّر
|
||||
/// في ثوانٍ وهو خلف المقود — الترتيب هنا ليس ذوقاً.
|
||||
///
|
||||
/// شريط المؤقّت ينفد فيختفي العرض تلقائياً (`dismissOffer` في الكيوبت).
|
||||
class OfferSheet extends StatefulWidget {
|
||||
const OfferSheet({super.key, required this.offer});
|
||||
|
||||
final Trip offer;
|
||||
|
||||
@override
|
||||
State<OfferSheet> createState() => _OfferSheetState();
|
||||
}
|
||||
|
||||
class _OfferSheetState extends State<OfferSheet>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _timer = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 25),
|
||||
)..forward();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final cubit = context.read<DutyCubit>();
|
||||
final offer = widget.offer;
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
animation: _timer,
|
||||
builder: (context, _) => LinearProgressIndicator(
|
||||
value: 1 - _timer.value,
|
||||
minHeight: 3,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: Space.md),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(l10n.driverOfferTitle, style: context.texts.titleMedium),
|
||||
if (offer.priceForDriver != null)
|
||||
Text(
|
||||
'${offer.priceForDriver} ${offer.currency}',
|
||||
style: numericStyle(context.texts.headlineSmall).copyWith(
|
||||
color: context.tripzColors.success,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: Space.md),
|
||||
_AddressRow(
|
||||
color: context.tripzColors.mapOrigin,
|
||||
label: l10n.rideOrigin,
|
||||
),
|
||||
_AddressRow(
|
||||
color: context.tripzColors.mapDestination,
|
||||
label: l10n.rideDestination,
|
||||
),
|
||||
const SizedBox(height: Space.lg),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TripzButton.secondary(
|
||||
label: l10n.driverReject,
|
||||
expanded: true,
|
||||
onPressed: cubit.dismissOffer,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: Space.sm),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: TripzButton.primary(
|
||||
label: l10n.driverAccept,
|
||||
onPressed: cubit.acceptOffer,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AddressRow extends StatelessWidget {
|
||||
const _AddressRow({required this.color, required this.label});
|
||||
|
||||
final Color color;
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: Space.xxs),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
|
||||
),
|
||||
const SizedBox(width: Space.sm),
|
||||
Text(label, style: context.texts.bodyMedium),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intaleq_maps/intaleq_maps.dart' as im;
|
||||
|
||||
import '../../../../core/config.dart';
|
||||
import '../../../../core/design/tripz_colors.dart';
|
||||
import '../../data/models/geo_point.dart';
|
||||
import '../../data/models/route_info.dart';
|
||||
|
||||
/// الخريطة — **الطبقة الوحيدة التي تعرف `intaleq_maps`**. ما فوقها يتعامل
|
||||
/// مع `GeoPoint` وحده، فتبديل محرّك الخريطة لاحقاً لا يلمس منطقاً.
|
||||
///
|
||||
/// البلاطات تُجلب مباشرة من map-saas بمفتاح مقيّد ببصمة التطبيق
|
||||
/// (قرار 2026-07-20).
|
||||
class RideMap extends StatefulWidget {
|
||||
const RideMap({
|
||||
super.key,
|
||||
this.origin,
|
||||
this.destination,
|
||||
this.driver,
|
||||
this.route,
|
||||
this.cameraTarget,
|
||||
this.onCameraIdle,
|
||||
});
|
||||
|
||||
final GeoPoint? origin;
|
||||
final GeoPoint? destination;
|
||||
final GeoPoint? driver;
|
||||
final RouteInfo? route;
|
||||
final GeoPoint? cameraTarget;
|
||||
|
||||
/// مركز الخريطة عند استقرارها — يغذّي اختيار النقطة بالدبّوس الثابت.
|
||||
final ValueChanged<GeoPoint>? onCameraIdle;
|
||||
|
||||
@override
|
||||
State<RideMap> createState() => _RideMapState();
|
||||
}
|
||||
|
||||
class _RideMapState extends State<RideMap> {
|
||||
im.IntaleqMapController? _controller;
|
||||
im.LatLng? _center;
|
||||
|
||||
static const _fallback = im.LatLng(31.9539, 35.9106); // عمّان
|
||||
|
||||
@override
|
||||
void didUpdateWidget(RideMap old) {
|
||||
super.didUpdateWidget(old);
|
||||
final target = widget.cameraTarget;
|
||||
if (target != null && target != old.cameraTarget) {
|
||||
_controller?.animateCamera(
|
||||
im.CameraUpdate.newLatLng(im.LatLng(target.lat, target.lng)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = context.tripzColors;
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return im.IntaleqMap(
|
||||
apiKey: AppConfig.mapApiKey,
|
||||
initialCameraPosition: im.CameraPosition(
|
||||
target: widget.origin == null
|
||||
? _fallback
|
||||
: im.LatLng(widget.origin!.lat, widget.origin!.lng),
|
||||
zoom: 15,
|
||||
),
|
||||
// الخريطة تبدّل ستايلها مع الثيم — خريطة نهارية في وضع ليلي تكسر
|
||||
// الغرض (docs/26 §2).
|
||||
styleUrl: isDark
|
||||
? im.IntaleqStyles.obsidian(AppConfig.mapApiKey)
|
||||
: im.IntaleqStyles.light(AppConfig.mapApiKey),
|
||||
myLocationEnabled: true,
|
||||
compassEnabled: false,
|
||||
zoomControlsEnabled: false,
|
||||
onMapCreated: (c) => _controller = c,
|
||||
onCameraMove: (position) => _center = position.target,
|
||||
onCameraIdle: () {
|
||||
final c = _center;
|
||||
if (c != null) widget.onCameraIdle?.call(GeoPoint(c.latitude, c.longitude));
|
||||
},
|
||||
markers: {
|
||||
if (widget.origin != null)
|
||||
_marker('origin', widget.origin!),
|
||||
if (widget.destination != null)
|
||||
_marker('destination', widget.destination!),
|
||||
if (widget.driver != null) _marker('driver', widget.driver!),
|
||||
},
|
||||
polylines: {
|
||||
if (widget.route != null && widget.route!.encodedPoints.isNotEmpty)
|
||||
im.Polyline(
|
||||
polylineId: const im.PolylineId('route'),
|
||||
points: im.PolylineUtils.decode(widget.route!.encodedPoints),
|
||||
color: colors.mapRoute,
|
||||
width: 5,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
im.Marker _marker(String id, GeoPoint p) => im.Marker(
|
||||
markerId: im.MarkerId(id),
|
||||
position: im.LatLng(p.lat, p.lng),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user