LifeMate — Personal, Family & Learning Companion
docs/offline-data-rescue-options
chore/phase1-repository-cleanup
deploy/stable-web-apk
deployment-static
design/mobile-accessibility-v2
design/mobile-navigation-review
docs/child-education-access-decision
docs/offline-data-rescue-options
docs/owner-guide-and-delivery-plan
docs/phase1-policy-options
docs/public-review-live-2026-10-15
feat/aparat-learning-library
feat/child-device-safety
feat/child-identity-schema
feat/flutter-mobile-navigation
feat/learning-content-operations
feat/local-signing-preflight
feat/online-family-stage0
feat/personal-encrypted-recovery
feat/private-planner-series-api
feat/public-review-page
feat/standalone-weekly-planner
feat/weekly-planner-android
final-feature-1/iran-family-school
fix/auth-abuse-expiry-safety
fix/auth-expiry-after-lock
fix/backend-request-safety
fix/lifeguide-bootstrap-naming-ci
fix/lifeguide-pages-qa-base-preflight
fix/lifeguide-qa-pages-env-deployment
fix/local-task-persistence
fix/managed-child-session-boundary
fix/personal-jalali-dates
fix/personal-notification-controls
fix/personal-upgrade-delivery-guard
fix/sms-approval-gates
fix/study-duration-display
infra/cloudflare-neon-migration
infra/lifeguide-cloudflare-qa
infra/lifeguide-github-pages-qa
infra/lifeguide-supabase-qa
main
phase-1/foundation-completion
phase-2/product-foundation-identity
phase-3/planner-school-family-core
phase-4/ai-learning-wellbeing
phase-5/hardening-observability-release
test/android-reminder-acceptance
test/personal-notification-settings
test/personal-recovery-acceptance
test/role-entry-apk
| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_localizations/flutter_localizations.dart'; |
| 3 | |
| 4 | import 'model.dart'; |
| 5 | import 'planner_ui.dart'; |
| 6 | import 'settings_ui.dart'; |
| 7 | import 'store.dart'; |
| 8 | |
| 9 | typedef StandaloneStoreOpener = Future<StandaloneStore> Function(); |
| 10 | typedef StandaloneReminderSettingsBuilder = Widget Function( |
| 11 | BuildContext context, StandaloneStore store); |
| 12 | |
| 13 | /// This entry point is intentionally independent from identity and HTTP APIs. |
| 14 | class StandaloneApp extends StatefulWidget { |
| 15 | const StandaloneApp({ |
| 16 | super.key, |
| 17 | required this.openStore, |
| 18 | this.reminderSettingsBuilder, |
| 19 | this.onPlansChanged, |
| 20 | this.onBeforePlansChange, |
| 21 | this.onResumed, |
| 22 | }); |
| 23 | |
| 24 | final StandaloneStoreOpener openStore; |
| 25 | final StandaloneReminderSettingsBuilder? reminderSettingsBuilder; |
| 26 | final Future<void> Function(StandaloneStore store)? onPlansChanged; |
| 27 | final Future<void> Function(StandaloneStore store)? onBeforePlansChange; |
| 28 | final Future<void> Function(StandaloneStore store)? onResumed; |
| 29 | |
| 30 | @override |
| 31 | State<StandaloneApp> createState() => _StandaloneAppState(); |
| 32 | } |
| 33 | |
| 34 | class _StandaloneAppState extends State<StandaloneApp> { |
| 35 | StandaloneStore? _store; |
| 36 | StandaloneProfile? _profile; |
| 37 | bool _loading = true; |
| 38 | bool _failed = false; |
| 39 | int _attempt = 0; |
| 40 | |
| 41 | @override |
| 42 | void initState() { |
| 43 | super.initState(); |
| 44 | _open(); |
| 45 | } |
| 46 | |
| 47 | Future<void> _open() async { |
| 48 | final attempt = ++_attempt; |
| 49 | setState(() { |
| 50 | _loading = true; |
| 51 | _failed = false; |
| 52 | }); |
| 53 | try { |
| 54 | final store = _store ?? await widget.openStore(); |
| 55 | if (!mounted || attempt != _attempt) return; |
| 56 | _store = store; |
| 57 | final profile = await store.profile(); |
| 58 | if (!mounted || attempt != _attempt) return; |
| 59 | setState(() { |
| 60 | _profile = profile; |
| 61 | _loading = false; |
| 62 | }); |
| 63 | } catch (_) { |
| 64 | if (!mounted || attempt != _attempt) return; |
| 65 | setState(() { |
| 66 | _loading = false; |
| 67 | _failed = true; |
| 68 | }); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | Future<void> _profileSaved() async { |
| 73 | final profile = await _store!.profile(); |
| 74 | if (mounted) setState(() => _profile = profile); |
| 75 | } |
| 76 | |
| 77 | @override |
| 78 | Widget build(BuildContext context) { |
| 79 | final seed = switch (_profile?.themeKey) { |
| 80 | 'blue' => const Color(0xff276e83), |
| 81 | 'mint' => const Color(0xff397b65), |
| 82 | 'coral' => const Color(0xffad5c4c), |
| 83 | _ => const Color(0xff76609a), |
| 84 | }; |
| 85 | final colors = ColorScheme.fromSeed( |
| 86 | seedColor: seed, |
| 87 | brightness: Brightness.light, |
| 88 | ); |
| 89 | return MaterialApp( |
| 90 | title: 'LifeGuide · برنامهٔ من', |
| 91 | debugShowCheckedModeBanner: false, |
| 92 | locale: const Locale('fa'), |
| 93 | supportedLocales: const [Locale('fa'), Locale('en')], |
| 94 | localizationsDelegates: const [ |
| 95 | GlobalMaterialLocalizations.delegate, |
| 96 | GlobalWidgetsLocalizations.delegate, |
| 97 | GlobalCupertinoLocalizations.delegate, |
| 98 | ], |
| 99 | theme: ThemeData( |
| 100 | useMaterial3: true, |
| 101 | fontFamily: 'LifeGuidePersian', |
| 102 | fontFamilyFallback: const ['LifeGuideLatin', 'LifeGuideEmoji'], |
| 103 | colorScheme: colors, |
| 104 | scaffoldBackgroundColor: colors.surface, |
| 105 | textTheme: const TextTheme( |
| 106 | bodySmall: TextStyle(fontSize: 13, height: 1.7), |
| 107 | bodyMedium: TextStyle(fontSize: 15, height: 1.7), |
| 108 | bodyLarge: TextStyle(fontSize: 16, height: 1.7), |
| 109 | labelSmall: TextStyle(fontSize: 12), |
| 110 | labelMedium: TextStyle(fontSize: 13), |
| 111 | labelLarge: TextStyle(fontSize: 14), |
| 112 | ), |
| 113 | inputDecorationTheme: InputDecorationTheme( |
| 114 | border: OutlineInputBorder(borderRadius: BorderRadius.circular(16)), |
| 115 | filled: true, |
| 116 | fillColor: colors.surface, |
| 117 | ), |
| 118 | filledButtonTheme: FilledButtonThemeData( |
| 119 | style: FilledButton.styleFrom( |
| 120 | minimumSize: const Size(48, 52), |
| 121 | shape: |
| 122 | RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), |
| 123 | ), |
| 124 | ), |
| 125 | outlinedButtonTheme: OutlinedButtonThemeData( |
| 126 | style: OutlinedButton.styleFrom(minimumSize: const Size(48, 50)), |
| 127 | ), |
| 128 | iconButtonTheme: IconButtonThemeData( |
| 129 | style: IconButton.styleFrom(minimumSize: const Size(48, 48)), |
| 130 | ), |
| 131 | textButtonTheme: TextButtonThemeData( |
| 132 | style: TextButton.styleFrom(minimumSize: const Size(48, 48)), |
| 133 | ), |
| 134 | ), |
| 135 | home: Directionality( |
| 136 | textDirection: TextDirection.rtl, |
| 137 | child: _loading |
| 138 | ? const Scaffold( |
| 139 | body: Center( |
| 140 | child: Column(mainAxisSize: MainAxisSize.min, children: [ |
| 141 | CircularProgressIndicator(), |
| 142 | SizedBox(height: 20), |
| 143 | Text('در حال باز کردن برنامهٔ این گوشی…'), |
| 144 | ]))) |
| 145 | : _failed |
| 146 | ? Scaffold( |
| 147 | body: SafeArea( |
| 148 | child: Center( |
| 149 | child: Padding( |
| 150 | padding: const EdgeInsets.all(28), |
| 151 | child: Column( |
| 152 | mainAxisSize: MainAxisSize.min, |
| 153 | children: [ |
| 154 | const Icon(Icons.folder_off_outlined, size: 48), |
| 155 | const SizedBox(height: 20), |
| 156 | const Text('برنامههای این گوشی باز نشد.', |
| 157 | textAlign: TextAlign.center), |
| 158 | const SizedBox(height: 12), |
| 159 | const Text( |
| 160 | 'ممکن است فضای گوشی کافی نباشد یا فایل ذخیرهسازی خوانده نشود. کمی فضا آزاد کنید و دوباره تلاش کنید. دادهها خودکار پاک نمیشوند.', |
| 161 | textAlign: TextAlign.center, |
| 162 | ), |
| 163 | const SizedBox(height: 24), |
| 164 | FilledButton( |
| 165 | onPressed: _open, |
| 166 | child: const Text('تلاش دوباره'), |
| 167 | ), |
| 168 | ], |
| 169 | ), |
| 170 | ), |
| 171 | ), |
| 172 | ), |
| 173 | ) |
| 174 | : _profile == null |
| 175 | ? StandaloneOnboarding( |
| 176 | store: _store!, onSaved: _profileSaved) |
| 177 | : StandalonePlannerShell( |
| 178 | store: _store!, |
| 179 | profile: _profile!, |
| 180 | onProfileSaved: _profileSaved, |
| 181 | reminderSettingsBuilder: widget.reminderSettingsBuilder, |
| 182 | onPlansChanged: widget.onPlansChanged, |
| 183 | onBeforePlansChange: widget.onBeforePlansChange, |
| 184 | onResumed: widget.onResumed, |
| 185 | ), |
| 186 | ), |
| 187 | ); |
| 188 | } |
| 189 | } |