LifeMate — Personal, Family & Learning Companion
test/personal-notification-settings
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 | |
| 3 | import 'reminder_coordinator.dart'; |
| 4 | import 'reminders.dart'; |
| 5 | import 'store.dart'; |
| 6 | |
| 7 | class StandaloneReminderSettings extends StatefulWidget { |
| 8 | const StandaloneReminderSettings( |
| 9 | {super.key, required this.store, required this.coordinator}); |
| 10 | final StandaloneStore store; |
| 11 | final StandaloneReminderCoordinator coordinator; |
| 12 | @override |
| 13 | State<StandaloneReminderSettings> createState() => |
| 14 | _StandaloneReminderSettingsState(); |
| 15 | } |
| 16 | |
| 17 | class _StandaloneReminderSettingsState extends State<StandaloneReminderSettings> |
| 18 | with WidgetsBindingObserver { |
| 19 | bool _busy = false; |
| 20 | @override |
| 21 | void initState() { |
| 22 | super.initState(); |
| 23 | WidgetsBinding.instance.addObserver(this); |
| 24 | _run(() => widget.coordinator.refresh(widget.store)); |
| 25 | } |
| 26 | |
| 27 | @override |
| 28 | void dispose() { |
| 29 | WidgetsBinding.instance.removeObserver(this); |
| 30 | super.dispose(); |
| 31 | } |
| 32 | |
| 33 | @override |
| 34 | void didChangeAppLifecycleState(AppLifecycleState state) { |
| 35 | if (state == AppLifecycleState.resumed && !_busy) { |
| 36 | _run(() => widget.coordinator.refresh(widget.store)); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | Future<void> _run(Future<void> Function() work) async { |
| 41 | if (_busy) return; |
| 42 | setState(() => _busy = true); |
| 43 | try { |
| 44 | await work(); |
| 45 | } catch (_) {/* Coordinator shows a safe Persian error. */} finally { |
| 46 | if (mounted) setState(() => _busy = false); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | @override |
| 51 | Widget build(BuildContext context) => AnimatedBuilder( |
| 52 | animation: widget.coordinator, |
| 53 | builder: (context, _) { |
| 54 | final state = widget.coordinator.status; |
| 55 | return Scaffold( |
| 56 | appBar: AppBar(title: const Text('یادآوریهای من')), |
| 57 | body: SafeArea( |
| 58 | child: ListView(padding: const EdgeInsets.all(20), children: [ |
| 59 | const Text('یادآوری روی همین گوشی', |
| 60 | style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)), |
| 61 | const SizedBox(height: 12), |
| 62 | const Text( |
| 63 | 'وقتی زمان برنامهات برسد، همراهت یادت میاندازد. با اجازهٔ تو، نام همراه و یک پیام عمومی نمایش داده میشود؛ عنوان خصوصی برنامه روی اعلان نمیآید. اینترنت و سرور لازم نیست.'), |
| 64 | const SizedBox(height: 16), |
| 65 | if (widget.coordinator.error != null) |
| 66 | Card( |
| 67 | child: Padding( |
| 68 | padding: const EdgeInsets.all(16), |
| 69 | child: Text(widget.coordinator.error!))), |
| 70 | if (_busy) |
| 71 | const LinearProgressIndicator( |
| 72 | semanticsLabel: 'در حال بررسی یادآوری'), |
| 73 | if (state != null && !state.supported) |
| 74 | const Text( |
| 75 | 'یادآوری در این محیط در دسترس نیست؛ برنامهها همچنان روی گوشی ذخیره میشوند.'), |
| 76 | if (state != null && state.supported) ...[ |
| 77 | SwitchListTile.adaptive( |
| 78 | title: const Text('اعلان برنامههای من'), |
| 79 | subtitle: Text( |
| 80 | state.enabled ? 'انتخاب تو: روشن' : 'انتخاب تو: خاموش'), |
| 81 | value: state.enabled, |
| 82 | onChanged: _busy |
| 83 | ? null |
| 84 | : (value) => _run(() => value |
| 85 | ? widget.coordinator.enable(widget.store) |
| 86 | : widget.coordinator.disable(widget.store)), |
| 87 | ), |
| 88 | Text(state.permissionGranted |
| 89 | ? 'مجوز اعلان: داده شده' |
| 90 | : 'مجوز اعلان: داده نشده. اجازهٔ اعلان را از تنظیمات اندروید بررسی کن.'), |
| 91 | const SizedBox(height: 12), |
| 92 | OutlinedButton.icon( |
| 93 | key: const Key('personal-notification-system-settings'), |
| 94 | style: |
| 95 | OutlinedButton.styleFrom(minimumSize: const Size(48, 48)), |
| 96 | onPressed: _busy |
| 97 | ? null |
| 98 | : () => _run(widget.coordinator.openNotificationSettings), |
| 99 | icon: const Icon(Icons.volume_up_outlined), |
| 100 | label: const Text('تنظیم صدا و اعلان در اندروید')), |
| 101 | const Text( |
| 102 | 'صدایی را انتخاب کن که دوست داری. تنظیم صدا و لرزش در اندروید انجام میشود؛ پس از برگشت، اجازهٔ اعلان دوباره بررسی میشود.'), |
| 103 | const SizedBox(height: 12), |
| 104 | Text('یادآوری آیندهٔ زمانبندیشده: ${state.scheduledCount}'), |
| 105 | Text(state.timing == 'exact' |
| 106 | ? 'زمانبندی دقیق در دسترس است.' |
| 107 | : 'زمانبندی تقریبی است؛ ممکن است اندروید اعلان را با تأخیر نشان دهد.'), |
| 108 | if (state.exactAlarmSupported && !state.canScheduleExactAlarms) |
| 109 | OutlinedButton.icon( |
| 110 | onPressed: _busy |
| 111 | ? null |
| 112 | : () => _run(() => widget.coordinator |
| 113 | .requestExactAccess(widget.store)), |
| 114 | icon: const Icon(Icons.alarm), |
| 115 | label: const Text('بررسی اجازهٔ زمانبندی دقیق')), |
| 116 | ], |
| 117 | const SizedBox(height: 20), |
| 118 | const Text('پوشش یادآوری', |
| 119 | style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), |
| 120 | const Text( |
| 121 | 'تا ۲۸ روز آینده و حداکثر ۱۲۸ نوبت نزدیکتر آماده میشود. برنامه را مرتب باز کن تا روزهای بعد هم آماده شوند. برای هر برنامه، زمان یادآوری را جدا انتخاب کن.'), |
| 122 | if (state != null && |
| 123 | state.eligibleCount > StandaloneReminderStatus.maximumReminders) |
| 124 | const Text( |
| 125 | 'تعداد نوبتها بیشتر از ظرفیت است؛ فعلاً فقط ۱۲۸ نوبت نزدیکتر آماده شدهاند.'), |
| 126 | const SizedBox(height: 12), |
| 127 | const Text( |
| 128 | 'خاموشکردن اجباری برنامه، تنظیم باتری، بیصدا بودن گوشی و مجوزهای اندروید میتوانند اعلان یا صدای آن را متوقف کنند. اعلان زمانبندیشده تضمین شنیدن آلارم نیست.'), |
| 129 | const SizedBox(height: 16), |
| 130 | OutlinedButton.icon( |
| 131 | onPressed: _busy |
| 132 | ? null |
| 133 | : () => |
| 134 | _run(() => widget.coordinator.refresh(widget.store)), |
| 135 | icon: const Icon(Icons.refresh), |
| 136 | label: const Text('بررسی دوباره')), |
| 137 | ])), |
| 138 | ); |
| 139 | }); |
| 140 | } |