2023-02-28 18:22:18 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
import 'package:immich_mobile/modules/onboarding/providers/gallery_permission.provider.dart';
|
|
|
|
import 'package:immich_mobile/routing/router.dart';
|
|
|
|
|
2023-11-14 22:30:27 +02:00
|
|
|
class BackupPermissionGuard extends AutoRouteGuard {
|
2023-02-28 18:22:18 +02:00
|
|
|
final GalleryPermissionNotifier _permission;
|
|
|
|
|
2023-11-14 22:30:27 +02:00
|
|
|
BackupPermissionGuard(this._permission);
|
2023-02-28 18:22:18 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
|
|
|
final p = _permission.hasPermission;
|
|
|
|
if (p) {
|
|
|
|
resolver.next(true);
|
|
|
|
} else {
|
2023-11-14 22:30:27 +02:00
|
|
|
router.push(const PermissionOnboardingRoute());
|
2023-02-28 18:22:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|