mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
Fix authentication required when minimize app
This commit is contained in:
parent
7da2de60cb
commit
34cfe7591f
1 changed files with 10 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'package:cake_wallet/core/auth_service.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
|
@ -28,15 +30,18 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
|||
RootState()
|
||||
: _isInactiveController = StreamController<bool>.broadcast(),
|
||||
_isInactive = false,
|
||||
_requestAuth = getIt.get<AuthService>().requireAuth(),
|
||||
_postFrameCallback = false;
|
||||
|
||||
Stream<bool> get isInactive => _isInactiveController.stream;
|
||||
StreamController<bool> _isInactiveController;
|
||||
bool _isInactive;
|
||||
bool _postFrameCallback;
|
||||
bool _requestAuth;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
_isInactiveController = StreamController<bool>.broadcast();
|
||||
_isInactive = false;
|
||||
_postFrameCallback = false;
|
||||
|
@ -52,6 +57,10 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
|||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_requestAuth = getIt.get<AuthService>().requireAuth();
|
||||
});
|
||||
|
||||
if (!_isInactive &&
|
||||
widget.authenticationStore.state == AuthenticationState.allowed) {
|
||||
setState(() => _setInactive(true));
|
||||
|
@ -65,7 +74,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isInactive && !_postFrameCallback) {
|
||||
if (_isInactive && !_postFrameCallback && _requestAuth) {
|
||||
_postFrameCallback = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.navigatorKey.currentState?.pushNamed(Routes.unlock,
|
||||
|
|
Loading…
Reference in a new issue