This commit is contained in:
J. A. Messias 2024-10-09 16:24:46 -03:00
parent 36931e14b0
commit 6fe32d8d7c
4 changed files with 34 additions and 61 deletions

View File

@ -42,10 +42,11 @@ class AppStateNotifier extends ChangeNotifier {
} }
GoRouter createRouter(AppStateNotifier appStateNotifier) { GoRouter createRouter(AppStateNotifier appStateNotifier) {
final bool? isLogged = StorageUtil().isLogged; final bool isLogged = StorageUtil().isLogged;
final bool? haveLocal = StorageUtil().haveLocal; final bool? haveLocal = StorageUtil().haveLocal;
final bool haveUserUUID = StorageUtil().userUUID.isNotEmpty; final bool haveUserUUID = StorageUtil().userUUID.isNotEmpty;
final bool haveDevUUID = StorageUtil().devUUID.isNotEmpty; final bool haveDevUUID = StorageUtil().devUUID.isNotEmpty;
final bool isRecovered = StorageUtil().isRecovered;
log('() => isLogged: $isLogged'); log('() => isLogged: $isLogged');
log('() => haveLocal: $haveLocal'); log('() => haveLocal: $haveLocal');
@ -84,11 +85,11 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) {
FFRoute( FFRoute(
name: '_initialize', name: '_initialize',
path: '/', path: '/',
builder: (context, _) => isLogged == true && haveDevUUID && haveUserUUID builder: (context, _) => isLogged && haveDevUUID && haveUserUUID
? haveLocal == true ? haveLocal == true
? const HomePageWidget() ? const HomePageWidget()
: const ReceptionPageWidget() : const ReceptionPageWidget()
: const WelcomePageWidget(), : const WelcomePageWidget()
), ),
FFRoute( FFRoute(
name: 'forgotPassword', name: 'forgotPassword',

View File

@ -16,6 +16,7 @@ import 'package:hub/backend/notifications/notification_service.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart';
import 'package:hub/shared/utils/storage_util.dart'; import 'package:hub/shared/utils/storage_util.dart';
import 'package:responsive_framework/responsive_framework.dart'; import 'package:responsive_framework/responsive_framework.dart';
@ -185,23 +186,29 @@ class _AppState extends State<App> {
Future<void> initDeepLinks() async { Future<void> initDeepLinks() async {
_appLinks = AppLinks(); _appLinks = AppLinks();
_linkSubscription = _appLinks.uriLinkStream.listen((uri) { _linkSubscription = _appLinks.uriLinkStream.listen((uri) {
final bool isRecovered = StorageUtil().isRecovered; final bool isRecovered = !StorageUtil().isRecovered;
if (isRecovered) openAppLink(uri); if (isRecovered) openAppLink(uri);
}); });
} }
void openAppLink(Uri uri) { void openAppLink(Uri uri) {
final bool isRecovered = !StorageUtil().isRecovered; final bool isRecovered = StorageUtil().isRecovered;
if(isRecovered) return; if(isRecovered) return;
StorageUtil().isRecovered = false; StorageUtil().isRecovered = true;
final String email = uri.queryParameters['email'] ?? ''; final String email = uri.queryParameters['email'] ?? '';
final String token = uri.queryParameters['token'] ?? ''; final String token = uri.queryParameters['token'] ?? '';
final BuildContext context = StorageUtil().context!; final BuildContext context = StorageUtil().context!;
final Future<Object?> Function(String, {Object? extra}) nav = context.push;
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty; final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
log('openAppLink: $uri'); log('openAppLink: $uri');
if (isNotEmpty) nav('/forgotPassword', extra: {'email': email, 'token': token}); if (isNotEmpty)
showModalBottomSheet(
context: context,
builder: (context) => ForgotPasswordScreen(email: email, token: token),
showDragHandle: true,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
)
.then((_) => StorageUtil().isRecovered = false);
// Use the extracted email and token as needed // Use the extracted email and token as needed
// navigatorKey.currentState?.pushNamed('/forgotPassword', arguments: {'email': email, 'token': token}); // navigatorKey.currentState?.pushNamed('/forgotPassword', arguments: {'email': email, 'token': token});

View File

@ -90,50 +90,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
} }
@override Widget build(BuildContext context) { @override Widget build(BuildContext context) {
final MediaQueryData mediaQuery = MediaQuery.of(context); final MediaQueryData mediaQuery = MediaQuery.of(context);
return Scaffold( return buildBody(context);
appBar: buildAppBar(context),
body: buildBody(context),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
automaticallyImplyLeading: false,
forceMaterialTransparency: true,
leading: FlutterFlowIconButton(
borderColor: Colors.transparent,
borderRadius: 30.0,
borderWidth: 1.0,
buttonSize: 60.0,
icon: Icon(
Icons.keyboard_arrow_left,
color: FlutterFlowTheme.of(context).primaryText,
size: 30.0,
),
onPressed: () async {
context.pop();
StorageUtil().isRecovered = true;
},
),
title: Text(
FFLocalizations.of(context).getVariableText(
ptText: 'Recuperar Senha',
enText: 'Recover Password',
),
style: FlutterFlowTheme.of(context).headlineMedium.override(
fontFamily: 'Nunito',
color: FlutterFlowTheme.of(context).primaryText,
fontSize: 15.0,
fontWeight: FontWeight.bold,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
),
),
actions: const [],
centerTitle: true,
elevation: 0.0,
);
} }
Row buildBody(BuildContext context) { Row buildBody(BuildContext context) {

View File

@ -141,12 +141,12 @@ class StorageUtil {
_email = await _secureStorage.getString('ff_email'); _email = await _secureStorage.getString('ff_email');
_passwd = await _secureStorage.getString('ff_passwd'); _passwd = await _secureStorage.getString('ff_passwd');
_deviceType = await _secureStorage.getString('ff_deviceType'); _deviceType = await _secureStorage.getString('ff_deviceType');
_isLogged = await _secureStorage.getBool('ff_isLogged'); _isLogged = await _secureStorage.getBool('ff_isLogged') ?? false;
_tokenAPNS = await _secureStorage.getString('ff_tokenAPNS'); _tokenAPNS = await _secureStorage.getString('ff_tokenAPNS');
_accessPass = await _secureStorage.getString('accessPass'); _accessPass = await _secureStorage.getString('accessPass');
_panicPass = await _secureStorage.getString('panicPass'); _panicPass = await _secureStorage.getString('panicPass');
_fingerprintPass = await _secureStorage.getString('fingerprintPass'); _fingerprintPass = await _secureStorage.getString('fingerprintPass');
_haveLocal = await _secureStorage.getBool('ff_have_local'); _haveLocal = await _secureStorage.getBool('ff_have_local') ?? false;
_deviceDescription = await _secureStorage.getString('deviceDescription'); _deviceDescription = await _secureStorage.getString('deviceDescription');
} catch (e) { } catch (e) {
log('SecureStorageHelper: Error during initialization: $e'); log('SecureStorageHelper: Error during initialization: $e');
@ -184,10 +184,18 @@ class StorageUtil {
log('SQLiteStorageHelper: Initialization complete'); log('SQLiteStorageHelper: Initialization complete');
} }
bool _isRecovered = true; bool _isRecovered = false;
bool get isRecovered => _isRecovered; bool get isRecovered => _isRecovered;
set isRecovered(bool value) => _isRecovered = value; set isRecovered(bool value) => _isRecovered = value;
String _tempMail = '';
String get tempMail => _tempMail;
set tempMail(String value) => _tempMail = value;
String _tempToken = '';
String get tempToken => _tempToken;
set tempToken(String value) => _tempToken = value;
bool _isFirstRun = true; bool _isFirstRun = true;
@ -212,9 +220,9 @@ class StorageUtil {
_secureStorage.set('ff_context', value.toString(), (v) => _context = value); _secureStorage.set('ff_context', value.toString(), (v) => _context = value);
} }
bool? _haveLocal; bool _haveLocal = false;
bool? get haveLocal => _haveLocal; bool get haveLocal => _haveLocal;
set haveLocal(bool? value) { set haveLocal(bool value) {
_haveLocal = value; _haveLocal = value;
_secureStorage.set( _secureStorage.set(
'ff_have_local', value ?? false, (v) => _haveLocal = value); 'ff_have_local', value ?? false, (v) => _haveLocal = value);
@ -269,9 +277,9 @@ class StorageUtil {
_secureStorage.set('ff_deviceType', value, (v) => _deviceType = v); _secureStorage.set('ff_deviceType', value, (v) => _deviceType = v);
} }
bool? _isLogged; bool _isLogged = false;
bool? get isLogged => _isLogged; bool get isLogged => _isLogged;
set isLogged(bool? value) { set isLogged(bool value) {
_isLogged = value; _isLogged = value;
_secureStorage.set('ff_isLogged', value, (v) => _isLogged = v); _secureStorage.set('ff_isLogged', value, (v) => _isLogged = v);
} }