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
| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter/scheduler.dart'; |
| 3 | |
| 4 | /// Owns one native custom-view route. Provider hide events must never pop an |
| 5 | /// unrelated app route, and a user Back/close must return the native view. |
| 6 | class AparatFullscreenPresenter { |
| 7 | AparatFullscreenPresenter({required this.navigator}); |
| 8 | |
| 9 | final NavigatorState navigator; |
| 10 | Route<void>? _route; |
| 11 | VoidCallback? _returnNativeView; |
| 12 | bool _disposed = false; |
| 13 | |
| 14 | void show(Widget view, VoidCallback returnNativeView) { |
| 15 | if (_disposed || !navigator.mounted) { |
| 16 | returnNativeView(); |
| 17 | return; |
| 18 | } |
| 19 | _dismiss(notifyNative: true); |
| 20 | late final Route<void> route; |
| 21 | route = MaterialPageRoute<void>( |
| 22 | fullscreenDialog: true, |
| 23 | builder: (_) => Scaffold( |
| 24 | backgroundColor: Colors.black, |
| 25 | body: SafeArea( |
| 26 | child: Stack(fit: StackFit.expand, children: [ |
| 27 | view, |
| 28 | Positioned( |
| 29 | top: 8, |
| 30 | right: 8, |
| 31 | child: IconButton.filled( |
| 32 | tooltip: 'خروج از تمامصفحه', |
| 33 | icon: const Icon(Icons.close), |
| 34 | onPressed: () { |
| 35 | if (_route == route) _dismiss(notifyNative: true); |
| 36 | })) |
| 37 | ])))); |
| 38 | _route = route; |
| 39 | _returnNativeView = returnNativeView; |
| 40 | navigator.push(route).then((_) { |
| 41 | // System Back already removed this route. A later provider hide cannot |
| 42 | // remove the app page beneath it. |
| 43 | if (_route != route) return; |
| 44 | final callback = _returnNativeView; |
| 45 | _route = null; |
| 46 | _returnNativeView = null; |
| 47 | callback?.call(); |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | /// The provider has already hidden the native custom view. |
| 52 | void hide() => _dismiss(notifyNative: false); |
| 53 | |
| 54 | void _dismiss({required bool notifyNative}) { |
| 55 | final route = _route; |
| 56 | final callback = _returnNativeView; |
| 57 | _route = null; |
| 58 | _returnNativeView = null; |
| 59 | if (notifyNative) callback?.call(); |
| 60 | if (route == null) return; |
| 61 | void removeOwnedRoute() { |
| 62 | if (navigator.mounted && route.isActive) navigator.removeRoute(route); |
| 63 | } |
| 64 | |
| 65 | // View disposal can happen during a build/lifecycle update. Route removal |
| 66 | // then waits for that frame, while ownership is revoked immediately. |
| 67 | final phase = SchedulerBinding.instance.schedulerPhase; |
| 68 | if (phase == SchedulerPhase.persistentCallbacks || |
| 69 | phase == SchedulerPhase.midFrameMicrotasks) { |
| 70 | WidgetsBinding.instance.addPostFrameCallback((_) => removeOwnedRoute()); |
| 71 | } else { |
| 72 | removeOwnedRoute(); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void dispose() { |
| 77 | _disposed = true; |
| 78 | _dismiss(notifyNative: true); |
| 79 | } |
| 80 | } |