|
|
|
|
@ -62,6 +62,26 @@ class _SplashPageState extends State<SplashPage> {
|
|
|
|
|
//
|
|
|
|
|
// }, (id, title, body, payload) async {});
|
|
|
|
|
super.initState();
|
|
|
|
|
initApp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void initApp() {
|
|
|
|
|
// Start splash logic after a delay
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
bool isSafe = await checkDeviceSafety();
|
|
|
|
|
|
|
|
|
|
if (!isSafe) {
|
|
|
|
|
Navigator.pushNamedAndRemoveUntil(context, UnsafeDeviceScreen.routeName, (_) => false);
|
|
|
|
|
} else {
|
|
|
|
|
if (_settingProvider.isLoaded && (_settingProvider.user != null)) {
|
|
|
|
|
checkTokenValidity(_settingProvider.user!.token!);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void checkTokenValidity(String token) async {
|
|
|
|
|
@ -185,23 +205,6 @@ class _SplashPageState extends State<SplashPage> {
|
|
|
|
|
_settingProvider = Provider.of<SettingProvider>(context, listen: false);
|
|
|
|
|
_userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
|
|
|
|
|
// Start splash logic after a delay
|
|
|
|
|
Future.delayed(const Duration(seconds: 2), () async {
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
bool isSafe = await checkDeviceSafety();
|
|
|
|
|
|
|
|
|
|
if (!isSafe) {
|
|
|
|
|
Navigator.pushNamedAndRemoveUntil(context, UnsafeDeviceScreen.routeName, (_) => false);
|
|
|
|
|
} else {
|
|
|
|
|
if (_settingProvider.isLoaded && (_settingProvider.user != null)) {
|
|
|
|
|
checkTokenValidity(_settingProvider.user!.token!);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
body: Stack(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
|