This commit is contained in:
jantunesmesias 2024-08-28 17:39:17 -03:00
parent c25c23634f
commit a7af306b31
4 changed files with 23 additions and 15 deletions

View File

@ -299,8 +299,8 @@ Future toggleSignUpPage(BuildContext context) async {
} }
Future toggleApp(BuildContext context, bool haveLocal) async { Future toggleApp(BuildContext context, bool haveLocal) async {
if (haveLocal == true) if (haveLocal == true) {
context.goNamed( context.pushNamed(
'homePage', 'homePage',
extra: <String, dynamic>{ extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo( kTransitionInfoKey: const TransitionInfo(
@ -309,8 +309,8 @@ Future toggleApp(BuildContext context, bool haveLocal) async {
), ),
}, },
); );
else if (haveLocal == false) } else if (haveLocal == false) {
context.goNamed( context.pushNamed(
'receptionPage', 'receptionPage',
extra: <String, dynamic>{ extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo( kTransitionInfoKey: const TransitionInfo(
@ -319,6 +319,7 @@ Future toggleApp(BuildContext context, bool haveLocal) async {
) )
}, },
); );
}
} }
Future<bool> visitCancelAction(BuildContext context, Future<bool> visitCancelAction(BuildContext context,

View File

@ -15,10 +15,9 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/home_page/home_page_model.dart'; import 'package:hub/pages/home_page/home_page_model.dart';
import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart'; import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
import 'package:provider/provider.dart';
class HomePageWidget extends StatefulWidget { class HomePageWidget extends StatefulWidget {
const HomePageWidget({super.key}); const HomePageWidget({Key? key});
@override @override
State<HomePageWidget> createState() => _HomePageWidgetState(); State<HomePageWidget> createState() => _HomePageWidgetState();
@ -30,6 +29,10 @@ class _HomePageWidgetState extends State<HomePageWidget> {
LocalProfileComponentWidget _localProfileComponentWidget = LocalProfileComponentWidget _localProfileComponentWidget =
const LocalProfileComponentWidget(); const LocalProfileComponentWidget();
_HomePageWidgetState() {
log('HomePageWidget');
}
Future<void> checkData() async { Future<void> checkData() async {
try { try {
final response = await PhpGroup.getDadosCall.call( final response = await PhpGroup.getDadosCall.call(
@ -67,6 +70,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
} }
Future<void> checkLocal() async { Future<void> checkLocal() async {
log('Checklocal');
try { try {
final response = await PhpGroup.getLocalsCall.call( final response = await PhpGroup.getLocalsCall.call(
devUUID: AppState().devUUID, devUUID: AppState().devUUID,
@ -80,9 +84,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
if (activeLocals.isEmpty || AppState().cliUUID.isEmpty) { if (activeLocals.isEmpty || AppState().cliUUID.isEmpty) {
await showBottomSheet().then((_) => checkData()); await showBottomSheet().then((_) => checkData());
} }
if (AppState().cliUUID.isEmpty) {
await showBottomSheet().then((_) => checkData());
}
} catch (e) { } catch (e) {
log('Error in checkLocal: $e'); log('Error in checkLocal: $e');
await showBottomSheet().then((_) => checkData()); await showBottomSheet().then((_) => checkData());
@ -110,11 +111,14 @@ class _HomePageWidgetState extends State<HomePageWidget> {
super.initState(); super.initState();
_model = createModel(context, () => HomePageModel()); _model = createModel(context, () => HomePageModel());
_model.updateOnChange = true;
AppState().context = context; AppState().context = context;
() async { WidgetsBinding.instance.addPostFrameCallback((_) async {
await checkLocal(); await checkLocal();
});
() async {
await FirebaseMessagingService().updateDeviceToken(); await FirebaseMessagingService().updateDeviceToken();
}(); }();
@ -131,7 +135,8 @@ class _HomePageWidgetState extends State<HomePageWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
context.watch<AppState>(); // context.watch<AppState>();
return GestureDetector( return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode) ? FocusScope.of(context).requestFocus(_model.unfocusNode)

View File

@ -316,7 +316,7 @@ class PreferencesPageModel with ChangeNotifier {
AppState().deleteLocal(); AppState().deleteLocal();
AppState().deleteOwnerUUID(); AppState().deleteOwnerUUID();
context.goNamed( context.pushNamed(
'homePage', 'homePage',
extra: <String, dynamic>{ extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo( kTransitionInfoKey: const TransitionInfo(
@ -372,7 +372,7 @@ class PreferencesPageModel with ChangeNotifier {
), ),
); );
}); });
notifyListeners(); // notifyListeners();
} catch (err, stack) { } catch (err, stack) {
Navigator.pop(context); Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
@ -417,7 +417,7 @@ class PreferencesPageModel with ChangeNotifier {
], ],
); );
}); });
notifyListeners(); // notifyListeners();
} }
void deleteAccount(BuildContext context) { void deleteAccount(BuildContext context) {

View File

@ -138,7 +138,9 @@ class PreferencesPageWidget extends StatelessWidget {
break; break;
case 5: case 5:
icon = Icons.landscape; icon = Icons.landscape;
onPressed = () => model.localUnlink(context); onPressed = () {
model.localUnlink(context);
};
isEnabled = false; isEnabled = false;
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
ptText: 'Desative para se desvincular do local selecionado', ptText: 'Desative para se desvincular do local selecionado',