mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-04 12:34:14 +01:00
TMP 4
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
|
||||
//import 'package:cake_wallet/src/stores/authentication/authentication_store.dart';
|
||||
import 'package:cake_wallet/src/stores/price/price_store.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
@@ -21,7 +26,10 @@ import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/screens/welcome/create_welcome_page.dart';
|
||||
|
||||
class Root extends StatefulWidget {
|
||||
Root({Key key}) : super(key: key);
|
||||
Root({Key key, this.authenticationStore, this.appStore}) : super(key: key);
|
||||
|
||||
final AuthenticationStore authenticationStore;
|
||||
final AppStore appStore;
|
||||
|
||||
@override
|
||||
RootState createState() => RootState();
|
||||
@@ -30,7 +38,6 @@ class Root extends StatefulWidget {
|
||||
class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
bool _isInactive;
|
||||
bool _postFrameCallback;
|
||||
AuthenticationStore _authenticationStore;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -48,12 +55,12 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_isInactive &&
|
||||
_authenticationStore.state ==
|
||||
AuthenticationState.authenticated ||
|
||||
_authenticationStore.state == AuthenticationState.active) {
|
||||
setState(() => _isInactive = true);
|
||||
}
|
||||
// if (!_isInactive &&
|
||||
// widget.authenticationStore.state ==
|
||||
// AuthenticationState.authenticated ||
|
||||
// widget.authenticationStore.state == AuthenticationState.active) {
|
||||
// setState(() => _isInactive = true);
|
||||
// }
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -63,18 +70,18 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_authenticationStore = Provider.of<AuthenticationStore>(context);
|
||||
final sharedPreferences = Provider.of<SharedPreferences>(context);
|
||||
final walletListService = Provider.of<WalletListService>(context);
|
||||
final walletService = Provider.of<WalletService>(context);
|
||||
final userService = Provider.of<UserService>(context);
|
||||
final priceStore = Provider.of<PriceStore>(context);
|
||||
final authenticationStore = Provider.of<AuthenticationStore>(context);
|
||||
final trades = Provider.of<Box<Trade>>(context);
|
||||
final transactionDescriptions =
|
||||
Provider.of<Box<TransactionDescription>>(context);
|
||||
final walletStore = Provider.of<WalletStore>(context);
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
// _authenticationStore = Provider.of<AuthenticationStore>(context);
|
||||
// final sharedPreferences = Provider.of<SharedPreferences>(context);
|
||||
// final walletListService = Provider.of<WalletListService>(context);
|
||||
// final walletService = Provider.of<WalletService>(context);
|
||||
// final userService = Provider.of<UserService>(context);
|
||||
// final priceStore = Provider.of<PriceStore>(context);
|
||||
// final authenticationStore = Provider.of<AuthenticationStore>(context);
|
||||
// final trades = Provider.of<Box<Trade>>(context);
|
||||
// final transactionDescriptions =
|
||||
// Provider.of<Box<TransactionDescription>>(context);
|
||||
// final walletStore = Provider.of<WalletStore>(context);
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
if (_isInactive && !_postFrameCallback) {
|
||||
_postFrameCallback = true;
|
||||
@@ -96,38 +103,51 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||
}
|
||||
|
||||
return Observer(builder: (_) {
|
||||
final state = _authenticationStore.state;
|
||||
final state = widget.authenticationStore.state;
|
||||
print(state);
|
||||
if (state == AuthenticationState.denied) {
|
||||
return createWelcomePage();
|
||||
}
|
||||
|
||||
if (state == AuthenticationState.readyToLogin) {
|
||||
return createLoginPage(
|
||||
sharedPreferences: sharedPreferences,
|
||||
userService: userService,
|
||||
walletService: walletService,
|
||||
walletListService: walletListService,
|
||||
authenticationStore: authenticationStore);
|
||||
if (state == AuthenticationState.installed) {
|
||||
return getIt.get<AuthPage>();
|
||||
}
|
||||
|
||||
if (state == AuthenticationState.authenticated ||
|
||||
state == AuthenticationState.restored) {
|
||||
return createDashboardPage(
|
||||
walletService: walletService,
|
||||
priceStore: priceStore,
|
||||
trades: trades,
|
||||
transactionDescriptions: transactionDescriptions,
|
||||
walletStore: walletStore,
|
||||
settingsStore: settingsStore);
|
||||
if (state == AuthenticationState.allowed) {
|
||||
return getIt.get<DashboardPage>();
|
||||
}
|
||||
|
||||
if (state == AuthenticationState.created) {
|
||||
return createSeedPage(
|
||||
settingsStore: settingsStore,
|
||||
walletService: walletService,
|
||||
callback: () =>
|
||||
_authenticationStore.state = AuthenticationState.authenticated);
|
||||
}
|
||||
// if (state == AuthenticationState.denied) {
|
||||
// return createWelcomePage();
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.readyToLogin) {
|
||||
// return createLoginPage(
|
||||
// sharedPreferences: sharedPreferences,
|
||||
// userService: userService,
|
||||
// walletService: walletService,
|
||||
// walletListService: walletListService,
|
||||
// authenticationStore: authenticationStore);
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.authenticated ||
|
||||
// state == AuthenticationState.restored) {
|
||||
// return createDashboardPage(
|
||||
// walletService: walletService,
|
||||
// priceStore: priceStore,
|
||||
// trades: trades,
|
||||
// transactionDescriptions: transactionDescriptions,
|
||||
// walletStore: walletStore,
|
||||
// settingsStore: settingsStore);
|
||||
// }
|
||||
|
||||
// if (state == AuthenticationState.created) {
|
||||
// return createSeedPage(
|
||||
// settingsStore: settingsStore,
|
||||
// walletService: walletService,
|
||||
// callback: () =>
|
||||
// _authenticationStore.state = AuthenticationState.authenticated);
|
||||
// }
|
||||
|
||||
return Container(color: Colors.white);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user