LifeMate — Personal, Family & Learning Companion

docs/owner-guide-and-delivery-plan
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
dart 252 lines 11.1 KB
Raw
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 }