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,102 @@
|
||||
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/session/session_cubit.dart';
|
||||
|
||||
import '../../../core/ui/tripz_button.dart';
|
||||
|
||||
import '../../../core/ui/tripz_scaffold.dart';
|
||||
|
||||
import '../../../core/ui/tripz_text_field.dart';
|
||||
|
||||
import '../cubit/profile_cubit.dart';
|
||||
|
||||
/// تعديل الاسم. **الرقم لا يُعدَّل**: هو هوية الحساب على الخادم، وتغييره
|
||||
/// يعني حساباً آخر (docs/38 §1) — فيُعرض معطّلاً مع سبب واضح لا مخفياً.
|
||||
class ProfileEditPage extends StatefulWidget {
|
||||
const ProfileEditPage({super.key});
|
||||
|
||||
@override
|
||||
State<ProfileEditPage> createState() => _ProfileEditPageState();
|
||||
}
|
||||
|
||||
class _ProfileEditPageState extends State<ProfileEditPage> {
|
||||
late final TextEditingController _name;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_name = TextEditingController(
|
||||
text: sl<SessionCubit>().state.user?.name ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_name.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return BlocProvider(
|
||||
create: (_) => ProfileCubit(sl()),
|
||||
child: BlocBuilder<ProfileCubit, ProfileState>(
|
||||
builder: (context, state) {
|
||||
final user = context.watch<SessionCubit>().state.user;
|
||||
return TripzScaffold(
|
||||
title: l10n.profileEditTitle,
|
||||
bottomAction: TripzButton.primary(
|
||||
label: l10n.actionSave,
|
||||
loading: state.saving,
|
||||
onPressed: () => _save(context),
|
||||
),
|
||||
child: ListView(
|
||||
children: [
|
||||
TripzTextField(
|
||||
controller: _name,
|
||||
label: l10n.profileNameLabel,
|
||||
enabled: !state.saving,
|
||||
),
|
||||
const SizedBox(height: Space.md),
|
||||
TripzTextField(
|
||||
controller: TextEditingController(text: user?.phone ?? ''),
|
||||
label: l10n.profilePhone,
|
||||
enabled: false,
|
||||
numeric: true,
|
||||
),
|
||||
const SizedBox(height: Space.xxs),
|
||||
Text(
|
||||
l10n.profilePhoneLocked,
|
||||
style: context.texts.bodySmall?.copyWith(
|
||||
color: context.colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _save(BuildContext context) async {
|
||||
final l10n = context.l10n;
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
final session = context.read<SessionCubit>();
|
||||
final user = await context.read<ProfileCubit>().save(_name.text);
|
||||
if (user == null) return;
|
||||
session.onProfileCompleted(user);
|
||||
messenger.showSnackBar(SnackBar(content: Text(l10n.profileSaved)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../core/design/tokens.dart';
|
||||
|
||||
import '../../../core/di.dart';
|
||||
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
|
||||
import '../../../core/session/session_cubit.dart';
|
||||
|
||||
import '../../../core/ui/failure_text.dart';
|
||||
|
||||
import '../../../core/ui/tripz_button.dart';
|
||||
|
||||
import '../../../core/ui/tripz_scaffold.dart';
|
||||
|
||||
import '../../../core/ui/tripz_text_field.dart';
|
||||
|
||||
import '../../../core/ui/form_header.dart';
|
||||
|
||||
import '../cubit/profile_cubit.dart';
|
||||
|
||||
class ProfileSetupPage extends StatefulWidget {
|
||||
const ProfileSetupPage({super.key});
|
||||
|
||||
@override
|
||||
State<ProfileSetupPage> createState() => _ProfileSetupPageState();
|
||||
}
|
||||
|
||||
class _ProfileSetupPageState extends State<ProfileSetupPage> {
|
||||
final _name = TextEditingController();
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_name.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return BlocProvider(
|
||||
create: (_) => ProfileCubit(sl()),
|
||||
child: BlocBuilder<ProfileCubit, ProfileState>(
|
||||
builder: (context, state) {
|
||||
return TripzScaffold(
|
||||
showAppBar: false,
|
||||
bottomAction: TripzButton.primary(
|
||||
label: l10n.actionSave,
|
||||
loading: state.saving,
|
||||
onPressed: () => _submit(context),
|
||||
),
|
||||
child: ListView(
|
||||
children: [
|
||||
const SizedBox(height: Space.xl),
|
||||
FormHeader(
|
||||
icon: Icons.person_outline_rounded,
|
||||
title: l10n.profileTitle,
|
||||
lead: l10n.profileLead,
|
||||
),
|
||||
const SizedBox(height: Space.lg),
|
||||
TripzTextField(
|
||||
controller: _name,
|
||||
label: l10n.profileNameLabel,
|
||||
autofocus: true,
|
||||
enabled: !state.saving,
|
||||
errorText: _error,
|
||||
textInputAction: TextInputAction.done,
|
||||
autofillHints: const [AutofillHints.name],
|
||||
onChanged: (_) => setState(() => _error = null),
|
||||
onSubmitted: (_) => _submit(context),
|
||||
),
|
||||
if (state.failure != null)
|
||||
AuthFailureText(failure: state.failure!),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _submit(BuildContext context) async {
|
||||
if (_name.text.trim().isEmpty) {
|
||||
setState(() => _error = context.l10n.profileNameErrEmpty);
|
||||
return;
|
||||
}
|
||||
final session = context.read<SessionCubit>();
|
||||
final user = await context.read<ProfileCubit>().save(_name.text);
|
||||
if (user != null) session.onProfileCompleted(user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user