## البحث لم يكن يستجيب — غلافان مختلفان
مثبت بـcurl: /geocoding/search يرجّع {"results":[…]} بينما /geocoding/reverse
يرجّع مصفوفة عارية. افترضتُ كليهما مصفوفة، فكان البحث يفشل صامتاً — ولهذا
«تحديد من الخريطة» يعمل (يستعمل reverse) والبحث لا. أُضيفت رسالة «لا نتائج»
كي لا يبقى الفراغ غامضاً، وأيقونة لكل صنف مكان.
## المحفظة صارت دفعاً حقيقياً لا كاش-إن
كنت أستعمل POST /wallet/topup — وهو بوصف الخادم كاش-إن تجريبي يزيد الرصيد
بلا دفع. المسار الصحيح موجود أصلاً: POST /payments/charge مع provider
وpurpose، وسجلّ بوابات فيه cash · paymob · syriatel · mtn ومحوّل فاتورة
لـ cliq · shamcash · zaincash.
كليك وشام كاش وزين كاش تعمل بنمط **الفاتورة** — نفس ما يفعله سيرو حرفياً
(create_cliq_invoice.php): الخادم يولّد مرجعاً ويعرض حساب الاستلام، ويحوّل
المستخدم، والتسوية تصل لاحقاً بمطابقة رسالة المزوّد. لا بوابة تحويل حيّة.
- InvoiceSheet يعرض المرجع وحساب الاستلام بزرّي نسخ — الرقم يُحوَّل في تطبيق
بنك آخر فالنسخ ليس رفاهية
- يُقال صراحةً أن الرصيد لا يزيد الآن، قبل الضغط لا بعده
- حساب استلام غير مضبوط للمستأجر يُعرض كخطأ لا كتعليمات ناقصة
- أسماء المزوّدين صُحّحت لتطابق PaymentGatewayRegistry حرفياً (syriatel لا
syriatel_cash…) — أي اسم آخر يرجّع 400
- qi_card حُذف: لا محوّل له على الخادم
- السائق: chargeCredit بنيّة credit_topup للرصيد التشغيلي
## الخريطة وواجهة «إلى أين»
- أسماء البداية والنهاية تُرسم فوق الخريطة (نمط سيرو) كطبقة فلاتر لا marker
- البطاقة المطوية صارت حقل بحث بارزاً مع الموقع الحالي فوقه
- حقل البحث يفتح مركّزاً مع زرّ مسح
## أداة
tool/sync_from_rider.sh كان يستثني ملفَّي ARB فيُسقط كل مفتاح مشترك جديد
ويكسر بناء السائق — تكرّر ثلاث مرات. صارا يُنسخان ثم تُفرض نصوص السائق فوقهما.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
349 lines
11 KiB
Dart
349 lines
11 KiB
Dart
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/app_drawer.dart';
|
|
import '../../../core/ui/status_banner.dart';
|
|
import '../../../core/ui/tripz_button.dart';
|
|
import '../cubit/ride_cubit.dart';
|
|
import '../cubit/ride_state.dart';
|
|
import '../data/models/geo_point.dart';
|
|
import 'widgets/active_trip_sheet.dart';
|
|
import 'widgets/center_pin.dart';
|
|
import 'widgets/confirm_sheet.dart';
|
|
import 'widgets/planner_sheet.dart';
|
|
import 'widgets/ride_map.dart';
|
|
import 'widgets/searching_sheet.dart';
|
|
|
|
/// شاشة الراكب: خريطة ثابتة + ورقة سفلية تتبدّل بالمرحلة (docs/39 §3).
|
|
///
|
|
/// الخريطة **لا تُعاد بناؤها** عند تبدّل الورقة: هي خارج الـ`BlocBuilder`
|
|
/// الذي يبني الورقة، ولها `BlocSelector` خاص بما تحتاجه وحدها. هذا هو الفرق
|
|
/// بين خريطة سلسة وأخرى تهتزّ عند كل تحديث حالة.
|
|
class RidePage extends StatefulWidget {
|
|
const RidePage({super.key});
|
|
|
|
@override
|
|
State<RidePage> createState() => _RidePageState();
|
|
}
|
|
|
|
class _RidePageState extends State<RidePage> with WidgetsBindingObserver {
|
|
late final RideCubit _cubit = sl<RideCubit>()..init();
|
|
GeoPoint? _mapCenter;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addObserver(this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
_cubit.close();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void didChangeAppLifecycleState(AppLifecycleState lifecycle) {
|
|
// الإذن قد يُمنح من إعدادات النظام والتطبيق في الخلفية — نلتقطه عند
|
|
// العودة بدل أن تبقى الخريطة على الموقع الاحتياطي.
|
|
if (lifecycle == AppLifecycleState.resumed && _cubit.state.origin == null) {
|
|
_cubit.locateMe();
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider.value(
|
|
value: _cubit,
|
|
child: Scaffold(
|
|
drawer: const AppDrawer(),
|
|
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,
|
|
),
|
|
),
|
|
|
|
// ── دبّوس الاختيار ─────────────────────────────────────────
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
// ── الورقة السفلية ─────────────────────────────────────────
|
|
Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: BlocBuilder<RideCubit, RideState>(
|
|
builder: (context, state) => _Sheet(
|
|
state: state,
|
|
onConfirmPick: () {
|
|
final center = _mapCenter;
|
|
if (center != null) _cubit.confirmMapPick(center);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// ما تحتاجه الخريطة وحدها — تغيّرُ أي شيء آخر في الحالة لا يعيد بناءها.
|
|
class _MapData {
|
|
const _MapData({
|
|
this.origin,
|
|
this.destination,
|
|
this.driver,
|
|
this.route,
|
|
this.camera,
|
|
this.originLabel = '',
|
|
this.destinationLabel = '',
|
|
});
|
|
|
|
final GeoPoint? origin;
|
|
final GeoPoint? destination;
|
|
final GeoPoint? driver;
|
|
final dynamic route;
|
|
final GeoPoint? camera;
|
|
final String originLabel;
|
|
final String destinationLabel;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is _MapData &&
|
|
other.origin == origin &&
|
|
other.destination == destination &&
|
|
other.driver == driver &&
|
|
other.route == route &&
|
|
other.camera == camera &&
|
|
other.originLabel == originLabel &&
|
|
other.destinationLabel == destinationLabel;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
origin,
|
|
destination,
|
|
driver,
|
|
route,
|
|
camera,
|
|
originLabel,
|
|
destinationLabel,
|
|
);
|
|
}
|
|
|
|
class _Sheet extends StatelessWidget {
|
|
const _Sheet({required this.state, required this.onConfirmPick});
|
|
|
|
final RideState state;
|
|
final VoidCallback onConfirmPick;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final child = switch (state.phase) {
|
|
RidePhase.idle => _Collapsed(
|
|
noLocation: state.error == RideError.noLocation,
|
|
originLabel: state.originLabel,
|
|
),
|
|
RidePhase.planning => PlannerSheet(state: state),
|
|
RidePhase.pickingOnMap => _PickConfirm(onConfirm: onConfirmPick),
|
|
RidePhase.confirming => ConfirmSheet(state: state),
|
|
RidePhase.searching => const SearchingSheet(),
|
|
RidePhase.active => ActiveTripSheet(trip: state.trip!),
|
|
};
|
|
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// زر دائري فوق الخريطة — سطح مرتفع كي يُقرأ فوق أي لون بلاطة.
|
|
class _MapFab extends StatelessWidget {
|
|
const _MapFab({required this.icon, required this.onTap});
|
|
|
|
final IconData icon;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Align(
|
|
alignment: AlignmentDirectional.topStart,
|
|
child: Material(
|
|
color: context.tripzColors.surfaceRaised,
|
|
shape: const CircleBorder(),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: EdgeInsets.all(Space.sm),
|
|
child: Icon(icon, size: Sizes.icon),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// البطاقة المطوية — واجهة «إلى أين؟».
|
|
///
|
|
/// حقل بحث حقيقي لا زرّ يفتح شاشة: الراكب يبدأ الكتابة فوراً. وموقعه الحالي
|
|
/// معروض فوقه كي يتأكّد أن نقطة البداية صحيحة قبل أن يفكّر في الوجهة.
|
|
class _Collapsed extends StatelessWidget {
|
|
const _Collapsed({required this.noLocation, required this.originLabel});
|
|
|
|
final bool noLocation;
|
|
final String originLabel;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final cubit = context.read<RideCubit>();
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// بلا موقع لا خريطة مفيدة — السبب يُعرض مع مخرجه بدل خريطة صامتة
|
|
// على موقع خاطئ.
|
|
if (noLocation) ...[
|
|
StatusBanner(
|
|
message: context.l10n.rideNoLocation,
|
|
tone: BannerTone.warning,
|
|
icon: Icons.location_off_outlined,
|
|
trailing: TripzButton.text(
|
|
label: context.l10n.actionRetry,
|
|
onPressed: cubit.locateMe,
|
|
),
|
|
),
|
|
const SizedBox(height: Space.sm),
|
|
],
|
|
if (originLabel.isNotEmpty) ...[
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 10,
|
|
height: 10,
|
|
decoration: BoxDecoration(
|
|
color: context.tripzColors.mapOrigin,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
const SizedBox(width: Space.xs),
|
|
Expanded(
|
|
child: Text(
|
|
originLabel,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: context.texts.bodySmall?.copyWith(
|
|
color: context.colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: Space.sm),
|
|
],
|
|
// حقل بحث لا زرّ: الضغط عليه يفتح المخطّط والكيبورد معاً.
|
|
Material(
|
|
color: context.colors.surfaceContainerHighest,
|
|
borderRadius: Radii.card_,
|
|
child: InkWell(
|
|
onTap: cubit.openPlanner,
|
|
borderRadius: Radii.card_,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: Space.md,
|
|
vertical: Space.sm,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.search_rounded, color: context.colors.primary),
|
|
const SizedBox(width: Space.sm),
|
|
Expanded(
|
|
child: Text(
|
|
context.l10n.rideWhereTo,
|
|
style: context.texts.titleMedium?.copyWith(
|
|
color: context.colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _PickConfirm extends StatelessWidget {
|
|
const _PickConfirm({required this.onConfirm});
|
|
|
|
final VoidCallback onConfirm;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TripzButton.primary(
|
|
label: context.l10n.rideConfirmPoint,
|
|
onPressed: onConfirm,
|
|
);
|
|
}
|
|
}
|