## التقييم مفروض لا اختياري
SessionCubit يفحص GET /trips/rating/pending بعد إثبات الجلسة، ووجود رحلة
معلّقة يحجز التطبيق كله عند /rating حتى تُحسم. دور المستخدم في الرحلة يأتي
من الخادم لا من نوع التطبيق — نفس الرقم قد يكون له حسابان (docs/38 §1).
التقييم المزدوج يرجّع 400، وهو نجاح من منظور المستخدم: الرحلة مُقيَّمة فعلاً
فلا يُحبس في شاشة بلا مخرج.
الجلسة تحتاج معرفة التقييم المعلّق، و core لا يجوز أن يستورد ميزة التقييم —
فأُضيفت الطريقة لواجهة SessionSource ونفّذها AuthRepository.
## core/format/money.dart
كل المبالغ تصل نصوصاً ("0.000")؛ التحويل والعرض من نقطة واحدة. عدد المنازل
من العملة (JOD ثلاث)، والعملة من إعداد المستأجر لا من ثابت في التطبيق.
## المحفظتان لا تُوحَّدان
- الراكب WalletPage: رصيد + شحن = التزام على المنصّة
- السائق EarningsPage: أرباح + سحب = إيراد له
شكلهما متقارب وحسابهما مختلف؛ دمجهما خطأ محاسبي لا اختصار (docs/39 §4).
## السحب بخطوتين
request يرسل رمزاً بلا خصم، و confirm هو ما يخصم ويحجز. شاشة سيرو كانت خطوة
واحدة ولم تُقلَّد. الرمز الخاطئ لا يُرجع المستخدم لخطوة المبلغ.
الرصيد التشغيلي معروض منفصلاً عن الأرباح: منه تُخصم العمولة ونفاده يوقف
وصول الطلبات — خلطه بالأرباح يخفي سبب توقّف العمل عن السائق.
FareSummary يعرض رقم كلّ طرف: price_for_passenger للراكب و price_for_driver
للسائق — حقلان منفصلان والفرق عمولة (docs/38 §4).
الإلغاء بتأكيد صريح مع سبب؛ السبب لا يقبله عقد الخادم بعد لكن السؤال يخفض
الإلغاء العرضي ويجهّز الحقل.
flutter analyze نظيف · الراكب 86 ملف/6,280 سطر · السائق 83 ملف/5,818 سطر.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
114 lines
3.7 KiB
Dart
114 lines
3.7 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/empty_view.dart';
|
|
import '../../../core/ui/tripz_button.dart';
|
|
import '../../../core/ui/tripz_scaffold.dart';
|
|
import '../../../core/ui/tripz_sheet.dart';
|
|
import '../../../core/ui/tripz_text_field.dart';
|
|
import '../cubit/wallet_cubit.dart';
|
|
import '../cubit/wallet_state.dart';
|
|
import 'widgets/balance_card.dart';
|
|
import 'widgets/txn_tile.dart';
|
|
|
|
/// محفظة الراكب — **رصيدٌ دفعه ولم يستهلكه**، أي التزامٌ على المنصّة.
|
|
/// شاشة السائق مختلفة عمداً (أرباح + سحب): لا تُوحَّدان (docs/39 §4).
|
|
class WalletPage extends StatefulWidget {
|
|
const WalletPage({super.key});
|
|
|
|
@override
|
|
State<WalletPage> createState() => _WalletPageState();
|
|
}
|
|
|
|
class _WalletPageState extends State<WalletPage> {
|
|
late final WalletCubit _cubit = sl<WalletCubit>()..load();
|
|
|
|
@override
|
|
void dispose() {
|
|
_cubit.close();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = context.l10n;
|
|
return BlocProvider.value(
|
|
value: _cubit,
|
|
child: BlocConsumer<WalletCubit, WalletState>(
|
|
listenWhen: (p, n) => p.action != n.action,
|
|
listener: (context, state) {
|
|
if (state.action == WalletAction.topupFailed) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(l10n.walletTopupFailed)),
|
|
);
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
return TripzScaffold(
|
|
title: l10n.walletTitle,
|
|
status: state.status,
|
|
error: state.error,
|
|
onRetry: _cubit.load,
|
|
child: ListView(
|
|
children: [
|
|
BalanceCard(
|
|
label: l10n.walletBalance,
|
|
balance: state.wallet?.balance,
|
|
currency: state.currency,
|
|
action: TripzButton.primary(
|
|
label: l10n.walletTopup,
|
|
loading: state.action == WalletAction.toppingUp,
|
|
onPressed: () => _openTopup(context),
|
|
),
|
|
),
|
|
const SizedBox(height: Space.lg),
|
|
Text(l10n.walletTransactions, style: context.texts.titleMedium),
|
|
const SizedBox(height: Space.xs),
|
|
if (state.transactions.isEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: Space.xl),
|
|
child: EmptyView(
|
|
icon: Icons.receipt_long_outlined,
|
|
message: l10n.walletEmpty,
|
|
),
|
|
)
|
|
else
|
|
for (final txn in state.transactions)
|
|
TxnTile(txn: txn, currency: state.currency),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void _openTopup(BuildContext context) {
|
|
final l10n = context.l10n;
|
|
final controller = TextEditingController();
|
|
TripzSheet.show(
|
|
context,
|
|
title: l10n.walletTopup,
|
|
child: TripzTextField(
|
|
controller: controller,
|
|
label: l10n.walletTopupAmount,
|
|
numeric: true,
|
|
autofocus: true,
|
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
|
),
|
|
bottomAction: TripzButton.primary(
|
|
label: l10n.walletTopup,
|
|
onPressed: () {
|
|
final amount = num.tryParse(controller.text.trim());
|
|
Navigator.of(context).pop();
|
|
if (amount != null) _cubit.topup(amount);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|