mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 20:19:25 +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 'dart:async';
|
||||||
|
import 'package:cake_wallet/core/auth_service.dart';
|
||||||
|
import 'package:cake_wallet/di.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||||
|
@ -28,15 +30,18 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||||
RootState()
|
RootState()
|
||||||
: _isInactiveController = StreamController<bool>.broadcast(),
|
: _isInactiveController = StreamController<bool>.broadcast(),
|
||||||
_isInactive = false,
|
_isInactive = false,
|
||||||
|
_requestAuth = getIt.get<AuthService>().requireAuth(),
|
||||||
_postFrameCallback = false;
|
_postFrameCallback = false;
|
||||||
|
|
||||||
Stream<bool> get isInactive => _isInactiveController.stream;
|
Stream<bool> get isInactive => _isInactiveController.stream;
|
||||||
StreamController<bool> _isInactiveController;
|
StreamController<bool> _isInactiveController;
|
||||||
bool _isInactive;
|
bool _isInactive;
|
||||||
bool _postFrameCallback;
|
bool _postFrameCallback;
|
||||||
|
bool _requestAuth;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
||||||
_isInactiveController = StreamController<bool>.broadcast();
|
_isInactiveController = StreamController<bool>.broadcast();
|
||||||
_isInactive = false;
|
_isInactive = false;
|
||||||
_postFrameCallback = false;
|
_postFrameCallback = false;
|
||||||
|
@ -52,6 +57,10 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_requestAuth = getIt.get<AuthService>().requireAuth();
|
||||||
|
});
|
||||||
|
|
||||||
if (!_isInactive &&
|
if (!_isInactive &&
|
||||||
widget.authenticationStore.state == AuthenticationState.allowed) {
|
widget.authenticationStore.state == AuthenticationState.allowed) {
|
||||||
setState(() => _setInactive(true));
|
setState(() => _setInactive(true));
|
||||||
|
@ -65,7 +74,7 @@ class RootState extends State<Root> with WidgetsBindingObserver {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_isInactive && !_postFrameCallback) {
|
if (_isInactive && !_postFrameCallback && _requestAuth) {
|
||||||
_postFrameCallback = true;
|
_postFrameCallback = true;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
widget.navigatorKey.currentState?.pushNamed(Routes.unlock,
|
widget.navigatorKey.currentState?.pushNamed(Routes.unlock,
|
||||||
|
|
Loading…
Reference in a new issue