WIP: debug tests

This commit is contained in:
J. A. Messias 2024-11-18 09:05:27 -03:00
parent dbac63d2ea
commit c2d54b6b3f
3 changed files with 24 additions and 11 deletions

View File

@ -10,6 +10,7 @@
<meta-data <meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id" android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id" /> android:value="@string/default_notification_channel_id" />
<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />
<application <application
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:label="FRE ACCESS HUB" android:label="FRE ACCESS HUB"

View File

@ -22,6 +22,7 @@ import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/services/localization/localization_service.dart'; import 'package:hub/shared/services/localization/localization_service.dart';
import 'package:hub/shared/utils/device_util.dart'; import 'package:hub/shared/utils/device_util.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:responsive_framework/responsive_framework.dart'; import 'package:responsive_framework/responsive_framework.dart';
import 'backend/notifications/firebase_messaging_service.dart'; import 'backend/notifications/firebase_messaging_service.dart';
@ -181,16 +182,22 @@ class _AppState extends State<App> with WidgetsBindingObserver {
}; };
Future<void> initDeepLinks() async { Future<void> initDeepLinks() async {
_appLinks = AppLinks(); try {
_linkSubscription = _appLinks.uriLinkStream.listen((uri) { _appLinks = AppLinks();
final bool isRecovered = StorageHelper().isRecovered; _linkSubscription = _appLinks.uriLinkStream.listen((uri) async {
if (!isRecovered) openAppLink(uri); final bool isRecovered = StorageHelper().isRecovered;
}); await DialogUtil.error(context, 'isRecovered: $isRecovered');
if (!isRecovered) await openAppLink(uri);
});
} catch (e) {
await DialogUtil.error(context, 'Erro ao tentar abrir o link');
}
} }
void openAppLink(Uri uri) { Future<void> openAppLink(Uri uri) async {
final bool isRecovered = StorageHelper().isRecovered; final bool isRecovered = StorageHelper().isRecovered;
log('isRecovered: $isRecovered'); log('isRecovered: $isRecovered');
await DialogUtil.warning(context, 'isRecovered: $isRecovered');
if (isRecovered) return; if (isRecovered) return;
StorageHelper().isRecovered = true; StorageHelper().isRecovered = true;
final String email = uri.queryParameters['email'] ?? ''; final String email = uri.queryParameters['email'] ?? '';
@ -201,7 +208,8 @@ class _AppState extends State<App> with WidgetsBindingObserver {
final FlutterFlowTheme theme = FlutterFlowTheme.of(context); final FlutterFlowTheme theme = FlutterFlowTheme.of(context);
final Widget screen = ForgotPasswordScreen(email: email, token: token); final Widget screen = ForgotPasswordScreen(email: email, token: token);
builder(context) => screen; builder(context) => screen;
showModalBottomSheet( await DialogUtil.warning(context, 'Builder: $builder');
await showModalBottomSheet(
context: context, context: context,
builder: (context) => Padding(padding: MediaQuery.viewInsetsOf(context), child: builder(context)), builder: (context) => Padding(padding: MediaQuery.viewInsetsOf(context), child: builder(context)),
isScrollControlled: true, isScrollControlled: true,
@ -211,7 +219,10 @@ class _AppState extends State<App> with WidgetsBindingObserver {
useSafeArea: true, useSafeArea: true,
enableDrag: true, enableDrag: true,
// isDismissible: true, // isDismissible: true,
).whenComplete(() => StorageHelper().isRecovered = false); ).whenComplete(() async {
StorageHelper().isRecovered = false;
await DialogUtil.success(context, 'isRecovered: ${StorageHelper().isRecovered}');
});
} }
} }
@ -266,7 +277,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
const Duration(milliseconds: 1000), () => setState(() => _appStateNotifier.stopShowingSplashImage())); const Duration(milliseconds: 1000), () => setState(() => _appStateNotifier.stopShowingSplashImage()));
_setupFirebaseMessaging(); _setupFirebaseMessaging();
WidgetsBinding.instance.addPersistentFrameCallback((_) => initDeepLinks()); WidgetsBinding.instance.addPersistentFrameCallback((_) async => await initDeepLinks());
} }
@override @override
@ -281,7 +292,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
if (state == AppLifecycleState.detached) { if (state == AppLifecycleState.detached) {
await LocalizationService.processLocals(context); await LocalizationService.processLocals(context);
FirebaseMessagingService().updateDeviceToken(); FirebaseMessagingService().updateDeviceToken();
} }
} }
@override @override

View File

@ -10,10 +10,11 @@ class StorageHelper {
StorageHelper._internal(); StorageHelper._internal();
late BuildContext? _context; late BuildContext? _context;
late bool _isRecovered = false;
BuildContext? get context => _context; BuildContext? get context => _context;
set context(BuildContext? context) => _context = context; set context(BuildContext? context) => _context = context;
late bool _isRecovered = false;
bool get isRecovered => _isRecovered; bool get isRecovered => _isRecovered;
set isRecovered(bool isRecovered) => _isRecovered = isRecovered; set isRecovered(bool isRecovered) => _isRecovered = isRecovered;