79 lines
2.4 KiB
Dart
79 lines
2.4 KiB
Dart
import 'package:get/get.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../../features/auth/views/phone_input_view.dart';
|
|
import '../../features/auth/views/otp_verify_view.dart';
|
|
import '../../features/auth/views/biometric_setup_view.dart';
|
|
import '../../features/auth/views/biometric_auth_view.dart';
|
|
import '../../features/dashboard/views/dashboard_view.dart';
|
|
import '../../features/dashboard/controllers/dashboard_controller.dart';
|
|
import '../../features/scanner/views/scanner_view.dart';
|
|
import '../../features/scanner/controllers/scanner_controller.dart';
|
|
import '../../core/storage/secure_storage.dart';
|
|
|
|
part 'app_routes.dart';
|
|
|
|
class AppPages {
|
|
static const INITIAL = AppRoutes.SPLASH;
|
|
|
|
static final routes = [
|
|
GetPage(
|
|
name: AppRoutes.SPLASH,
|
|
page: () {
|
|
// Check login state after a short delay
|
|
Future.delayed(const Duration(seconds: 2), () async {
|
|
final token = await SecureStorage().getToken();
|
|
if (token != null && token.isNotEmpty) {
|
|
// User is already logged in, request Biometric unlock before dashboard
|
|
Get.offAllNamed(AppRoutes.BIOMETRIC_AUTH);
|
|
} else {
|
|
// New user, go to login
|
|
Get.offAllNamed(AppRoutes.PHONE_INPUT);
|
|
}
|
|
});
|
|
return const Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(Icons.security, size: 100, color: Color(0xFF0F4C81)),
|
|
SizedBox(height: 24),
|
|
CircularProgressIndicator(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
GetPage(
|
|
name: AppRoutes.PHONE_INPUT,
|
|
page: () => PhoneInputView(),
|
|
),
|
|
GetPage(
|
|
name: AppRoutes.OTP_VERIFY,
|
|
page: () => OtpVerifyView(),
|
|
),
|
|
GetPage(
|
|
name: AppRoutes.BIOMETRIC_SETUP,
|
|
page: () => BiometricSetupView(),
|
|
),
|
|
GetPage(
|
|
name: AppRoutes.BIOMETRIC_AUTH,
|
|
page: () => const BiometricAuthView(),
|
|
),
|
|
GetPage(
|
|
name: AppRoutes.DASHBOARD,
|
|
page: () => const DashboardView(),
|
|
binding: BindingsBuilder(() {
|
|
Get.put(DashboardController());
|
|
}),
|
|
),
|
|
GetPage(
|
|
name: AppRoutes.SCANNER,
|
|
page: () => const ScannerView(),
|
|
binding: BindingsBuilder(() {
|
|
Get.put(ScannerController());
|
|
}),
|
|
),
|
|
];
|
|
}
|