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/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'; import 'package:cake_wallet/src/domain/common/qr_scanner.dart'; import 'package:cake_wallet/src/domain/services/user_service.dart'; import 'package:cake_wallet/src/domain/services/wallet_list_service.dart'; import 'package:cake_wallet/src/domain/services/wallet_service.dart'; import 'package:cake_wallet/src/domain/exchange/trade.dart'; import 'package:cake_wallet/src/domain/monero/transaction_description.dart'; import 'package:cake_wallet/src/screens/auth/create_login_page.dart'; import 'package:cake_wallet/src/screens/dashboard/create_dashboard_page.dart'; 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, this.authenticationStore, this.appStore, this.child}) : super(key: key); final AuthenticationStore authenticationStore; final AppStore appStore; final Widget child; @override RootState createState() => RootState(); } class RootState extends State with WidgetsBindingObserver { bool _isInactive; bool _postFrameCallback; // GlobalKey _navKey; @override void initState() { _isInactive = false; _postFrameCallback = false; WidgetsBinding.instance.addObserver(this); // WidgetsBinding.instance.addPostFrameCallback((_) { // _navKey.currentState.pushNamed(Routes.login); // }); super.initState(); } @override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.paused: if (isQrScannerShown) { return; } // if (!_isInactive && // widget.authenticationStore.state == // AuthenticationState.authenticated || // widget.authenticationStore.state == AuthenticationState.active) { // setState(() => _isInactive = true); // } break; default: break; } } @override Widget build(BuildContext context) { return widget.child; // _authenticationStore = Provider.of(context); // final sharedPreferences = Provider.of(context); // final walletListService = Provider.of(context); // final walletService = Provider.of(context); // final userService = Provider.of(context); // final priceStore = Provider.of(context); // final authenticationStore = Provider.of(context); // final trades = Provider.of>(context); // final transactionDescriptions = // Provider.of>(context); // final walletStore = Provider.of(context); // final settingsStore = Provider.of(context); // if (_isInactive && !_postFrameCallback) { // _postFrameCallback = true; // WidgetsBinding.instance.addPostFrameCallback((_) { // Navigator.of(context).pushNamed(Routes.unlock, // arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) { // if (!isAuthenticatedSuccessfully) { // return; // } // setState(() { // _postFrameCallback = false; // _isInactive = false; // }); // auth.close(); // }); // }); // } // return Navigator( // key: _navKey, // initialRoute: Routes.welcome, // onGenerateRoute: Router.generateRoute( // sharedPreferences: sharedPreferences, // walletListService: walletListService, // walletService: walletService, // userService: userService, // settings: settings, // priceStore: priceStore, // walletStore: walletStore, // syncStore: syncStore, // balanceStore: balanceStore, // settingsStore: settingsStore, // contacts: contacts, // nodes: nodes, // trades: trades, // transactionDescriptions: transactionDescriptions), // ); // return Observer(builder: (_) { // final state = widget.authenticationStore.state; // if (state == AuthenticationState.denied) { // return createWelcomePage(); // } // if (state == AuthenticationState.installed) { // return getIt.get(instanceName: 'login'); // } // if (state == AuthenticationState.allowed) { // return getIt.get(); // } // 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); // }); } }