cake_wallet/lib/reactions/bootstrap.dart

35 lines
1.5 KiB
Dart
Raw Normal View History

2020-08-29 10:19:27 +00:00
import 'dart:async';
2020-09-14 12:08:33 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
2020-06-20 07:10:00 +00:00
import 'package:shared_preferences/shared_preferences.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/reactions/on_authentication_state_change.dart';
import 'package:cake_wallet/reactions/on_current_fiat_change.dart';
import 'package:cake_wallet/reactions/on_current_wallet_change.dart';
2020-06-20 07:10:00 +00:00
import 'package:cake_wallet/store/app_store.dart';
import 'package:cake_wallet/store/settings_store.dart';
2020-06-20 07:10:00 +00:00
import 'package:cake_wallet/store/authentication_store.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
2020-06-20 07:10:00 +00:00
2020-09-21 11:50:26 +00:00
Future<void> bootstrap(GlobalKey<NavigatorState> navigatorKey) async {
2020-06-20 07:10:00 +00:00
final appStore = getIt.get<AppStore>();
final authenticationStore = getIt.get<AuthenticationStore>();
final settingsStore = getIt.get<SettingsStore>();
2020-09-21 11:50:26 +00:00
final fiatConversionStore = getIt.get<FiatConversionStore>();
2020-06-20 07:10:00 +00:00
if (authenticationStore.state == AuthenticationState.uninitialized) {
2020-09-21 11:50:26 +00:00
authenticationStore.state = getIt
.get<SharedPreferences>()
.getString(PreferencesKey.currentWalletName) ==
null
? AuthenticationState.denied
: AuthenticationState.installed;
2020-06-20 07:10:00 +00:00
}
2020-09-21 11:50:26 +00:00
startAuthenticationStateChange(authenticationStore, navigatorKey);
startCurrentWalletChangeReaction(
appStore, settingsStore, fiatConversionStore);
startCurrentFiatChangeReaction(appStore, settingsStore);
2020-06-20 07:10:00 +00:00
}