Merge pull request 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
commit 192d45e1b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 13 deletions

View file

@ -261,7 +261,7 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
final statusBarColor = Colors.transparent; final statusBarColor = Colors.transparent;
final authenticationStore = getIt.get<AuthenticationStore>(); final authenticationStore = getIt.get<AuthenticationStore>();
final initialRoute = final initialRoute =
authenticationStore.state == AuthenticationState.denied authenticationStore.state == AuthenticationState.uninitialized
? Routes.disclaimer ? Routes.disclaimer
: Routes.login; : Routes.login;
final currentTheme = settingsStore.currentTheme; final currentTheme = settingsStore.currentTheme;

View file

@ -22,9 +22,9 @@ Future<void> bootstrap(GlobalKey<NavigatorState> navigatorKey) async {
final currentWalletName = getIt final currentWalletName = getIt
.get<SharedPreferences>() .get<SharedPreferences>()
.getString(PreferencesKey.currentWalletName); .getString(PreferencesKey.currentWalletName);
authenticationStore.state = currentWalletName == null if (currentWalletName != null) {
? AuthenticationState.denied authenticationStore.state = AuthenticationState.installed;
: AuthenticationState.installed; }
startAuthenticationStateChange(authenticationStore, navigatorKey); startAuthenticationStateChange(authenticationStore, navigatorKey);
startCurrentWalletChangeReaction( startCurrentWalletChangeReaction(

View file

@ -26,10 +26,5 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false); await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
return; return;
} }
if (state == AuthenticationState.denied) {
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
return;
}
}); });
} }

View file

@ -4,7 +4,7 @@ part 'authentication_store.g.dart';
class AuthenticationStore = AuthenticationStoreBase with _$AuthenticationStore; class AuthenticationStore = AuthenticationStoreBase with _$AuthenticationStore;
enum AuthenticationState { uninitialized, installed, allowed, denied } enum AuthenticationState { uninitialized, installed, allowed }
abstract class AuthenticationStoreBase with Store { abstract class AuthenticationStoreBase with Store {
AuthenticationStoreBase() : state = AuthenticationState.uninitialized; AuthenticationStoreBase() : state = AuthenticationState.uninitialized;
@ -17,7 +17,4 @@ abstract class AuthenticationStoreBase with Store {
@action @action
void allowed() => state = AuthenticationState.allowed; void allowed() => state = AuthenticationState.allowed;
@action
void denied() => state = AuthenticationState.denied;
} }