Merge pull request #665 from cake-tech/fix-navigation-error-on-app-first-open

Fix navigation error on app first open
This commit is contained in:
Omar Hatem
2022-12-08 01:26:07 +02:00
committed by GitHub
4 changed files with 5 additions and 13 deletions
+1 -1
View File
@@ -261,7 +261,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
final statusBarColor = Colors.transparent;
final authenticationStore = getIt.get<AuthenticationStore>();
final initialRoute =
authenticationStore.state == AuthenticationState.denied
authenticationStore.state == AuthenticationState.uninitialized
? Routes.disclaimer
: Routes.login;
final currentTheme = settingsStore.currentTheme;
+3 -3
View File
@@ -22,9 +22,9 @@ Future<void> bootstrap(GlobalKey<NavigatorState> navigatorKey) async {
final currentWalletName = getIt
.get<SharedPreferences>()
.getString(PreferencesKey.currentWalletName);
authenticationStore.state = currentWalletName == null
? AuthenticationState.denied
: AuthenticationState.installed;
if (currentWalletName != null) {
authenticationStore.state = AuthenticationState.installed;
}
startAuthenticationStateChange(authenticationStore, navigatorKey);
startCurrentWalletChangeReaction(
@@ -26,10 +26,5 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
return;
}
if (state == AuthenticationState.denied) {
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
return;
}
});
}
+1 -4
View File
@@ -4,7 +4,7 @@ part 'authentication_store.g.dart';
class AuthenticationStore = AuthenticationStoreBase with _$AuthenticationStore;
enum AuthenticationState { uninitialized, installed, allowed, denied }
enum AuthenticationState { uninitialized, installed, allowed }
abstract class AuthenticationStoreBase with Store {
AuthenticationStoreBase() : state = AuthenticationState.uninitialized;
@@ -17,7 +17,4 @@ abstract class AuthenticationStoreBase with Store {
@action
void allowed() => state = AuthenticationState.allowed;
@action
void denied() => state = AuthenticationState.denied;
}