feat(apps): الدراور وطبقتا الميزات والإشعارات — المرحلة 6
## طبقتا الميزات مُطبَّقتان معاً
AppDrawer يفحص: Features.wallet && context.tenantHas('wallet')
- Features.x ثابت const: يقرّر ما يُبنى في الـbinary. إطفاؤه يحذف الكود
فلا يُستخرج (docs/23 §5)
- tenantHas من GET /tenant/config/:slug: يقرّر ما يُعرض ممّا بُني حسب اشتراك
المستأجر (docs/38 §10)
هذا هو ربط lite/pro/max عملياً. TenantCubit يعرض النسخة المخزّنة فوراً ثم
يحدّثها: إقلاع بلا إنترنت يعرض الميزات المعروفة آخر مرة لا شاشة فارغة.
## الشاشات
الدراور · تعديل الحساب · سجلّ الرحلات · الإعدادات (مظهر + لغة) · المساعدة.
الرقم في تعديل الحساب معطّل مع سبب معروض لا مخفي: هو هوية الحساب على الخادم
وتغييره يعني حساباً آخر (docs/38 §1).
## الإشعارات
PushService معزول — الملف الوحيد الذي يعرف Firebase. التسجيل بعد إثبات
الجلسة عبر خطّاف في SessionCubit، ومع اشتراك onTokenRefresh: بدونه تتوقّف
الإشعارات بصمت بعد أسابيع. الإعداد الأصلي كان جاهزاً مسبقاً.
## تصحيحات بنيوية كشفها فحص آلي
docs/23 §1 يمنع أن تستورد ميزة من أخرى — وكانت خمس مخالفات:
1. features/history أُدمجت في features/trip — السجلّ جزء من ميزة الرحلة
2. AppDrawer صعد إلى core/ui — هيكل تطبيق لا ميزة
3. AuthFailure → core/api/api_failure.dart، ومترجمه → core/ui/failure_text.dart
4. AuthHeader → core/ui/form_header.dart
5. ProfileRepository مستقلّ عن AuthRepository: تعديل الملف ليس مصادقة
flutter analyze نظيف · الراكب 98 ملف/7,497 سطر · السائق 95 ملف/6,931 سطر.
فحوص آلية نظيفة: صفر استيراد بين ميزتين · core يستورد features من di و
router وحدهما · Firebase و intaleq_maps و geolocator و socket_io كلٌّ معزول.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
66e28acc58
commit
096acae74e
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../core/api/api_exception.dart';
|
||||
|
||||
import '../../../core/api/api_failure.dart';
|
||||
|
||||
import '../../../core/session/app_user.dart';
|
||||
|
||||
import '../../../core/ui/view_status.dart';
|
||||
|
||||
import '../data/profile_repository.dart';
|
||||
|
||||
class ProfileState {
|
||||
const ProfileState({
|
||||
this.status = ViewStatus.success,
|
||||
this.saving = false,
|
||||
this.failure,
|
||||
this.user,
|
||||
});
|
||||
|
||||
final ViewStatus status;
|
||||
final bool saving;
|
||||
final AuthFailure? failure;
|
||||
final AppUser? user;
|
||||
|
||||
ProfileState copyWith({
|
||||
ViewStatus? status,
|
||||
bool? saving,
|
||||
AuthFailure? failure,
|
||||
AppUser? user,
|
||||
bool clearFailure = false,
|
||||
}) {
|
||||
return ProfileState(
|
||||
status: status ?? this.status,
|
||||
saving: saving ?? this.saving,
|
||||
failure: clearFailure ? null : (failure ?? this.failure),
|
||||
user: user ?? this.user,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// إكمال الملف بعد أول دخول. عقد الخادم يقبل `{ name, language }` فقط
|
||||
/// (docs/38 §3) — لا اسم أول/أخير ولا بريد كما في سيرو (docs/39 §2).
|
||||
class ProfileCubit extends Cubit<ProfileState> {
|
||||
ProfileCubit(this._repo) : super(const ProfileState());
|
||||
|
||||
final ProfileRepository _repo;
|
||||
|
||||
Future<AppUser?> save(String name) async {
|
||||
emit(state.copyWith(saving: true, clearFailure: true));
|
||||
try {
|
||||
final user = await _repo.update(name: name.trim());
|
||||
emit(state.copyWith(saving: false, user: user));
|
||||
return user;
|
||||
} on ApiException catch (e) {
|
||||
emit(state.copyWith(saving: false, failure: e.toAuthFailure()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user