diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 192332a7..46c8e9c7 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; // import 'package:hub/components/organisms/bottom_arrow_linked_locals/bottom_arrow_linked_locals_component_widget.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart'; +import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; import 'package:hub/custom_code/actions/get_dev_u_u_i_d.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; @@ -157,8 +158,8 @@ Future singInLoginAction( AppState().serialNumber = await getSerialNumber() ?? ''; AppState().isLogged = true; - AppState().haveLocal = - await checkLocals(context: context, model: model); + AppState().haveLocal = await checkLocals(context: context, model: model) + .then((value) async => await toggleApp(context, value)); } else { if (PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')) == null) { DialogUtil.errorDefault(context); @@ -395,24 +396,23 @@ Future checkLocals({ return false; } List locals = response.jsonBody['locais'] ?? []; - if (locals != null && locals.isEmpty) { - await toggleApp(context, false); + + if (locals.isEmpty) { return false; } else { - // else if (locals.where((local) => local['CLU_STATUS'] != 'A').isNotEmpty) { - // await showModalBottomSheet( - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // enableDrag: false, - // isDismissible: false, - // context: context, - // builder: (context) => Padding( - // padding: MediaQuery.viewInsetsOf(context), - // child: const BottomArrowLinkedLocalsComponentWidget(), - // ), - // ); - // } - await toggleApp(context, true); + if (locals.where((local) => local['CLU_STATUS'] != 'A').isNotEmpty) { + await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + enableDrag: false, + isDismissible: false, + context: context, + builder: (context) => Padding( + padding: MediaQuery.viewInsetsOf(context), + child: const BottomArrowLinkedLocalsComponentWidget(), + ), + ); + } return true; } } diff --git a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart index d10ef31a..708d5307 100644 --- a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart +++ b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart @@ -14,7 +14,7 @@ export 'local_profile_component_model.dart'; //// class LocalProfileComponentWidget extends StatefulWidget { - const LocalProfileComponentWidget({required bool localStatus, super.key}); + const LocalProfileComponentWidget({super.key}); @override State createState() => diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/pages/home_page/home_page_widget.dart index 24e140a0..7a9a989c 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/pages/home_page/home_page_widget.dart @@ -7,7 +7,6 @@ import 'package:hub/actions/actions.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/backend/notifications/firebase_messaging_service.dart'; import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; import 'package:hub/components/organism_components/local_profile_component/local_profile_component_widget.dart'; import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; @@ -27,7 +26,6 @@ class HomePageWidget extends StatefulWidget { class _HomePageWidgetState extends State { late HomePageModel _model; - bool localStatus = false; final scaffoldKey = GlobalKey(); void checkData() async { @@ -62,6 +60,7 @@ class _HomePageWidgetState extends State { } } + @override @override void initState() { super.initState(); @@ -73,32 +72,30 @@ class _HomePageWidgetState extends State { await FirebaseMessagingService().updateDeviceToken(); }(); - checkData(); + checkLocals( + context: context, + model: _model, + ).then((_) => checkData()); - WidgetsBinding.instance.addPostFrameCallback((_) async { - localStatus = await checkLocals( - context: context, - model: _model, - ); - - if (AppState().cliUUID.isEmpty) { - showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - isDismissible: false, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: const BottomArrowLinkedLocalsComponentWidget(), - ); - }, - ).then((value) => safeSetState(() {})); - } else { - return; - } - }); + // WidgetsBinding.instance.addPostFrameCallback((_) async { + // if (AppState().cliUUID.isEmpty) { + // showModalBottomSheet( + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // enableDrag: false, + // isDismissible: false, + // context: context, + // builder: (context) { + // return Padding( + // padding: MediaQuery.viewInsetsOf(context), + // child: const BottomArrowLinkedLocalsComponentWidget(), + // ); + // }, + // ).then((value) => safeSetState(() {})); + // } else { + // return; + // } + // }); _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); @@ -125,12 +122,12 @@ class _HomePageWidgetState extends State { drawerEnableOpenDragGesture: true, drawerDragStartBehavior: DragStartBehavior.start, drawer: CustomDrawer(model: _model), - body: buildPage(context, localStatus), + body: buildPage(context), ), ); } - Container buildPage(BuildContext context, bool localStatus) { + Container buildPage(BuildContext context) { return Container( decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, @@ -151,7 +148,7 @@ class _HomePageWidgetState extends State { clipBehavior: Clip.none, children: [ createHeader(context), - createLocal(localStatus), + createLocal(), createBody(), ], ), @@ -167,8 +164,8 @@ class _HomePageWidgetState extends State { children: [ Expanded( child: Container( - width: 100.0, - height: 100.0, + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height * 0.1, decoration: const BoxDecoration( color: Color(0xFF1AAB5F), ), @@ -320,13 +317,11 @@ class _HomePageWidgetState extends State { ); } - Widget createLocal(bool localStatus) { + Widget createLocal() { return wrapWithModel( model: _model.localComponentModel, updateCallback: () => safeSetState(() {}), - child: LocalProfileComponentWidget( - localStatus: localStatus, - ), + child: const LocalProfileComponentWidget(), ); } } diff --git a/lib/shared/widgets/drawer_widget/drawer_widget.dart b/lib/shared/widgets/drawer_widget/drawer_widget.dart index 6ae8e2c8..839e5c65 100644 --- a/lib/shared/widgets/drawer_widget/drawer_widget.dart +++ b/lib/shared/widgets/drawer_widget/drawer_widget.dart @@ -13,18 +13,20 @@ class CustomDrawer extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - width: MediaQuery.of(context).size.width * 0.8, - child: Drawer( - elevation: 16.0, - child: Container( - color: FlutterFlowTheme.of(context).primaryBackground, - child: Column( - children: [ - _buildDrawerHeader(context), - // _buildSearchBar(context), - _buildDrawerBody(), - ].addToStart(const SizedBox(height: 20)), + return SafeArea( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: Drawer( + elevation: 16.0, + child: Container( + color: FlutterFlowTheme.of(context).primaryBackground, + child: Column( + children: [ + _buildDrawerHeader(context), + // _buildSearchBar(context), + _buildDrawerBody(), + ].addToStart(const SizedBox(height: 20)), + ), ), ), ), @@ -39,68 +41,67 @@ class CustomDrawer extends StatelessWidget { bottomRight: Radius.circular(5.0), ), ), - child: Padding( - padding: const EdgeInsets.fromLTRB(30, 30, 10, 0), - child: Row( - children: [ - Flexible( - fit: FlexFit.loose, - flex: 1, - child: Container( - width: 50.0, - height: 50.0, - clipBehavior: Clip.antiAlias, - decoration: BoxDecoration( - shape: BoxShape.circle, - ), - child: CachedNetworkImage( - imageUrl: valueOrDefault( - 'assets/images/person.jpg', - 'https://freaccess.com.br/freaccess/Images/Clients/${AppState().cliUUID}.png', - ), - width: 80.0, - height: 80.0, - fit: BoxFit.cover, - alignment: Alignment.center, - placeholder: (context, url) => - Image.asset('assets/images/person.jpg'), - errorListener: (_) => Image.asset('assets/images/person.jpg'), - errorWidget: (_, __, ___) => - Image.asset('assets/images/person.jpg'), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Flexible( + fit: FlexFit.loose, + flex: 1, + child: Container( + width: 50.0, + height: 50.0, + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + shape: BoxShape.circle, + ), + child: CachedNetworkImage( + imageUrl: valueOrDefault( + 'assets/images/person.jpg', + 'https://freaccess.com.br/freaccess/Images/Clients/${AppState().cliUUID}.png', ), + width: 80.0, + height: 80.0, + fit: BoxFit.cover, + alignment: Alignment.center, + placeholder: (context, url) => + Image.asset('assets/images/person.jpg'), + errorListener: (_) => Image.asset('assets/images/person.jpg'), + errorWidget: (_, __, ___) => + Image.asset('assets/images/person.jpg'), ), ), - SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - convertToUppercase(AppState().name) ?? '', - style: FlutterFlowTheme.of(context).bodyLarge.override( - fontFamily: 'Nunito Sans', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 14.0, - letterSpacing: 0.0, - fontWeight: FontWeight.normal, - ), - ), - SizedBox(height: 5), - Text( - AppState().email, - style: FlutterFlowTheme.of(context).bodySmall.override( - fontFamily: 'Nunito Sans', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 12.0, - letterSpacing: 0.0, - fontWeight: FontWeight.normal, - ), - ), - ], - ), + ), + SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + convertToUppercase(AppState().name) ?? '', + style: FlutterFlowTheme.of(context).bodyLarge.override( + fontFamily: 'Nunito Sans', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 14.0, + letterSpacing: 0.0, + fontWeight: FontWeight.normal, + ), + ), + SizedBox(height: 5), + Text( + AppState().email, + style: FlutterFlowTheme.of(context).bodySmall.override( + fontFamily: 'Nunito Sans', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 12.0, + letterSpacing: 0.0, + fontWeight: FontWeight.normal, + ), + ), + ], ), - ], - ), + ), + ], ), ); }