fix: fechar e reabrir o app durante a seleção de locais
This commit is contained in:
parent
b28ca12482
commit
6e1d04d978
|
@ -1,21 +1,15 @@
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
|
||||||
import 'package:hub/features/home/index.dart';
|
|
||||||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/shared/components/molecules/drawer/index.dart';
|
import 'package:hub/shared/components/molecules/drawer/index.dart';
|
||||||
import 'package:hub/shared/components/molecules/locals/index.dart';
|
import 'package:hub/shared/components/molecules/locals/index.dart';
|
||||||
import 'package:hub/shared/components/molecules/menu/index.dart';
|
import 'package:hub/shared/components/molecules/menu/index.dart';
|
||||||
import 'package:hub/shared/components/molecules/modules/index.dart';
|
|
||||||
import 'package:hub/shared/helpers/storage/base_storage.dart';
|
|
||||||
import 'package:hub/shared/extensions/string_extensions.dart';
|
|
||||||
import 'package:hub/shared/helpers/storage/storage_helper.dart';
|
|
||||||
|
|
||||||
class HomePageWidget extends StatefulWidget {
|
class HomePageWidget extends StatefulWidget {
|
||||||
const HomePageWidget({
|
const HomePageWidget({
|
||||||
|
@ -36,6 +30,7 @@ class _HomePageWidgetState extends State<HomePageWidget> with WidgetsBindingObse
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
await LocalsRepositoryImpl().check(context);
|
||||||
if (widget.update != null) {
|
if (widget.update != null) {
|
||||||
await widget.update!(context);
|
await widget.update!(context);
|
||||||
}
|
}
|
||||||
|
@ -48,36 +43,7 @@ class _HomePageWidgetState extends State<HomePageWidget> with WidgetsBindingObse
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
|
||||||
Future<void> execute() async {
|
|
||||||
final isLogged = await StorageHelper().get(SecureStorageKey.isLogged.value);
|
|
||||||
log('isLogged: $isLogged');
|
|
||||||
if (isLogged.toBoolean()) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
await LocalsRepositoryImpl().update(context);
|
|
||||||
await FirebaseMessagingService().updateDeviceToken();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (state == AppLifecycleState.detached) {
|
|
||||||
print('AppLifecycleState.detached');
|
|
||||||
}
|
|
||||||
if (state == AppLifecycleState.resumed) {
|
|
||||||
print('AppLifecycleState.resumed');
|
|
||||||
}
|
|
||||||
if (state == AppLifecycleState.inactive) {
|
|
||||||
print('AppLifecycleState.inactive');
|
|
||||||
}
|
|
||||||
if (state == AppLifecycleState.paused) {
|
|
||||||
print('AppLifecycleState.paused');
|
|
||||||
}
|
|
||||||
if (state == AppLifecycleState.hidden) {
|
|
||||||
print('AppLifecycleState.hidden');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Builder(
|
return Builder(
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
||||||
import 'package:hub/shared/components/molecules/locals/index.dart';
|
import 'package:hub/shared/components/molecules/locals/index.dart';
|
||||||
import 'package:hub/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart';
|
import 'package:hub/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart';
|
||||||
import 'package:hub/shared/components/molecules/modules/index.dart';
|
import 'package:hub/shared/components/molecules/modules/index.dart';
|
||||||
|
@ -34,6 +35,17 @@ class LocalsRepositoryImpl implements LocalsRepository {
|
||||||
await localDataSource.unlinkLocal();
|
await localDataSource.unlinkLocal();
|
||||||
await update(context);
|
await update(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> check(BuildContext context) async {
|
||||||
|
final String? cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value);
|
||||||
|
final String? ownerUUID = await StorageHelper().get(KeychainStorageKey.ownerUUID.value);
|
||||||
|
final bool haveCli = cliUUID != null && cliUUID.isNotEmpty;
|
||||||
|
final bool haveOwner = ownerUUID != null && ownerUUID.isNotEmpty;
|
||||||
|
if (!haveCli && !haveOwner) {
|
||||||
|
await update(context);
|
||||||
|
await FirebaseMessagingService().updateDeviceToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> _handleReponse(BuildContext context) async {
|
Future<bool> _handleReponse(BuildContext context) async {
|
||||||
bool response = false;
|
bool response = false;
|
||||||
|
|
32
pubspec.lock
32
pubspec.lock
|
@ -466,10 +466,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: firebase_core_platform_interface
|
name: firebase_core_platform_interface
|
||||||
sha256: e30da58198a6d4b49d5bce4e852f985c32cb10db329ebef9473db2b9f09ce810
|
sha256: b94b217e3ad745e784960603d33d99471621ecca151c99c670869b76e50ad2a6
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.3.0"
|
version: "5.3.1"
|
||||||
firebase_core_web:
|
firebase_core_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -535,10 +535,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_animate
|
name: flutter_animate
|
||||||
sha256: "7c8a6594a9252dad30cc2ef16e33270b6248c4dedc3b3d06c86c4f3f4dc05ae5"
|
sha256: "7befe2d3252728afb77aecaaea1dec88a89d35b9b1d2eea6d04479e8af9117b5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.5.0"
|
version: "4.5.2"
|
||||||
flutter_bloc:
|
flutter_bloc:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -615,10 +615,10 @@ packages:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: flutter_launcher_icons
|
name: flutter_launcher_icons
|
||||||
sha256: "619817c4b65b322b5104b6bb6dfe6cda62d9729bd7ad4303ecc8b4e690a67a77"
|
sha256: "31cd0885738e87c72d6f055564d37fabcdacee743b396b78c7636c169cac64f5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.14.1"
|
version: "0.14.2"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
@ -798,10 +798,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: go_router
|
name: go_router
|
||||||
sha256: "8660b74171fafae4aa8202100fa2e55349e078281dadc73a241eb8e758534d9d"
|
sha256: "2fd11229f59e23e967b0775df8d5948a519cd7e1e8b6e849729e010587b46539"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "14.6.1"
|
version: "14.6.2"
|
||||||
google_fonts:
|
google_fonts:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -1206,10 +1206,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: path_provider_foundation
|
name: path_provider_foundation
|
||||||
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
|
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.1"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1430,10 +1430,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_android
|
name: shared_preferences_android
|
||||||
sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab"
|
sha256: "7f172d1b06de5da47b6264c2692ee2ead20bbbc246690427cdb4fc301cd0c549"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.3"
|
version: "2.3.4"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -1675,10 +1675,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: url_launcher_ios
|
name: url_launcher_ios
|
||||||
sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e
|
sha256: "16a513b6c12bb419304e72ea0ae2ab4fed569920d1c7cb850263fe3acc824626"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.3.1"
|
version: "6.3.2"
|
||||||
url_launcher_linux:
|
url_launcher_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1691,10 +1691,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_macos
|
name: url_launcher_macos
|
||||||
sha256: "769549c999acdb42b8bcfa7c43d72bf79a382ca7441ab18a808e101149daf672"
|
sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.2.1"
|
version: "3.2.2"
|
||||||
url_launcher_platform_interface:
|
url_launcher_platform_interface:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -32,7 +32,7 @@ dependencies:
|
||||||
file_picker: ^8.0.7
|
file_picker: ^8.0.7
|
||||||
# flutter_expandable_fab: ^2.1.0
|
# flutter_expandable_fab: ^2.1.0
|
||||||
firebase_analytics: ^11.3.0
|
firebase_analytics: ^11.3.0
|
||||||
flutter_animate: 4.5.0
|
flutter_animate: ^4.5.2
|
||||||
# flutter_cache_manager: ^3.4.1
|
# flutter_cache_manager: ^3.4.1
|
||||||
# flutter_plugin_android_lifecycle: ^2.0.23
|
# flutter_plugin_android_lifecycle: ^2.0.23
|
||||||
share_plus: ^10.0.0
|
share_plus: ^10.0.0
|
||||||
|
@ -66,7 +66,7 @@ dependencies:
|
||||||
path_provider: ^2.1.4
|
path_provider: ^2.1.4
|
||||||
path_provider_android: ^2.2.12
|
path_provider_android: ^2.2.12
|
||||||
google_mlkit_face_detection: ^0.12.0
|
google_mlkit_face_detection: ^0.12.0
|
||||||
path_provider_foundation: 2.4.0
|
path_provider_foundation: ^2.4.1
|
||||||
path_provider_platform_interface: 2.1.2
|
path_provider_platform_interface: 2.1.2
|
||||||
percent_indicator: ^4.2.3
|
percent_indicator: ^4.2.3
|
||||||
plugin_platform_interface: 2.1.8
|
plugin_platform_interface: 2.1.8
|
||||||
|
|
Loading…
Reference in New Issue