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 274f1b55..4a0966fd 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 @@ -123,9 +123,12 @@ class _LocalProfileComponentWidgetState showDragHandle: false, useSafeArea: true, context: context, - builder: (context) => Padding( - padding: MediaQuery.viewInsetsOf(context), - child: const BottomArrowLinkedLocalsComponentWidget(), + builder: (context) => PopScope( + canPop: false, + child: Padding( + padding: MediaQuery.viewInsetsOf(context), + child: const BottomArrowLinkedLocalsComponentWidget(), + ), ), ).then((_) async { onUpdate(); diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart index d8e0e8e0..97b7b058 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart @@ -120,6 +120,22 @@ class ScheduleProvisionalVisitPageModel return false; } + DateTime selectedDateTime; + DateTime currentDateTime = DateTime.now(); + selectedDateTime = + DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); + + try { + selectedDateTime = + DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); + } catch (e) { + return false; + } + + if (selectedDateTime.isBefore(currentDateTime)) { + return false; + } + return true; } diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/pages/home_page/home_page_widget.dart index d0824e48..a045dfff 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/pages/home_page/home_page_widget.dart @@ -26,6 +26,7 @@ class HomePageWidget extends StatefulWidget { class _HomePageWidgetState extends State { late HomePageModel _model; final scaffoldKey = GlobalKey(); + late LocalProfileComponentWidget _localProfileComponentWidget; _HomePageWidgetState() { @@ -54,65 +55,60 @@ class _HomePageWidgetState extends State { @override Widget build(BuildContext context) { StorageUtil().context = context; - return GestureDetector( - onTap: () => _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), - child: Scaffold( - key: scaffoldKey, - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - // drawer: buildDrawer(context), - drawerEnableOpenDragGesture: true, - drawerDragStartBehavior: DragStartBehavior.start, - drawer: CustomDrawer(model: _model), - appBar: AppBar( - backgroundColor: FlutterFlowTheme.of(context).primary, - automaticallyImplyLeading: false, - leading: FlutterFlowIconButton( - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 40.0, - fillColor: FlutterFlowTheme.of(context).primary, - icon: const Icon( - Icons.menu_rounded, - color: Colors.white, - size: 28.0, - ), - onPressed: () async { - scaffoldKey.currentState!.openDrawer(); - }, + return Scaffold( + key: scaffoldKey, + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + // drawer: buildDrawer(context), + drawerEnableOpenDragGesture: true, + drawerDragStartBehavior: DragStartBehavior.start, + drawer: CustomDrawer(model: _model), + appBar: AppBar( + backgroundColor: FlutterFlowTheme.of(context).primary, + automaticallyImplyLeading: false, + leading: FlutterFlowIconButton( + borderRadius: 20.0, + borderWidth: 1.0, + buttonSize: 40.0, + fillColor: FlutterFlowTheme.of(context).primary, + icon: const Icon( + Icons.menu_rounded, + color: Colors.white, + size: 28.0, ), - title: Row( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(8.0), - child: Image.asset( - 'assets/images/logo.png', - width: 15.0, - height: 15.0, - fit: BoxFit.cover, - ), - ), - Text( - 'FRE ACCESS', - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).info, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - ].divide(const SizedBox(width: 8.0)), - ), - actions: const [], - centerTitle: true, - elevation: 0.0, + onPressed: () async { + scaffoldKey.currentState!.openDrawer(); + }, ), - body: buildPage(context), + title: Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Image.asset( + 'assets/images/logo.png', + width: 15.0, + height: 15.0, + fit: BoxFit.cover, + ), + ), + Text( + 'FRE ACCESS', + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).info, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).bodyMediumFamily), + ), + ), + ].divide(const SizedBox(width: 8.0)), + ), + actions: const [], + centerTitle: true, + elevation: 0.0, ), + body: buildPage(context), ); } diff --git a/lib/pages/reception_page/reception_page_widget.dart b/lib/pages/reception_page/reception_page_widget.dart index 858b8d92..7de37ed3 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -124,9 +124,12 @@ class _ReceptionPageWidgetState extends State enableDrag: false, isDismissible: false, context: context, - builder: (context) => Padding( - padding: MediaQuery.viewInsetsOf(context), - child: const BottomArrowLinkedLocalsComponentWidget(), + builder: (context) => PopScope( + canPop: false, + child: Padding( + padding: MediaQuery.viewInsetsOf(context), + child: const BottomArrowLinkedLocalsComponentWidget(), + ), ), ).then((_) async { StorageUtil().haveLocal = true; diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart index 4467764d..54b411f9 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart @@ -83,8 +83,31 @@ class ScheduleCompleteVisitPageModel (textController2!.text != '') && (dropDownValue1 != null && dropDownValue1 != '') && (dropDownValue2 != null && dropDownValue2 != '')) { + DateTime selectedDateTime; + DateTime currentDateTime = DateTime.now().subtract(Duration(minutes: 10)); + try { + selectedDateTime = + DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController1.text); + if (selectedDateTime.isBefore(currentDateTime)) { + return false; + } + } catch (e) { + return false; + } + + try { + selectedDateTime = + DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController2.text); + if (selectedDateTime.isBefore(currentDateTime)) { + return false; + } + } catch (e) { + return false; + } + return true; } + return false; } @@ -114,7 +137,8 @@ class ScheduleCompleteVisitPageModel enText: 'Start date must be before end date.', ); } - if (startDate.isBefore(DateTime.now())) { + if (startDate + .isBefore(DateTime.now().subtract(const Duration(minutes: 10)))) { return FFLocalizations.of(context).getVariableText( enText: 'Start date must be after current date.', ptText: 'A data de início deve ser posterior à data atual.', @@ -152,7 +176,8 @@ class ScheduleCompleteVisitPageModel ptText: 'A data de término deve ser posterior à data de início.', ); } - if (endDate.isBefore(DateTime.now())) { + if (startDate + .isBefore(DateTime.now().subtract(const Duration(minutes: 10)))) { return FFLocalizations.of(context).getVariableText( enText: 'End date must be after current date.', ptText: 'A data de término deve ser posterior à data atual.', diff --git a/lib/shared/helpers/secure_storage_helper.dart b/lib/shared/helpers/secure_storage_helper.dart index 94eda6e4..7e135cb3 100644 --- a/lib/shared/helpers/secure_storage_helper.dart +++ b/lib/shared/helpers/secure_storage_helper.dart @@ -16,7 +16,7 @@ class SecureStorageHelper extends ChangeNotifier implements Storage { Future setAndCacheString( String key, String value, Function(String) cacheSetter) async { - log('setAndCacheString value for key: $key to $value'); + log('SecureStorageHelper -> setAndCacheString value for key: $key to $value'); await _secureStorage.write(key: key, value: value); CacheUtil.instance.set(key, value); cacheSetter(value); @@ -24,7 +24,7 @@ class SecureStorageHelper extends ChangeNotifier implements Storage { Future setAndCacheBool( String key, bool value, Function(bool) cacheSetter) async { - log('setAndCacheBool value for key: $key to $value'); + log('SecureStorageHelper -> setAndCacheBool value for key: $key to $value'); await _secureStorage.write(key: key, value: value.toString()); CacheUtil.instance.set(key, value); cacheSetter(value); @@ -32,19 +32,19 @@ class SecureStorageHelper extends ChangeNotifier implements Storage { Future setAndCacheObject( String key, String value, Function(String) cacheSetter) async { - log('setAndCacheObject value for key: $key to $value'); + log('SecureStorageHelper -> setAndCacheObject value for key: $key to $value'); await _secureStorage.write(key: key, value: value); CacheUtil.instance.set(key, value); cacheSetter(value); } Future getString(String key) async { - log('getString value for key: $key'); var value = CacheUtil.instance.get(key); if (value == null) { value = await _secureStorage.read(key: key); CacheUtil.instance.set(key, value); } + log('SecureStorageHelper -> getString $value for key: $key'); return value; } @@ -53,20 +53,20 @@ class SecureStorageHelper extends ChangeNotifier implements Storage { if (value == null || value == 'null') { value = await _secureStorage.read(key: key); CacheUtil.instance.set(key, value); - log('getBool $value for key: $key'); + log('SecureStorageHelper -> getBool $value for key: $key'); return value == 'true'; } - log('getBool $value for key: $key'); + log('SecureStorageHelper -> getBool $value for key: $key'); return value; } Future getObject(String key) async { - log('getObject value for key: $key'); var value = CacheUtil.instance.get(key); if (value == null) { value = await _secureStorage.read(key: key); CacheUtil.instance.set(key, value); } + log('SecureStorageHelper -> getObject $value for key: $key'); return value as BuildContext?; } @@ -84,7 +84,7 @@ class SecureStorageHelper extends ChangeNotifier implements Storage { @override Future get(String key) async { - log('get value for key: $key'); + log('SecureStorageHelper -> get value for key: $key'); var stringValue = await getString(key); if (stringValue != null) return stringValue; @@ -99,13 +99,13 @@ class SecureStorageHelper extends ChangeNotifier implements Storage { @override Future delete(String key) async { - log('delete value for key: $key'); + log('SecureStorageHelper -> delete value for key: $key'); await _secureStorage.delete(key: key); CacheUtil.instance.delete(key); } Future purge() async { - log('Purging secure storage'); + log('SecureStorageHelper -> Purging secure storage'); await _secureStorage.deleteAll(); CacheUtil.instance.clear(); }