@davoodmehraban89 / LifeMate / commits / 0afcac7
Fork 0

LifeMate — Personal, Family & Learning Companion

feat: implement approved mobile home and separate Flutter destinations

Quinn White committed Oct 16, 2026 at 12:52 UTC 0afcac71b9e9b007515aa8a45eb331bd9f00dc55
5 files changed +726 -215
apps/lifemate/lib/main.dart
+254 -209
@@ -5,6 +5,9 @@ import 'package:flutter/material.dart';
5 import 'package:flutter_localizations/flutter_localizations.dart';
6
7 import 'api.dart';
8 +import 'mobile_home.dart';
9 +import 'study_ui.dart';
10 +import 'dashboard_ui.dart';
11 import 'iran_hub.dart';
12 import 'education_ui.dart';
13 import 'content_review_sync.dart';
@@ -132,8 +135,8 @@ class _LifeMateAppState extends State<LifeMateApp> {
135 theme: ThemeData(
136 fontFamily: 'LifeGuidePersian',
137 fontFamilyFallback: const ['LifeGuideLatin', 'LifeGuideEmoji'],
135 - colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF4D86E8)),
136 - scaffoldBackgroundColor: const Color(0xFFF8FAFD),
138 + colorScheme: ColorScheme.fromSeed(seedColor: MobileHomeMenu.accent),
139 + scaffoldBackgroundColor: MobileHomeMenu.paper,
140 inputDecorationTheme:
141 const InputDecorationTheme(border: OutlineInputBorder()),
142 useMaterial3: true,
@@ -1029,7 +1032,9 @@ class HomeShell extends StatefulWidget {
1032 }
1033
1034 class _HomeShellState extends State<HomeShell> with WidgetsBindingObserver {
1032 - int index = 0;
1035 + String page = 'خانه';
1036 + String displayName = '';
1037 + bool contextLoaded = false;
1038 String themePreference = 'adult_blue';
1039 bool adultShell = false;
1040 String? contextError;
@@ -1041,22 +1046,21 @@ class _HomeShellState extends State<HomeShell> with WidgetsBindingObserver {
1046 widget.api is HttpIdentityApi ? widget.api as HttpIdentityApi : null;
1047
1048 static const studentPages = [
1044 - 'امروز',
1045 - 'برنامه هفتگی',
1046 - 'تقویم',
1047 - 'تکالیف و کارها',
1048 - 'امتحان‌ها و نمرات',
1049 + 'خانه',
1050 + 'برنامه من',
1051 + 'درس‌ها',
1052 'تمرکز',
1053 + 'خانواده',
1054 + 'امتحان‌ها و نمرات',
1055 'همراه هوشمند',
1051 - 'مدرسه من',
1056 ];
1053 -
1057 static const adultPages = [
1055 - 'امروز',
1058 + 'خانه',
1059 'برنامه‌ریز',
1060 'خانواده',
1058 - 'راهنما',
1061 + 'گزارش‌ها',
1062 'من',
1063 + 'راهنما',
1064 'مدرسه من',
1065 ];
1066
@@ -1146,244 +1150,283 @@ class _HomeShellState extends State<HomeShell> with WidgetsBindingObserver {
1150 adultShell = category == 'adult' ||
1151 (!['girl_minor', 'boy_minor'].contains(category) &&
1152 !['girl_pink', 'boy_blue'].contains(themePreference));
1153 + displayName = profile['display_name']?.toString() ?? 'همراه';
1154 + contextLoaded = true;
1155 contextError = null;
1150 - if (index >= pages.length) index = pages.length - 1;
1156 + if (!pages.contains(page)) page = 'خانه';
1157 });
1158 }
1159 } catch (error) {
1154 - if (mounted) setState(() => contextError = errorText(error));
1160 + if (mounted) {
1161 + setState(() {
1162 + contextError = errorText(error);
1163 + contextLoaded = false;
1164 + });
1165 + }
1166 }
1167 }
1168
1169 List<String> get pages => adultShell ? adultPages : studentPages;
1170
1160 - Color get accent => themePreference == 'girl_pink'
1161 - ? const Color(0xFFE58FB0)
1162 - : const Color(0xFF4D86E8);
1171 + List<String> get primaryPages => adultShell
1172 + ? ['خانه', 'برنامه‌ریز', 'خانواده', 'گزارش‌ها', 'من']
1173 + : ['خانه', 'برنامه من', 'درس‌ها', 'تمرکز', 'خانواده'];
1174
1175 List<NavigationDestination> get destinations => adultShell
1176 ? const [
1177 + NavigationDestination(icon: Icon(Icons.home_outlined), label: 'خانه'),
1178 NavigationDestination(
1167 - icon: Icon(Icons.home_outlined),
1168 - label: 'امروز',
1169 - ),
1170 - NavigationDestination(
1171 - icon: Icon(Icons.event_note_outlined),
1172 - label: 'برنامه‌ریز',
1173 - ),
1179 + icon: Icon(Icons.event_note_outlined), label: 'برنامه‌ریز'),
1180 NavigationDestination(
1175 - icon: Icon(Icons.family_restroom_outlined),
1176 - label: 'خانواده',
1177 - ),
1181 + icon: Icon(Icons.people_outline), label: 'خانواده'),
1182 NavigationDestination(
1179 - icon: Icon(Icons.assistant_outlined),
1180 - label: 'راهنما',
1181 - ),
1183 + icon: Icon(Icons.bar_chart_outlined), label: 'گزارش‌ها'),
1184 NavigationDestination(
1183 - icon: Icon(Icons.person_outline),
1184 - label: 'من',
1185 - ),
1185 + icon: Icon(Icons.person_outline), label: 'بیشتر'),
1186 ]
1187 : const [
1188 + NavigationDestination(icon: Icon(Icons.home_outlined), label: 'خانه'),
1189 NavigationDestination(
1189 - icon: Icon(Icons.home_outlined),
1190 - label: 'امروز',
1191 - ),
1192 - NavigationDestination(
1193 - icon: Icon(Icons.schedule_outlined),
1194 - label: 'برنامه',
1195 - ),
1190 + icon: Icon(Icons.event_note_outlined), label: 'برنامه'),
1191 NavigationDestination(
1197 - icon: Icon(Icons.calendar_month_outlined),
1198 - label: 'تقویم',
1199 - ),
1192 + icon: Icon(Icons.menu_book_outlined), label: 'درس‌ها'),
1193 NavigationDestination(
1201 - icon: Icon(Icons.task_alt_outlined),
1202 - label: 'کارها',
1203 - ),
1194 + icon: Icon(Icons.timelapse_outlined), label: 'تمرکز'),
1195 NavigationDestination(
1205 - icon: Icon(Icons.school_outlined),
1206 - label: 'امتحان‌ها',
1207 - ),
1196 + icon: Icon(Icons.people_outline), label: 'خانواده'),
1197 ];
1198
1210 - void selectPage(int next) {
1211 - setState(() => index = next);
1199 + void selectPage(String next) {
1200 + final refreshProfile = ['من', 'خانواده'].contains(page) && next == 'خانه';
1201 + setState(() => page = next);
1202 + if (refreshProfile) loadContext();
1203 + }
1204 +
1205 + void openHomeMenu(String destination) => selectPage(switch (destination) {
1206 + 'plan' => adultShell ? 'برنامه‌ریز' : 'برنامه من',
1207 + 'courses' => 'درس‌ها',
1208 + 'focus' => 'تمرکز',
1209 + 'family' => 'خانواده',
1210 + 'report' => adultShell ? 'گزارش‌ها' : 'گزارش من',
1211 + 'reminders' => 'یادآوری‌ها',
1212 + _ => 'خانه',
1213 + });
1214 +
1215 + Widget pageContent() {
1216 + if (!contextLoaded) {
1217 + return contextError == null
1218 + ? const Center(child: CircularProgressIndicator())
1219 + : LoadError(
1220 + error: const ApiException(503, 'profile_unavailable'),
1221 + retry: loadContext);
1222 + }
1223 + if (page == 'خانه') {
1224 + return MobileHomeMenu(
1225 + displayName: displayName, adult: adultShell, onOpen: openHomeMenu);
1226 + }
1227 + if (['درس‌ها', 'مدرسه من'].contains(page)) {
1228 + return EducationLibraryPage(api: widget.api);
1229 + }
1230 + if (page == 'برنامه من') {
1231 + return PlannerPage(api: widget.api);
1232 + }
1233 + if (page == 'تمرکز') {
1234 + return StudyHub(api: widget.api);
1235 + }
1236 + if (page == 'گزارش‌ها') {
1237 + return ParentFamilyDashboard(api: widget.api);
1238 + }
1239 + if (page == 'گزارش من') {
1240 + return httpApi == null
1241 + ? const CoreNotice(
1242 + title: 'گزارش یادگیری',
1243 + subtitle: 'برای دریافت گزارش، اتصال به حساب معتبر لازم است.')
1244 + : LearningReviewsPage(
1245 + api: httpApi!, onOpenLesson: openReviewedLesson);
1246 + }
1247 + if (page == 'یادآوری‌ها') {
1248 + return NotificationInboxPage(api: widget.api, embedded: true);
1249 + }
1250 + if (page == 'خانواده' || page == 'من') {
1251 + return ProfileFamilyPage(api: widget.api, embedded: true);
1252 + }
1253 + if (page == 'همراه هوشمند' || page == 'راهنما') {
1254 + return const CoreNotice(
1255 + title: 'همراه هوشمند',
1256 + subtitle:
1257 + 'در این مرحله فعال نیست؛ داده سلامت و گفت‌وگو به سرویس هوشمند ارسال نمی‌شود.');
1258 + }
1259 + return Phase3HomeContent(
1260 + api: widget.api, page: page, adultShell: adultShell);
1261 }
1262
1263 @override
1264 Widget build(BuildContext context) => Theme(
1265 data: Theme.of(context).copyWith(
1217 - colorScheme: ColorScheme.fromSeed(seedColor: accent),
1218 - scaffoldBackgroundColor: Colors.white,
1266 + colorScheme: ColorScheme.fromSeed(seedColor: MobileHomeMenu.accent),
1267 + scaffoldBackgroundColor: MobileHomeMenu.paper,
1268 + appBarTheme: const AppBarTheme(
1269 + backgroundColor: MobileHomeMenu.paper,
1270 + foregroundColor: MobileHomeMenu.ink,
1271 + elevation: 0,
1272 + surfaceTintColor: Colors.transparent),
1273 ),
1220 - child: Scaffold(
1221 - appBar: AppBar(
1222 - title: Text(pages[index]),
1223 - actions: [
1224 - IconButton(
1225 - tooltip: 'مدرسه من',
1226 - icon: const Icon(Icons.menu_book_outlined),
1227 - onPressed: () => Navigator.of(context).push(MaterialPageRoute(
1228 - builder: (_) => Scaffold(
1229 - appBar: AppBar(title: const Text('مدرسه من')),
1230 - body: EducationLibraryPage(api: widget.api)))),
1274 + child: PopScope(
1275 + canPop: page == 'خانه',
1276 + onPopInvokedWithResult: (didPop, _) {
1277 + if (!didPop) selectPage('خانه');
1278 + },
1279 + child: Scaffold(
1280 + appBar: AppBar(
1281 + leading: page == 'خانه'
1282 + ? null
1283 + : IconButton(
1284 + tooltip: 'برگشت به خانه',
1285 + onPressed: () => selectPage('خانه'),
1286 + icon: const Icon(Icons.arrow_back)),
1287 + title: Text(page == 'خانه' ? 'لایف‌گاید' : page),
1288 + actions: [
1289 + IconButton(
1290 + tooltip: 'یادآوری‌ها',
1291 + icon: const Icon(Icons.notifications_none),
1292 + onPressed: () => selectPage('یادآوری‌ها')),
1293 + IconButton(
1294 + tooltip: 'حساب و تنظیمات',
1295 + icon: const Icon(Icons.person_outline),
1296 + onPressed: () => selectPage('من')),
1297 + ],
1298 ),
1232 - IconButton(
1233 - onPressed: () async {
1234 - await Navigator.of(context).push(MaterialPageRoute(
1235 - builder: (_) => ProfileFamilyPage(api: widget.api)));
1236 - if (mounted) await loadContext();
1237 - },
1238 - icon: const Icon(Icons.person_outline),
1299 + body: pageContent(),
1300 + bottomNavigationBar: NavigationBar(
1301 + selectedIndex: primaryPages.contains(page)
1302 + ? primaryPages.indexOf(page)
1303 + : 0,
1304 + onDestinationSelected: (index) =>
1305 + selectPage(primaryPages[index]),
1306 + destinations: destinations,
1307 ),
1240 - ],
1241 - ),
1242 - body: Column(children: [
1243 - if (contextError != null)
1244 - MaterialBanner(content: Text(contextError!), actions: [
1245 - TextButton(
1246 - onPressed: loadContext, child: const Text('تلاش دوباره'))
1247 - ]),
1248 - Expanded(
1249 - child: pages[index] == 'مدرسه من'
1250 - ? EducationLibraryPage(api: widget.api)
1251 - : pages[index] == 'من'
1252 - ? ProfileFamilyPage(api: widget.api)
1253 - : (pages[index] == 'همراه هوشمند' ||
1254 - pages[index] == 'راهنما')
1255 - ? const CoreNotice(
1256 - title: 'همراه هوشمند',
1257 - subtitle:
1258 - 'در این مرحله فعال نیست؛ داده سلامت و گفت‌وگو به سرویس هوشمند ارسال نمی‌شود.')
1259 - : Phase3HomeContent(
1260 - api: widget.api,
1261 - page: pages[index],
1262 - adultShell: adultShell,
1263 - ))
1264 - ]),
1265 - bottomNavigationBar: NavigationBar(
1266 - selectedIndex: index > 4 ? 0 : index,
1267 - onDestinationSelected: selectPage,
1268 - destinations: destinations,
1269 - ),
1270 - drawer: Drawer(
1271 - child: SafeArea(
1272 - child: ListView(
1273 - children: [
1274 - const ListTile(
1275 - title: Text('LifeGuide'),
1276 - subtitle: Text('منوی اصلی'),
1277 - ),
1278 - ...pages.asMap().entries.map(
1279 - (entry) => ListTile(
1280 - title: Text(entry.value),
1308 + drawer: Drawer(
1309 + child: SafeArea(
1310 + child: ListView(
1311 + children: [
1312 + const ListTile(
1313 + title: Text('LifeGuide'),
1314 + subtitle: Text('منوی اصلی'),
1315 + ),
1316 + ...pages.asMap().entries.map(
1317 + (entry) => ListTile(
1318 + title: Text(entry.value),
1319 + onTap: () {
1320 + selectPage(entry.value);
1321 + Navigator.pop(context);
1322 + },
1323 + ),
1324 + ),
1325 + ListTile(
1326 + leading: const Icon(Icons.notifications_outlined),
1327 + title: const Text('اعلان‌های درون برنامه'),
1328 onTap: () {
1282 - selectPage(entry.key);
1329 Navigator.pop(context);
1284 - },
1285 - ),
1286 - ),
1287 - ListTile(
1288 - leading: const Icon(Icons.notifications_outlined),
1289 - title: const Text('اعلان‌های درون برنامه'),
1290 - onTap: () {
1291 - Navigator.pop(context);
1292 - Navigator.of(context).push(MaterialPageRoute(
1293 - builder: (_) =>
1294 - NotificationInboxPage(api: widget.api)));
1295 - }),
1296 - ListTile(
1297 - leading: const Icon(Icons.sync_problem_outlined),
1298 - title: const Text('تغییرهای معلق و تعارض‌ها'),
1299 - onTap: () {
1300 - Navigator.pop(context);
1301 - Navigator.of(context).push(MaterialPageRoute(
1302 - builder: (_) => SyncChangesPage(api: widget.api)));
1303 - }),
1304 - if (httpApi != null)
1305 - ListTile(
1306 - leading: const Icon(Icons.flag_outlined),
1307 - title: const Text('اهداف یادگیری'),
1308 - onTap: () {
1309 - Navigator.pop(context);
1310 - Navigator.of(context).push(MaterialPageRoute(
1311 - builder: (_) =>
1312 - LearningGoalsPage(api: httpApi!)));
1313 - }),
1314 - if (httpApi != null)
1315 - ListTile(
1316 - leading: const Icon(Icons.history_edu_outlined),
1317 - title: const Text('مرور و تاریخچه یادگیری'),
1318 - onTap: () {
1319 - Navigator.pop(context);
1320 - Navigator.of(context).push(MaterialPageRoute(
1321 - builder: (_) => LearningReviewsPage(
1322 - api: httpApi!,
1323 - onOpenLesson: openReviewedLesson)));
1324 - }),
1325 - if (httpApi != null &&
1326 - contentPermissions.contains('feedback.read'))
1327 - ListTile(
1328 - leading: const Icon(Icons.fact_check_outlined),
1329 - title: const Text('بررسی محتوای آموزشی'),
1330 - onTap: () async {
1331 - Navigator.pop(context);
1332 - await Navigator.of(context).push(MaterialPageRoute(
1330 + Navigator.of(context).push(MaterialPageRoute(
1331 + builder: (_) =>
1332 + NotificationInboxPage(api: widget.api)));
1333 + }),
1334 + ListTile(
1335 + leading: const Icon(Icons.sync_problem_outlined),
1336 + title: const Text('تغییرهای معلق و تعارض‌ها'),
1337 + onTap: () {
1338 + Navigator.pop(context);
1339 + Navigator.of(context).push(MaterialPageRoute(
1340 + builder: (_) =>
1341 + SyncChangesPage(api: widget.api)));
1342 + }),
1343 + if (httpApi != null)
1344 + ListTile(
1345 + leading: const Icon(Icons.flag_outlined),
1346 + title: const Text('اهداف یادگیری'),
1347 + onTap: () {
1348 + Navigator.pop(context);
1349 + Navigator.of(context).push(MaterialPageRoute(
1350 + builder: (_) =>
1351 + LearningGoalsPage(api: httpApi!)));
1352 + }),
1353 + if (httpApi != null)
1354 + ListTile(
1355 + leading: const Icon(Icons.history_edu_outlined),
1356 + title: const Text('مرور و تاریخچه یادگیری'),
1357 + onTap: () {
1358 + Navigator.pop(context);
1359 + Navigator.of(context).push(MaterialPageRoute(
1360 + builder: (_) => LearningReviewsPage(
1361 + api: httpApi!,
1362 + onOpenLesson: openReviewedLesson)));
1363 + }),
1364 + if (httpApi != null &&
1365 + contentPermissions.contains('feedback.read'))
1366 + ListTile(
1367 + leading: const Icon(Icons.fact_check_outlined),
1368 + title: const Text('بررسی محتوای آموزشی'),
1369 + onTap: () async {
1370 + Navigator.pop(context);
1371 + await Navigator.of(context).push(
1372 + MaterialPageRoute(
1373 + builder: (_) =>
1374 + ContentReviewPage(api: httpApi!)));
1375 + if (mounted) await loadCapabilities();
1376 + }),
1377 + if (widget.onEndpointSettings != null && !kIsWeb)
1378 + ListTile(
1379 + leading: const Icon(Icons.settings_ethernet),
1380 + title: const Text('تنظیم اتصال'),
1381 + onTap: () {
1382 + Navigator.pop(context);
1383 + widget.onEndpointSettings!();
1384 + }),
1385 + if (widget.onSignOut != null)
1386 + ListTile(
1387 + leading: const Icon(Icons.logout),
1388 + title: const Text('خروج از حساب'),
1389 + onTap: () async {
1390 + Navigator.pop(context);
1391 + try {
1392 + if (!await confirmScopeDiscard(
1393 + context, widget.api)) {
1394 + return;
1395 + }
1396 + await widget.onSignOut!();
1397 + } catch (e) {
1398 + if (context.mounted) {
1399 + ScaffoldMessenger.of(context).showSnackBar(
1400 + SnackBar(content: Text(errorText(e))));
1401 + }
1402 + }
1403 + }),
1404 + if (!adultShell) ...[
1405 + const Divider(),
1406 + ListTile(
1407 + leading: const Icon(Icons.family_restroom),
1408 + title: const Text('خانواده'),
1409 + onTap: () => Navigator.of(context).push(
1410 + MaterialPageRoute(
1411 builder: (_) =>
1334 - ContentReviewPage(api: httpApi!)));
1335 - if (mounted) await loadCapabilities();
1336 - }),
1337 - if (widget.onEndpointSettings != null && !kIsWeb)
1338 - ListTile(
1339 - leading: const Icon(Icons.settings_ethernet),
1340 - title: const Text('تنظیم اتصال'),
1341 - onTap: () {
1342 - Navigator.pop(context);
1343 - widget.onEndpointSettings!();
1344 - }),
1345 - if (widget.onSignOut != null)
1346 - ListTile(
1347 - leading: const Icon(Icons.logout),
1348 - title: const Text('خروج از حساب'),
1349 - onTap: () async {
1350 - Navigator.pop(context);
1351 - try {
1352 - if (!await confirmScopeDiscard(
1353 - context, widget.api)) {
1354 - return;
1355 - }
1356 - await widget.onSignOut!();
1357 - } catch (e) {
1358 - if (context.mounted) {
1359 - ScaffoldMessenger.of(context).showSnackBar(
1360 - SnackBar(content: Text(errorText(e))));
1361 - }
1362 - }
1363 - }),
1364 - if (!adultShell) ...[
1365 - const Divider(),
1366 - ListTile(
1367 - leading: const Icon(Icons.family_restroom),
1368 - title: const Text('خانواده'),
1369 - onTap: () => Navigator.of(context).push(
1370 - MaterialPageRoute(
1371 - builder: (_) => ProfileFamilyPage(api: widget.api),
1412 + ProfileFamilyPage(api: widget.api),
1413 + ),
1414 + ),
1415 ),
1373 - ),
1374 - ),
1375 - ],
1376 - ],
1416 + ],
1417 + ],
1418 + ),
1419 + ),
1420 ),
1378 - ),
1379 - ),
1380 - ),
1421 + )),
1422 );
1423 }
1424
1425 class ProfileFamilyPage extends StatefulWidget {
1385 - const ProfileFamilyPage({super.key, required this.api});
1426 + const ProfileFamilyPage(
1427 + {super.key, required this.api, this.embedded = false});
1428 final IdentityApi api;
1429 + final bool embedded;
1430 @override
1431 State<ProfileFamilyPage> createState() => _ProfileFamilyPageState();
1432 }
@@ -1436,7 +1479,9 @@ class _ProfileFamilyPageState extends State<ProfileFamilyPage> {
1479
1480 @override
1481 Widget build(BuildContext context) => Scaffold(
1439 - appBar: AppBar(title: const Text('پروفایل و خانواده')),
1482 + appBar: widget.embedded
1483 + ? null
1484 + : AppBar(title: const Text('پروفایل و خانواده')),
1485 body: FutureBuilder<List<dynamic>>(
1486 future: data,
1487 builder: (context, snapshot) {
apps/lifemate/lib/mobile_home.dart new
+252
@@ -0,0 +1,252 @@
1 +import 'package:flutter/material.dart';
2 +
3 +/// Presentation only. Categories choose menus; API permissions remain server-side.
4 +class MobileHomeMenu extends StatelessWidget {
5 + const MobileHomeMenu(
6 + {super.key,
7 + required this.displayName,
8 + required this.adult,
9 + required this.onOpen});
10 + final String displayName;
11 + final bool adult;
12 + final ValueChanged<String> onOpen;
13 +
14 + static const ink = Color(0xFF245B4E);
15 + static const paper = Color(0xFFF4F5EE);
16 + static const accent = Color(0xFF226F5C);
17 +
18 + @override
19 + Widget build(BuildContext context) => LayoutBuilder(builder: (context, box) {
20 + final compact = box.maxHeight < 590;
21 + final menus = adult
22 + ? const [
23 + (
24 + 'plan',
25 + 'برنامه من',
26 + 'کارها و زمان‌های شخصی',
27 + Icons.event_note_outlined,
28 + Color(0xFFE7EEDC)
29 + ),
30 + (
31 + 'family',
32 + 'خانواده',
33 + 'اعضا و تنظیمات اشتراک',
34 + Icons.people_outline,
35 + Color(0xFFF4E4E8)
36 + ),
37 + (
38 + 'report',
39 + 'گزارش‌های مجاز',
40 + 'انتخاب خانواده و فرزند',
41 + Icons.bar_chart_outlined,
42 + Color(0xFFE5EFF3)
43 + ),
44 + (
45 + 'reminders',
46 + 'یادآوری‌ها',
47 + 'پیام‌های داخل برنامه',
48 + Icons.notifications_none,
49 + Color(0xFFF5EED8)
50 + ),
51 + ]
52 + : const [
53 + (
54 + 'plan',
55 + 'برنامه من',
56 + 'کارها و تکلیف‌ها',
57 + Icons.event_note_outlined,
58 + Color(0xFFE7EEDC)
59 + ),
60 + (
61 + 'courses',
62 + 'درس‌های من',
63 + 'پایه، کتاب و یادگیری',
64 + Icons.menu_book_outlined,
65 + Color(0xFFF6E7DC)
66 + ),
67 + (
68 + 'focus',
69 + 'وقت تمرکز',
70 + 'مطالعه با تایمر',
71 + Icons.timelapse_outlined,
72 + Color(0xFFECE6F7)
73 + ),
74 + (
75 + 'family',
76 + 'خانواده',
77 + 'حساب و اشتراک‌گذاری',
78 + Icons.people_outline,
79 + Color(0xFFF4E4E8)
80 + ),
81 + (
82 + 'report',
83 + 'گزارش من',
84 + 'مرور و تاریخچه یادگیری',
85 + Icons.bar_chart_outlined,
86 + Color(0xFFF5EED8)
87 + ),
88 + (
89 + 'reminders',
90 + 'یادآوری‌ها',
91 + 'پیام‌های داخل برنامه',
92 + Icons.notifications_none,
93 + Color(0xFFE5EFF3)
94 + ),
95 + ];
96 + return SingleChildScrollView(
97 + key: const ValueKey('home-scroll'),
98 + padding: const EdgeInsets.fromLTRB(16, 12, 16, 20),
99 + child: Center(
100 + child: ConstrainedBox(
101 + constraints: const BoxConstraints(maxWidth: 600),
102 + child: Column(
103 + crossAxisAlignment: CrossAxisAlignment.start,
104 + children: [
105 + Text('سلام $displayName',
106 + style: Theme.of(context)
107 + .textTheme
108 + .titleLarge
109 + ?.copyWith(
110 + color: ink, fontWeight: FontWeight.w600)),
111 + const SizedBox(height: 5),
112 + Text(
113 + adult
114 + ? 'فضای شخصی و خانوادگی تو'
115 + : 'امروز از کدام قدم شروع کنیم؟',
116 + style: const TextStyle(
117 + color: Color(0xFF6E7C6D), fontSize: 13)),
118 + SizedBox(height: compact ? 12 : 20),
119 + Container(
120 + width: double.infinity,
121 + padding: EdgeInsets.all(compact ? 14 : 20),
122 + decoration: BoxDecoration(
123 + color: adult
124 + ? const Color(0xFFE2EDF0)
125 + : const Color(0xFFE4EED7),
126 + borderRadius: BorderRadius.circular(24)),
127 + child: Row(children: [
128 + Expanded(
129 + child: Column(
130 + crossAxisAlignment:
131 + CrossAxisAlignment.start,
132 + children: [
133 + Text(
134 + adult
135 + ? 'کنار هم، با برنامه‌ای روشن'
136 + : 'یک شروع کوچک، یک قدم جلوتر',
137 + style: TextStyle(
138 + color: ink,
139 + fontSize: compact ? 17 : 21,
140 + fontWeight: FontWeight.w600)),
141 + const SizedBox(height: 8),
142 + Text(
143 + adult
144 + ? 'برنامه شخصی و اطلاعاتی که با تو به اشتراک گذاشته شده‌اند.'
145 + : 'برنامه‌ات را ببین، یک کار انتخاب کن و شروع کن.',
146 + style: const TextStyle(
147 + color: ink, fontSize: 12)),
148 + ])),
149 + if (box.maxWidth > 340) ...[
150 + const SizedBox(width: 14),
151 + ExcludeSemantics(
152 + child: Icon(
153 + adult
154 + ? Icons.diversity_1_outlined
155 + : Icons.route_outlined,
156 + size: compact ? 45 : 68,
157 + color:
158 + accent.withValues(alpha: .55))),
159 + ],
160 + ])),
161 + SizedBox(height: compact ? 12 : 20),
162 + const Text('همه چیز، سر جای خودش',
163 + style: TextStyle(color: ink, fontSize: 13)),
164 + const SizedBox(height: 10),
165 + GridView.builder(
166 + shrinkWrap: true,
167 + physics: const NeverScrollableScrollPhysics(),
168 + gridDelegate:
169 + SliverGridDelegateWithFixedCrossAxisCount(
170 + crossAxisCount:
171 + MediaQuery.textScalerOf(context)
172 + .scale(1) >
173 + 1.3
174 + ? 1
175 + : 2,
176 + crossAxisSpacing: 10,
177 + mainAxisSpacing: 10,
178 + mainAxisExtent: (compact ? 88.0 : 100.0) *
179 + MediaQuery.textScalerOf(context)
180 + .scale(1)
181 + .clamp(1, 1.8)),
182 + itemCount: menus.length,
183 + itemBuilder: (context, index) {
184 + final (id, title, subtitle, icon, tint) =
185 + menus[index];
186 + return _HomeTile(
187 + id: id,
188 + title: title,
189 + subtitle: subtitle,
190 + icon: icon,
191 + tint: tint,
192 + onTap: () => onOpen(id));
193 + }),
194 + ]))));
195 + });
196 +}
197 +
198 +class _HomeTile extends StatelessWidget {
199 + const _HomeTile(
200 + {required this.id,
201 + required this.title,
202 + required this.subtitle,
203 + required this.icon,
204 + required this.tint,
205 + required this.onTap});
206 + final String id, title, subtitle;
207 + final IconData icon;
208 + final Color tint;
209 + final VoidCallback onTap;
210 + @override
211 + Widget build(BuildContext context) => Material(
212 + color: Colors.white,
213 + borderRadius: BorderRadius.circular(18),
214 + child: InkWell(
215 + key: ValueKey('home-$id'),
216 + onTap: onTap,
217 + borderRadius: BorderRadius.circular(18),
218 + child: Semantics(
219 + button: true,
220 + child: Padding(
221 + padding: const EdgeInsets.all(8),
222 + child: Column(
223 + mainAxisAlignment: MainAxisAlignment.center,
224 + crossAxisAlignment: CrossAxisAlignment.start,
225 + children: [
226 + Row(children: [
227 + Container(
228 + padding: const EdgeInsets.all(6),
229 + decoration: BoxDecoration(
230 + color: tint,
231 + borderRadius: BorderRadius.circular(10)),
232 + child: Icon(icon,
233 + size: 18, color: MobileHomeMenu.ink)),
234 + const SizedBox(width: 6),
235 + Expanded(
236 + child: Text(title,
237 + style: const TextStyle(
238 + color: MobileHomeMenu.ink,
239 + fontSize: 13,
240 + height: 1.25,
241 + fontWeight: FontWeight.w600))),
242 + ]),
243 + const SizedBox(height: 5),
244 + Text(subtitle,
245 + maxLines: 2,
246 + overflow: TextOverflow.ellipsis,
247 + style: const TextStyle(
248 + color: Color(0xFF788475),
249 + fontSize: 11,
250 + height: 1.25)),
251 + ])))));
252 +}
apps/lifemate/lib/notifications_ui.dart
+10 -6
@@ -4,8 +4,10 @@ import 'api.dart';
4 import 'notification_delivery.dart';
5
6 class NotificationInboxPage extends StatefulWidget {
7 - const NotificationInboxPage({super.key, required this.api, this.delivery});
7 + const NotificationInboxPage(
8 + {super.key, required this.api, this.delivery, this.embedded = false});
9 final IdentityApi api;
10 + final bool embedded;
11 final NotificationDeliveryPort? delivery;
12 @override
13 State<NotificationInboxPage> createState() => _NotificationInboxPageState();
@@ -70,11 +72,13 @@ class _NotificationInboxPageState extends State<NotificationInboxPage>
72
73 @override
74 Widget build(BuildContext context) => Scaffold(
73 - appBar: AppBar(title: const Text('یادآوری‌های لایف‌گاید'), actions: [
74 - IconButton(
75 - onPressed: loading ? null : reload,
76 - icon: const Icon(Icons.refresh))
77 - ]),
75 + appBar: widget.embedded
76 + ? null
77 + : AppBar(title: const Text('یادآوری‌های لایف‌گاید'), actions: [
78 + IconButton(
79 + onPressed: loading ? null : reload,
80 + icon: const Icon(Icons.refresh))
81 + ]),
82 body: ListView(padding: const EdgeInsets.all(16), children: [
83 const Text(
84 'این یادآوری‌ها هنگام باز بودن برنامه تازه می‌شوند. اعلان پس‌زمینه فعال نیست.'),
apps/lifemate/test/mobile_navigation_test.dart new
+160
@@ -0,0 +1,160 @@
1 +import 'package:flutter/material.dart';
2 +import 'package:flutter/services.dart';
3 +import 'package:flutter_test/flutter_test.dart';
4 +import 'package:lifemate/main.dart';
5 +import 'package:lifemate/api.dart';
6 +import 'package:lifemate/phase3_ui.dart';
7 +import 'package:lifemate/education_ui.dart';
8 +import 'package:lifemate/study_ui.dart';
9 +import 'package:lifemate/dashboard_ui.dart';
10 +import 'package:shared_preferences/shared_preferences.dart';
11 +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart';
12 +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart';
13 +
14 +import 'app_test.dart' show FakeApi;
15 +
16 +class MenuApi extends FakeApi {
17 + MenuApi({this.category = 'girl_minor'});
18 + final String category;
19 + bool failProfile = false;
20 + @override
21 + Future<Map<String, dynamic>> getProfile() async {
22 + if (failProfile) throw const ApiException(503, 'profile_unavailable');
23 + return {
24 + 'user_id': 'synthetic-menu-user',
25 + 'display_name': 'کاربر نمونه',
26 + 'profile_category': category,
27 + 'theme_preference': 'adult_blue',
28 + };
29 + }
30 +
31 + @override
32 + Future<List<Map<String, dynamic>>> listFamilies() async => [];
33 +}
34 +
35 +void main() {
36 + TestWidgetsFlutterBinding.ensureInitialized();
37 + setUpAll(() async {
38 + final fonts = FontLoader('LifeGuidePersian')
39 + ..addFont(rootBundle.load('assets/fonts/LifeGuidePersian.ttf'));
40 + await fonts.load();
41 + WidgetController.hitTestWarningShouldBeFatal = true;
42 + });
43 +
44 + setUp(() {
45 + String? token;
46 + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
47 + .setMockMethodCallHandler(
48 + const MethodChannel('lifeguide/local_write_guard'), (call) async {
49 + if (call.method == 'getBlocked') return token != null;
50 + if (call.method == 'beginWrite') return token = 'synthetic-menu-write';
51 + if (call.method == 'completeWrite' && call.arguments == token) {
52 + token = null;
53 + return true;
54 + }
55 + throw PlatformException(code: 'local_storage_restart_required');
56 + });
57 + SharedPreferences.setMockInitialValues({});
58 + SharedPreferencesAsyncPlatform.instance =
59 + InMemorySharedPreferencesAsync.withData({});
60 + });
61 + Future<void> shell(WidgetTester tester, MenuApi api) async {
62 + await tester.pumpWidget(MaterialApp(
63 + theme: ThemeData(fontFamily: 'LifeGuidePersian'),
64 + home: Directionality(
65 + textDirection: TextDirection.rtl, child: HomeShell(api: api))));
66 + await tester.pumpAndSettle();
67 + }
68 +
69 + for (final size in [const Size(390, 844), const Size(320, 740)]) {
70 + testWidgets(
71 + 'compact home menus open separate destinations and back at $size',
72 + (tester) async {
73 + tester.view.physicalSize = size;
74 + tester.view.devicePixelRatio = 1;
75 + addTearDown(tester.view.resetPhysicalSize);
76 + addTearDown(tester.view.resetDevicePixelRatio);
77 + await shell(tester, MenuApi());
78 + expect(find.textContaining('کاربر نمونه'), findsOneWidget);
79 + for (final entry in {
80 + 'plan': PlannerPage,
81 + 'courses': EducationLibraryPage,
82 + 'focus': StudyHub,
83 + 'family': ProfileFamilyPage
84 + }.entries) {
85 + final menu = find.byKey(ValueKey('home-${entry.key}'));
86 + expect(menu.hitTestable(), findsOneWidget);
87 + expect(tester.getRect(menu).bottom, lessThan(size.height - 50));
88 + await tester.tap(menu);
89 + await tester.pumpAndSettle();
90 + expect(find.byType(entry.value), findsOneWidget);
91 + expect(find.byKey(const ValueKey('home-plan')), findsNothing);
92 + await tester.tap(find.byTooltip('برگشت به خانه'));
93 + await tester.pumpAndSettle();
94 + expect(find.byKey(const ValueKey('home-plan')), findsOneWidget);
95 + }
96 + for (final key in ['report', 'reminders']) {
97 + expect(find.byKey(ValueKey('home-$key')).hitTestable(), findsOneWidget);
98 + await tester.tap(find.byKey(ValueKey('home-$key')));
99 + await tester.pumpAndSettle();
100 + expect(find.byKey(const ValueKey('home-plan')), findsNothing);
101 + await tester.tap(find.byTooltip('برگشت به خانه'));
102 + await tester.pumpAndSettle();
103 + }
104 + expect(tester.takeException(), isNull);
105 + await tester.pumpWidget(const SizedBox());
106 + });
107 + }
108 + testWidgets('large text remains reachable without layout overflow',
109 + (tester) async {
110 + tester.view.physicalSize = const Size(320, 740);
111 + tester.view.devicePixelRatio = 1;
112 + addTearDown(tester.view.resetPhysicalSize);
113 + addTearDown(tester.view.resetDevicePixelRatio);
114 + await tester.pumpWidget(MaterialApp(
115 + theme: ThemeData(fontFamily: 'LifeGuidePersian'),
116 + home: MediaQuery(
117 + data: const MediaQueryData(
118 + size: Size(320, 740), textScaler: TextScaler.linear(1.6)),
119 + child: Directionality(
120 + textDirection: TextDirection.rtl,
121 + child: HomeShell(api: MenuApi())))));
122 + await tester.pumpAndSettle();
123 + await tester.scrollUntilVisible(
124 + find.byKey(const ValueKey('home-reminders')), 150,
125 + scrollable: find
126 + .descendant(
127 + of: find.byKey(const ValueKey('home-scroll')),
128 + matching: find.byType(Scrollable))
129 + .first);
130 + expect(find.byKey(const ValueKey('home-reminders')).hitTestable(),
131 + findsOneWidget);
132 + expect(tester.takeException(), isNull);
133 + await tester.pumpWidget(const SizedBox());
134 + });
135 + testWidgets(
136 + 'adult home does not depend on family membership or grant parent access',
137 + (tester) async {
138 + await shell(tester, MenuApi(category: 'adult'));
139 + expect(find.byKey(const ValueKey('home-family')), findsOneWidget);
140 + expect(find.byKey(const ValueKey('home-report')), findsOneWidget);
141 + expect(find.byKey(const ValueKey('home-courses')), findsNothing);
142 + await tester.tap(find.byKey(const ValueKey('home-report')));
143 + await tester.pumpAndSettle();
144 + expect(find.byType(ParentFamilyDashboard), findsOneWidget);
145 + expect(find.byType(LearningReportPage), findsNothing);
146 + await tester.pumpWidget(const SizedBox());
147 + });
148 + testWidgets(
149 + 'profile failure does not guess a child or parent home and can retry',
150 + (tester) async {
151 + final api = MenuApi()..failProfile = true;
152 + await shell(tester, api);
153 + expect(find.byKey(const ValueKey('home-plan')), findsNothing);
154 + api.failProfile = false;
155 + await tester.tap(find.text('تلاش دوباره').first);
156 + await tester.pumpAndSettle();
157 + expect(find.byKey(const ValueKey('home-plan')), findsOneWidget);
158 + await tester.pumpWidget(const SizedBox());
159 + });
160 +}
docs/superpowers/plans/2026-10-16-flutter-mobile-navigation.md new
+50
@@ -0,0 +1,50 @@
1 +# Approved mobile navigation — Flutter implementation plan
2 +
3 +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans. Implement task-by-task; preserve the existing client and API.
4 +
5 +**Goal:** Replace the authenticated entry with the approved, compact home menu and separate working destinations, including a selected task detail using the existing server-backed planner.
6 +**Architecture:** Flutter HomeShell owns primary navigation; a small presentation-only mobile_home.dart supplies the approved warm/teal menu. Existing EducationLibraryPage, StudyHub, family/report, notification and account/sync pages remain authoritative. Task detail delegates mutations to the existing PlanSync; no new database or authentication model.
7 +**Tech stack:** Flutter/Dart, existing HTTP API, PlanSync and user-scoped OfflineStore.
8 +**Spec:** design-review/mobile-v1/README.md and exports/LifeGuide-overview.png, approved by owner in this conversation on2026-10-16.
9 +
10 +## Global constraints
11 +- No merge, deployment, live endpoint/DNS/database changes, external AI/SMS or real data.
12 +- Existing Flutter only; React design remains a reference. All screenshots/fixtures synthetic.
13 +- Profile category controls presentation only; server remains permission authority.
14 +- No fake counts, video, quiz, session durations, parent visibility or alarm claims.
15 +- Preserve pending changes, logout/scope gates, review capabilities and disabled sensitive guide.
16 +- One small draft PR stacked on design PR30; full product phase1/online hosting acceptance is still incomplete.
17 +
18 +## Review focus
19 +- Small screens320/390 and large text: six child menus reachable, no overflow; scroll only when space/accessibility requires it.
20 +- Profile failure/change or missing family: no wrong-role navigation, retry and correct home after context reload.
21 +- Shared/view-only tasks: detail cannot offer mutation/timer controls; backend permissions unchanged.
22 +- Pending offline creation: edits remain queued; no study until server ACK; conflicts stay visible.
23 +- Back/account/scope transitions: selected item is correct; preserve root logout/cache isolation and invalidate obsolete routes as before.
24 +
25 +### Task1 — Home and separate destinations
26 +**Files:** lib/main.dart; new lib/mobile_home.dart; test/mobile_navigation_test.dart; existing online_ui_test.dart as needed for intentional menu labels.
27 +**Consumes:** IdentityApi.getProfile(), existing pages and HomeShell callbacks.
28 +**Produces:** compact HomeMenu (profile name, child/adult layout, selection callback); HomeShell routes every main menu to its existing API-backed page, root back returns home.
29 +- [ ] Write tests against existing HomeShell for six menus and back at320/390, profile name, adult presentation independent from family membership, profile failure retry.
30 +- [ ] Run focused Flutter tests; expect missing home/menu assertions (RED).
31 +- [ ] Implement approved palette/layout and reuse existing destinations; preserve drawer capabilities/scope/logout.
32 +- [ ] Run focused tests and full suite; expect all PASS. Commit.
33 +
34 +### Task2 — Selected task detail
35 +**Files:** lib/phase3_ui.dart; new lib/plan_details_ui.dart; test/mobile_navigation_test.dart.
36 +**Consumes:** selected plan map, PlanItemDialog and PlanSync mutation outcomes; task kind/status/visibility/owner/version.
37 +**Produces:** PlanDetailsPage with correct selected content, edit/complete/archive via existing caller, server-ACK/pending states; approved presentation without fake data.
38 +- [ ] Tests: selecting second item opens its own detail; edit and completion show ACK/queued state; archive confirmation; shared non-owner view is read-only; pending cannot start study.
39 +- [ ] Run focused tests before implementation; expect absent detail route (RED).
40 +- [ ] Delegate actions to existing planner logic; retain existing popup actions for compatibility and scope guards.
41 +- [ ] Run focused tests and full suite, formatting/analyze; expect all PASS. Commit.
42 +
43 +### Task3 — Evidence and delivery
44 +**Files:** docs/ux/mobile-navigation implementation receipt; PROJECT_STATE.md; design status.
45 +**Consumes:** final Flutter source, local synthetic Node+PostgreSQL API and compiled web build if available.
46 +**Produces:** real build and interaction receipts/screenshot, draft PR; explicit UNVERIFIED physical devices, signing, hosting and managed-child legacy API gates.
47 +- [ ] Run flutter analyze/test; build web --release --no-web-resources-cdn --pwa-strategy=none and bundle local resources.
48 +- [ ] Exercise compiled client through local synthetic API/PostgreSQL; independent read-after-write if fixture setup available. Never reuse live or real-data hosts.
49 +- [ ] Independent wholebranch review; fix important findings with regression checks.
50 +- [ ] Record commands/results/limits, commit and open draft PR. No merge/deploy. Stop and report this delivery.