## تصحيح بنيوي أولاً
بنية المرحلة 1 كانت تخالف docs/23 §1 المُلزِم. أُعيدت للشجرة المفروضة
حرفياً: app.dart في الجذر · core/{config,build_config,di,router}.dart ·
core/{design,ui,l10n,api,storage,session}/ · features/<f>/{cubit,data,view}/
## المرحلة 2 — نظام التصميم (docs/26)
- core/design: tokens (مسافات/زوايا/حركة/أحجام — الشاشة لا تخترع رقماً) ·
typography (IBM Plex Sans Arabic + Inter محليّان، بأرقام tabular للأسعار
والعدّادات) · TripzColors كـThemeExtension للأدوار الدلالية ·
buildTheme(brightness, locale) بمدخلين لا ثالث لهما
- core/ui: 11 مكوّناً. TripzScaffold يحوّل status الـCubit وحده إلى
skeleton/خطأ/فراغ/محتوى — فلا تكتب أي شاشة if (loading)
- core/l10n: ARB عربي/إنجليزي + gen_l10n. لا نص مرئي داخل widget
- SettingsCubit: المظهر واللغة. الاتجاه يتبع اللغة آلياً بلا Directionality
مفروضة، وسقف تكبير النص 1.3
## المرحلة 3 — المصادقة
- طبقة الشبكة: تجديد استباقي بطلقة واحدة (عمر التوكن 15 دقيقة) ·
x-app-role · x-device-id من device_info_plus — يُرسَل الآن كي يُفعَّل علم
الخادم لاحقاً بلا تعديل التطبيق
- SessionCubit في core/session خلف واجهة SessionSource: الجلسة حالة على
مستوى التطبيق لا ميزة، و core لا يستورد من features
- LoginCubit بخطواته الخمس، ProfileCubit، وست شاشات:
الشروط ← إذن الموقع ← الهاتف ← الرمز ← إكمال الملف ← هيكل الرئيسية
من سيرو نُقل السلوك لا الكود: بوابتان قبل أي حقل إدخال · إعادة فحص الإذن عند
العودة من إعدادات النظام · تحقّق الهاتف الثلاثي. وأُضيف ما ينقصه: عدّاد إعادة
إرسال الرمز — بدونه تُحظر ثلاث ضغطات المستخدمَ خمس دقائق (docs/38 §2).
قراران موثّقان في docs/37: لا packages/tripz_ui (الوثيقتان المُلزِمتان تفرضان
core/design و core/ui داخل التطبيق)، والـCubit يُصدر رمز فشل لا نصّاً
(يجمع بين docs/23 §3 و docs/26 §4).
flutter analyze نظيف في التطبيقين · 48 ملف و3,140 سطر لكل تطبيق · الفرق
بينهما أربعة ملفات فقط: build_config · config · ملفّا ARB.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
86 lines
2.6 KiB
Dart
86 lines
2.6 KiB
Dart
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/ui/tripz_button.dart';
|
|
import '../../../core/ui/tripz_scaffold.dart';
|
|
import '../../../core/ui/tripz_text_field.dart';
|
|
import '../cubit/profile_cubit.dart';
|
|
import '../../../core/session/session_cubit.dart';
|
|
import 'widgets/auth_failure_text.dart';
|
|
import 'widgets/auth_header.dart';
|
|
|
|
class ProfilePage extends StatefulWidget {
|
|
const ProfilePage({super.key});
|
|
|
|
@override
|
|
State<ProfilePage> createState() => _ProfilePageState();
|
|
}
|
|
|
|
class _ProfilePageState extends State<ProfilePage> {
|
|
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),
|
|
AuthHeader(
|
|
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);
|
|
}
|
|
}
|