mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
Transfer repository from Gitlab
This commit is contained in:
parent
af2efbdbbd
commit
568cc243f0
177 changed files with 13300 additions and 0 deletions
22
mobile/lib/routing/auth_guard.dart
Normal file
22
mobile/lib/routing/auth_guard.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:immich_mobile/shared/services/network.service.dart';
|
||||
|
||||
class AuthGuard extends AutoRouteGuard {
|
||||
final NetworkService _networkService = NetworkService();
|
||||
|
||||
@override
|
||||
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
||||
try {
|
||||
var res = await _networkService.postRequest(url: 'auth/validateToken');
|
||||
var jsonReponse = jsonDecode(res.toString());
|
||||
if (jsonReponse['authStatus']) {
|
||||
resolver.next(true);
|
||||
}
|
||||
} catch (e) {
|
||||
router.removeUntil((route) => route.name == "LoginRoute");
|
||||
}
|
||||
}
|
||||
}
|
||||
22
mobile/lib/routing/router.dart
Normal file
22
mobile/lib/routing/router.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:immich_mobile/modules/login/views/login_page.dart';
|
||||
import 'package:immich_mobile/modules/home/views/home_page.dart';
|
||||
import 'package:immich_mobile/routing/auth_guard.dart';
|
||||
import 'package:immich_mobile/shared/views/backup_controller_page.dart';
|
||||
import 'package:immich_mobile/shared/views/image_viewer_page.dart';
|
||||
|
||||
part 'router.gr.dart';
|
||||
|
||||
@MaterialAutoRouter(
|
||||
replaceInRouteName: 'Page,Route',
|
||||
routes: <AutoRoute>[
|
||||
AutoRoute(page: LoginPage, initial: true),
|
||||
AutoRoute(page: HomePage, guards: [AuthGuard]),
|
||||
AutoRoute(page: BackupControllerPage, guards: [AuthGuard]),
|
||||
AutoRoute(page: ImageViewerPage, guards: [AuthGuard]),
|
||||
],
|
||||
)
|
||||
class AppRouter extends _$AppRouter {
|
||||
AppRouter() : super(authGuard: AuthGuard());
|
||||
}
|
||||
122
mobile/lib/routing/router.gr.dart
Normal file
122
mobile/lib/routing/router.gr.dart
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
// **************************************************************************
|
||||
// AutoRouteGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
// **************************************************************************
|
||||
// AutoRouteGenerator
|
||||
// **************************************************************************
|
||||
//
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
part of 'router.dart';
|
||||
|
||||
class _$AppRouter extends RootStackRouter {
|
||||
_$AppRouter(
|
||||
{GlobalKey<NavigatorState>? navigatorKey, required this.authGuard})
|
||||
: super(navigatorKey);
|
||||
|
||||
final AuthGuard authGuard;
|
||||
|
||||
@override
|
||||
final Map<String, PageFactory> pagesMap = {
|
||||
LoginRoute.name: (routeData) {
|
||||
return MaterialPageX<dynamic>(
|
||||
routeData: routeData, child: const LoginPage());
|
||||
},
|
||||
HomeRoute.name: (routeData) {
|
||||
return MaterialPageX<dynamic>(
|
||||
routeData: routeData, child: const HomePage());
|
||||
},
|
||||
BackupControllerRoute.name: (routeData) {
|
||||
return MaterialPageX<dynamic>(
|
||||
routeData: routeData, child: const BackupControllerPage());
|
||||
},
|
||||
ImageViewerRoute.name: (routeData) {
|
||||
final args = routeData.argsAs<ImageViewerRouteArgs>();
|
||||
return MaterialPageX<dynamic>(
|
||||
routeData: routeData,
|
||||
child: ImageViewerPage(
|
||||
key: args.key,
|
||||
imageUrl: args.imageUrl,
|
||||
heroTag: args.heroTag,
|
||||
thumbnailUrl: args.thumbnailUrl));
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
List<RouteConfig> get routes => [
|
||||
RouteConfig(LoginRoute.name, path: '/'),
|
||||
RouteConfig(HomeRoute.name, path: '/home-page', guards: [authGuard]),
|
||||
RouteConfig(BackupControllerRoute.name,
|
||||
path: '/backup-controller-page', guards: [authGuard]),
|
||||
RouteConfig(ImageViewerRoute.name,
|
||||
path: '/image-viewer-page', guards: [authGuard])
|
||||
];
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [LoginPage]
|
||||
class LoginRoute extends PageRouteInfo<void> {
|
||||
const LoginRoute() : super(LoginRoute.name, path: '/');
|
||||
|
||||
static const String name = 'LoginRoute';
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [HomePage]
|
||||
class HomeRoute extends PageRouteInfo<void> {
|
||||
const HomeRoute() : super(HomeRoute.name, path: '/home-page');
|
||||
|
||||
static const String name = 'HomeRoute';
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [BackupControllerPage]
|
||||
class BackupControllerRoute extends PageRouteInfo<void> {
|
||||
const BackupControllerRoute()
|
||||
: super(BackupControllerRoute.name, path: '/backup-controller-page');
|
||||
|
||||
static const String name = 'BackupControllerRoute';
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [ImageViewerPage]
|
||||
class ImageViewerRoute extends PageRouteInfo<ImageViewerRouteArgs> {
|
||||
ImageViewerRoute(
|
||||
{Key? key,
|
||||
required String imageUrl,
|
||||
required String heroTag,
|
||||
required String thumbnailUrl})
|
||||
: super(ImageViewerRoute.name,
|
||||
path: '/image-viewer-page',
|
||||
args: ImageViewerRouteArgs(
|
||||
key: key,
|
||||
imageUrl: imageUrl,
|
||||
heroTag: heroTag,
|
||||
thumbnailUrl: thumbnailUrl));
|
||||
|
||||
static const String name = 'ImageViewerRoute';
|
||||
}
|
||||
|
||||
class ImageViewerRouteArgs {
|
||||
const ImageViewerRouteArgs(
|
||||
{this.key,
|
||||
required this.imageUrl,
|
||||
required this.heroTag,
|
||||
required this.thumbnailUrl});
|
||||
|
||||
final Key? key;
|
||||
|
||||
final String imageUrl;
|
||||
|
||||
final String heroTag;
|
||||
|
||||
final String thumbnailUrl;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ImageViewerRouteArgs{key: $key, imageUrl: $imageUrl, heroTag: $heroTag, thumbnailUrl: $thumbnailUrl}';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue