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 ab338b78..3120a876 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 @@ -1,4 +1,3 @@ - import '/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -12,10 +11,7 @@ export 'local_profile_component_model.dart'; //// class LocalProfileComponentWidget extends StatefulWidget { - const LocalProfileComponentWidget({ - required bool localStatus, - super.key - }); + const LocalProfileComponentWidget({required bool localStatus, super.key}); @override State createState() => @@ -87,35 +83,34 @@ class _LocalProfileComponentWidgetState padding: MediaQuery.viewInsetsOf(context), child: const SizedBox( height: double.infinity, - child: - BottomArrowLinkedLocalsComponentWidget(), + child: BottomArrowLinkedLocalsComponentWidget(), ), ); }, ).then((value) => safeSetState(() {})); }, child: ClipRRect( - borderRadius: BorderRadius.circular(200.0), - child: - Image.network( - 'https://freaccess.com.br/freaccess/Images/Clients/${FFAppState().cliUUID}.png', - width: 80.0, - height: 80.0, - fit: BoxFit.cover, - alignment: const Alignment(0.0, 0.0), - errorBuilder: (context, error, stackTrace) => Image.network( - 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', + borderRadius: BorderRadius.circular(200.0), + child: Image.network( + 'https://freaccess.com.br/freaccess/Images/Clients/${FFAppState().cliUUID}.png', width: 80.0, height: 80.0, fit: BoxFit.cover, alignment: const Alignment(0.0, 0.0), - errorBuilder: (context, error, stackTrace) => Image.asset('assets/images/error_image.svg'), - ), - ) - ), - ), + errorBuilder: (context, error, stackTrace) => + Image.network( + 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', + width: 80.0, + height: 80.0, + fit: BoxFit.cover, + alignment: const Alignment(0.0, 0.0), + errorBuilder: (context, error, stackTrace) => + Image.asset('assets/images/error_image.svg'), + ), + )), ), ), + ), Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, @@ -125,16 +120,15 @@ class _LocalProfileComponentWidgetState functions.convertToUppercase(FFAppState().local), 'NOME DO LOCAL', ), - style: - FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).info, - fontSize: 14.0, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: - GoogleFonts.asMap().containsKey('Nunito'), - ), + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: 14.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: + GoogleFonts.asMap().containsKey('Nunito'), + ), ), ], ), @@ -148,4 +142,4 @@ class _LocalProfileComponentWidgetState ), ); } -} \ No newline at end of file +} diff --git a/lib/components/templates_components/details_component/details_component_action.dart b/lib/components/templates_components/details_component/details_component_action.dart index fafb0916..0225d38f 100644 --- a/lib/components/templates_components/details_component/details_component_action.dart +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -84,7 +84,6 @@ Widget buildDetails( ) .then((value) { Navigator.pop(context); - Navigator.pop(context); if (value == false) { showSnackbar( context, @@ -105,6 +104,8 @@ Widget buildDetails( ); } }).catchError((err, stack) { + Navigator.pop(context); + showSnackbar( context, FFLocalizations.of(context).getVariableText( diff --git a/lib/components/templates_components/details_component/details_component_widget.dart b/lib/components/templates_components/details_component/details_component_widget.dart index bc8e40f1..7ebbd254 100644 --- a/lib/components/templates_components/details_component/details_component_widget.dart +++ b/lib/components/templates_components/details_component/details_component_widget.dart @@ -91,217 +91,210 @@ class _VisitRequestTemplateComponentWidgetState return LayoutBuilder( builder: (context, constraints) { - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Container( - width: constraints.maxWidth, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primaryBackground, - borderRadius: const BorderRadius.all(Radius.circular(25.0)), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - width: 150.0, - height: 150.0, - clipBehavior: Clip.antiAlias, - decoration: const BoxDecoration( - shape: BoxShape.circle, - ), - child: CachedNetworkImage( - fadeInDuration: const Duration(milliseconds: 100), - fadeOutDuration: const Duration(milliseconds: 100), - imageUrl: - 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', - fit: BoxFit.cover, - ), + return Container( + width: constraints.maxWidth, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primaryBackground, + borderRadius: const BorderRadius.all(Radius.circular(25.0)), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: 150.0, + height: 150.0, + clipBehavior: Clip.antiAlias, + decoration: const BoxDecoration( + shape: BoxShape.circle, ), - Row( - children: statusLinkedHashMap.expand((linkedHashMap) { - return linkedHashMap.entries - .map((MapEntry item) { - return Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 24.0), - child: TextFormField( - // controller: _model.textControllerStatus, - // focusNode: _model.textFieldFocusNodeStatus, - autofocus: false, - canRequestFocus: false, - readOnly: true, - obscureText: false, - decoration: InputDecoration( - isDense: true, - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: item.value, - ), - ), - filled: true, - fillColor: item.value, - labelText: item.key, - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).info, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).info, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - focusedBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - suffixIcon: Icon( - Icons.info, - color: FlutterFlowTheme.of(context).accent1, + child: CachedNetworkImage( + fadeInDuration: const Duration(milliseconds: 100), + fadeOutDuration: const Duration(milliseconds: 100), + imageUrl: + 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', + fit: BoxFit.cover, + ), + ), + Row( + children: statusLinkedHashMap.expand((linkedHashMap) { + return linkedHashMap.entries + .map((MapEntry item) { + return Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24.0), + child: TextFormField( + // controller: _model.textControllerStatus, + // focusNode: _model.textFieldFocusNodeStatus, + autofocus: false, + canRequestFocus: false, + readOnly: true, + obscureText: false, + decoration: InputDecoration( + isDense: true, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: item.value, ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium + filled: true, + fillColor: item.value, + labelText: item.key, + labelStyle: FlutterFlowTheme.of(context) + .labelMedium .override( fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + .labelMediumFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey(FlutterFlowTheme.of(context) - .bodyMediumFamily), + .labelMediumFamily), ), - textAlign: TextAlign.start, - maxLines: null, - keyboardType: TextInputType.name, - validator: _model.textController1Validator - .asValidator(context), - ), - ), - ); - }).toList(); - }).toList(), - ), - ListView.builder( - shrinkWrap: true, - itemCount: labelsLinkedHashMap.length, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) { - String key = labelsLinkedHashMap.keys.elementAt(index); - String value = labelsLinkedHashMap[key]!; - // return Text('key: $key, value: $value'); - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10.0, vertical: 3.0), - child: TextFormField( - readOnly: true, - initialValue: '$value', - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily, - ), - ), - decoration: InputDecoration( - labelText: key, - filled: true, - fillColor: - FlutterFlowTheme.of(context).primaryBackground, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here + hintStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .labelMediumFamily, + color: FlutterFlowTheme.of(context).info, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context) + .labelMediumFamily), + ), + focusedBorder: InputBorder.none, + errorBorder: InputBorder.none, + focusedErrorBorder: InputBorder.none, + suffixIcon: Icon( + Icons.info, + color: FlutterFlowTheme.of(context).info, ), ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium + style: FlutterFlowTheme.of(context) + .bodyMedium .override( fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, + .bodyMediumFamily, + color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily, - ), + FlutterFlowTheme.of(context) + .bodyMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily, - ), - ), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here - ), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here - ), - ), - errorBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here - ), - ), - focusedErrorBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here - ), - ), + textAlign: TextAlign.start, + maxLines: null, + keyboardType: TextInputType.name, + validator: _model.textController1Validator + .asValidator(context), ), ), ); - }, - ), - if (widget.buttons.isNotEmpty) - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: widget.buttons, + }).toList(); + }).toList(), + ), + ListView.builder( + shrinkWrap: true, + itemCount: labelsLinkedHashMap.length, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + String key = labelsLinkedHashMap.keys.elementAt(index); + String value = labelsLinkedHashMap[key]!; + // return Text('key: $key, value: $value'); + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10.0, vertical: 3.0), + child: TextFormField( + readOnly: true, + initialValue: '$value', + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: + FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).bodyMediumFamily, + ), + ), + decoration: InputDecoration( + labelText: key, + filled: true, + fillColor: + FlutterFlowTheme.of(context).primaryBackground, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + labelStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).labelMediumFamily, + ), + ), + hintStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).labelMediumFamily, + ), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + ), ), + ); + }, + ), + if (widget.buttons.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: widget.buttons, ), - ] - .divide(const SizedBox(height: 20.0)) - .addToEnd(const SizedBox(height: 20.0)) - .addToStart(const SizedBox(height: 20.0)), - ), + ), + ] + .divide(const SizedBox(height: 20.0)) + .addToEnd(const SizedBox(height: 20.0)) + .addToStart(const SizedBox(height: 20.0)), ), ); }, diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index 68bfc993..8324d836 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -97,38 +97,10 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( name: 'scheduleCompleteVisitPage', path: '/scheduleCompleteVisitPage', builder: (context, params) => ScheduleCompleteVisitPageWidget( - // get current datatime picker dd/mm/aaaa hh:mm:ss - // visitStartDateStr: DateTime.now().toString(), - // post 1 day - // visitEndDateStr: DateTime.now().add(const Duration(days: 1)).toString(), visitorStrList: params.getParam( 'visitorStrList', ParamType.String, ), - visitStartDateStr: params.getParam( - 'visitStartDateStr', - ParamType.String, - ), - visitEndDateStr: params.getParam( - 'visitEndDateStr', - ParamType.String, - ), - visitReasonStr: params.getParam( - 'visitReasonStr', - ParamType.String, - ), - visitLevelStr: params.getParam( - 'visitLevelStr', - ParamType.String, - ), - visitTempBol: params.getParam( - 'visitTempBol', - ParamType.bool, - ), - visitObsStr: params.getParam( - 'visitObsStr', - ParamType.String, - ), visitorJsonList: params.getParam( 'visitorJsonList', ParamType.JSON, diff --git a/lib/main.dart b/lib/main.dart index 61119468..31a077e1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,14 +20,14 @@ void main() async { DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); - await initializeApp(); + await init(); runApp(ChangeNotifierProvider( create: (context) => FFAppState(), child: const MyApp(), )); } -Future initializeApp() async { +Future init() async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError; await FlutterFlowTheme.initialize(); diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 1ac7cde3..72c0dcf2 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -330,71 +330,110 @@ Widget liberationHistoryItemCard( }) ], onTapCardItemAction: () async { - showModalBottomSheet( - isScrollControlled: true, - isDismissible: true, - backgroundColor: Colors.transparent, + showDialog( + // isScrollControlled: true, + // isDismissible: true, + // backgroundColor: Colors.transparent, useSafeArea: true, context: context, builder: (context) { - return VisitRequestTemplateComponentWidget( - // vteName: liberationHistoryItem['VTE_NOME'], - // vteReason: liberationHistoryItem['NOT_MOTIVO'], - // vawDate: liberationHistoryItem['NOT_STATUS'] == 'S' - // ? liberationHistoryItem['NOT_DTENVIO'] - // : liberationHistoryItem['NOT_DTRESPOSTA'], - // vawStatus: liberationHistoryItem['NOT_STATUS'], - // vteMsg: liberationHistoryItem['NOT_MSGENVIO'], - // vteUUID: liberationHistoryItem['VTE_ID'], - // cliUUID: FFAppState().cliUUID, - // msgUUID: liberationHistoryItem['NOT_ID'], - // vawDestino: liberationHistoryItem['NOT_DESTINO'], - // vawUUID: liberationHistoryItem['NOT_ID'], - // vawName: liberationHistoryItem['NOT_NOME'], - // vawRef: liberationHistoryItem['NOT_ID'], - labelsHashMap: Map.from({ - 'Nome:': liberationHistoryItem['VTE_NOME'], - 'Data:': liberationHistoryItem['NOT_DTENVIO'], - 'Motivo:': liberationHistoryItem['NOT_MOTIVO'], - 'Mensagem:': liberationHistoryItem['NOT_MSGENVIO'], - // 'Resposta:': liberationHistoryItem['NOT_MSGRESPOSTA'], - }), - buttons: [ - if (liberationHistoryItem['NOT_STATUS'] == 'S') - FlutterFlowIconButton( - icon: const Icon(Icons.done), - onPressed: () async { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Aprovar Visita', - enText: 'Approve Visit', - ), - ), - content: Text( - FFLocalizations.of(context).getVariableText( - ptText: - 'Você tem certeza que deseja aprovar essa visita?', - enText: - 'Are you sure you want to approve this visit?', - ), - ), - backgroundColor: - FlutterFlowTheme.of(context).primaryBackground, - actions: [ - FFButtonWidget( - text: - FFLocalizations.of(context).getVariableText( - enText: 'No', - ptText: 'Não', + return Dialog( + alignment: Alignment.center, + child: VisitRequestTemplateComponentWidget( + // vteName: liberationHistoryItem['VTE_NOME'], + // vteReason: liberationHistoryItem['NOT_MOTIVO'], + // vawDate: liberationHistoryItem['NOT_STATUS'] == 'S' + // ? liberationHistoryItem['NOT_DTENVIO'] + // : liberationHistoryItem['NOT_DTRESPOSTA'], + // vawStatus: liberationHistoryItem['NOT_STATUS'], + // vteMsg: liberationHistoryItem['NOT_MSGENVIO'], + // vteUUID: liberationHistoryItem['VTE_ID'], + // cliUUID: FFAppState().cliUUID, + // msgUUID: liberationHistoryItem['NOT_ID'], + // vawDestino: liberationHistoryItem['NOT_DESTINO'], + // vawUUID: liberationHistoryItem['NOT_ID'], + // vawName: liberationHistoryItem['NOT_NOME'], + // vawRef: liberationHistoryItem['NOT_ID'], + labelsHashMap: Map.from({ + 'Nome:': liberationHistoryItem['VTE_NOME'], + 'Data:': liberationHistoryItem['NOT_DTENVIO'], + 'Motivo:': liberationHistoryItem['NOT_MOTIVO'], + 'Mensagem:': liberationHistoryItem['NOT_MSGENVIO'], + // 'Resposta:': liberationHistoryItem['NOT_MSGRESPOSTA'], + }), + buttons: [ + if (liberationHistoryItem['NOT_STATUS'] == 'S') + FlutterFlowIconButton( + icon: const Icon(Icons.done), + onPressed: () async { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Aprovar Visita', + enText: 'Approve Visit', ), - onPressed: () { - Navigator.pop(context); - }, - options: FFButtonOptions( + ), + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja aprovar essa visita?', + enText: + 'Are you sure you want to approve this visit?', + ), + ), + backgroundColor: FlutterFlowTheme.of(context) + .primaryBackground, + actions: [ + FFButtonWidget( + text: FFLocalizations.of(context) + .getVariableText( + enText: 'No', + ptText: 'Não', + ), + onPressed: () { + Navigator.pop(context); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: FlutterFlowTheme.of(context) + .primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context) + .primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), + ), + FFButtonWidget( + text: FFLocalizations.of(context) + .getVariableText( + enText: 'Yes', + ptText: 'Sim', + ), + onPressed: () async { + Navigator.pop(context); + Navigator.pop(context); + await answersRequest + .call( + context, + liberationHistoryItem['NOT_ID'] + .toString(), + 'L', + 'Mensagem', + liberationHistoryItem['VTE_ID'] + .toString(), + ) + .then((value) {}); + }, + options: FFButtonOptions( width: 100, height: 40, color: FlutterFlowTheme.of(context) @@ -408,86 +447,82 @@ Widget liberationHistoryItemCard( .primaryBackground, width: 1, ), - borderRadius: BorderRadius.circular(10)), - ), - FFButtonWidget( - text: - FFLocalizations.of(context).getVariableText( - enText: 'Yes', - ptText: 'Sim', - ), - onPressed: () async { - Navigator.pop(context); - Navigator.pop(context); - await answersRequest - .call( - context, - liberationHistoryItem['NOT_ID'] - .toString(), - 'L', - 'Mensagem', - liberationHistoryItem['VTE_ID'] - .toString(), - ) - .then((value) {}); - }, - options: FFButtonOptions( - width: 100, - height: 40, - color: FlutterFlowTheme.of(context) - .primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context) - .primaryText, + borderRadius: BorderRadius.circular(10), ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, - width: 1, + ), + ], + ); + }); + }, + ), + if (liberationHistoryItem['NOT_STATUS'] == 'S') + FlutterFlowIconButton( + icon: const Icon(Icons.close), + onPressed: () async { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Bloquear Visita', + enText: 'Block Visit', + ), + ), + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja bloquear essa visita?', + enText: + 'Are you sure you want to block this visit?', + ), + ), + backgroundColor: FlutterFlowTheme.of(context) + .primaryBackground, + actions: [ + FFButtonWidget( + text: FFLocalizations.of(context) + .getVariableText( + enText: 'No', + ptText: 'Não', ), - borderRadius: BorderRadius.circular(10), + onPressed: () { + Navigator.pop(context); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: FlutterFlowTheme.of(context) + .primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context) + .primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), ), - ), - ], - ); - }); - }, - ), - if (liberationHistoryItem['NOT_STATUS'] == 'S') - FlutterFlowIconButton( - icon: const Icon(Icons.close), - onPressed: () async { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Bloquear Visita', - enText: 'Block Visit', - ), - ), - content: Text( - FFLocalizations.of(context).getVariableText( - ptText: - 'Você tem certeza que deseja bloquear essa visita?', - enText: - 'Are you sure you want to block this visit?', - ), - ), - backgroundColor: - FlutterFlowTheme.of(context).primaryBackground, - actions: [ - FFButtonWidget( - text: - FFLocalizations.of(context).getVariableText( - enText: 'No', - ptText: 'Não', - ), - onPressed: () { - Navigator.pop(context); - }, - options: FFButtonOptions( + FFButtonWidget( + text: FFLocalizations.of(context) + .getVariableText( + enText: 'Yes', + ptText: 'Sim', + ), + onPressed: () async { + await answersRequest.call( + context, + liberationHistoryItem['NOT_ID'] + .toString(), + 'B', + 'Mensagem', + liberationHistoryItem['VTE_ID'] + .toString(), + ); + }, + options: FFButtonOptions( width: 100, height: 40, color: FlutterFlowTheme.of(context) @@ -501,74 +536,44 @@ Widget liberationHistoryItemCard( .primaryBackground, width: 1, ), - borderRadius: BorderRadius.circular(10)), - ), - FFButtonWidget( - text: - FFLocalizations.of(context).getVariableText( - enText: 'Yes', - ptText: 'Sim', - ), - onPressed: () async { - await answersRequest.call( - context, - liberationHistoryItem['NOT_ID'].toString(), - 'B', - 'Mensagem', - liberationHistoryItem['VTE_ID'].toString(), - ); - }, - options: FFButtonOptions( - width: 100, - height: 40, - color: FlutterFlowTheme.of(context) - .primaryBackground, - textStyle: TextStyle( - color: FlutterFlowTheme.of(context) - .primaryText, + borderRadius: BorderRadius.circular(10), ), - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, - width: 1, - ), - borderRadius: BorderRadius.circular(10), ), - ), - ], - ); - }); - }, - ), - ], - statusHashMap: [ - liberationHistoryItem['NOT_STATUS'] == 'L' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Finalizado', - enText: 'Finished', - ): FlutterFlowTheme.of(context).success, - }) - : liberationHistoryItem['NOT_STATUS'] == 'B' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked', - ): FlutterFlowTheme.of(context).error, - }) - : Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active', - ): FlutterFlowTheme.of(context).warning, - }) - ], - imageHashMap: Map.from({ - 'key': liberationHistoryItem['VTE_ID'], - 'value': 'E', - }), - // changeStatusAction: answersRequest, - // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], + ], + ); + }); + }, + ), + ], + statusHashMap: [ + liberationHistoryItem['NOT_STATUS'] == 'L' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Finalizado', + enText: 'Finished', + ): FlutterFlowTheme.of(context).success, + }) + : liberationHistoryItem['NOT_STATUS'] == 'B' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }) + : Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).warning, + }) + ], + imageHashMap: Map.from({ + 'key': liberationHistoryItem['VTE_ID'], + 'value': 'E', + }), + // changeStatusAction: answersRequest, + // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], + ), ); }, ).then((_) { 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 022d79b9..3ce328e6 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 @@ -2,6 +2,7 @@ import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/form_field_controller.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/request_manager.dart'; @@ -164,11 +165,21 @@ class ScheduleCompleteVisitPageModel ); textFieldFocusNode1 = FocusNode(); - textController1 = TextEditingController(); + textController1 = TextEditingController( + text: dateTimeFormat( + 'd/M/y H:mm:ss', + DateTime.now().add(const Duration(minutes: 10)), + // locale: FFLocalizations.of(context).languageCode, + )); textController1Validator = _textController1Validator; textFieldFocusNode2 = FocusNode(); - textController2 = TextEditingController(); + textController2 = TextEditingController( + text: dateTimeFormat( + 'd/M/y H:mm:ss', + DateTime.now().add(const Duration(days: 1)), + // locale: FFLocalizations.of(context).languageCode, + )); textController2Validator = _textController2Validator; textFieldFocusNode3 = FocusNode(); diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart index 0ca53309..733a5bcc 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart @@ -29,22 +29,10 @@ class ScheduleCompleteVisitPageWidget extends StatefulWidget { const ScheduleCompleteVisitPageWidget({ super.key, this.visitorStrList, - this.visitStartDateStr, - this.visitEndDateStr, - this.visitReasonStr, - this.visitLevelStr, - this.visitTempBol, - this.visitObsStr, this.visitorJsonList, }); final String? visitorStrList; - final String? visitStartDateStr; - final String? visitEndDateStr; - final String? visitReasonStr; - final String? visitLevelStr; - final bool? visitTempBol; - final String? visitObsStr; final List? visitorJsonList; @override @@ -250,10 +238,7 @@ Widget bodyScheduleCompleteVisit( scheduleVisit(context, _model, setState, safeSetState), wrapWithModel( model: _model, - child: VisitHistoryWidget( - model: _model, - safeSetState: safeSetState, - ), + child: VisitHistoryWidget(), updateCallback: () { setState(() {}); }, diff --git a/lib/pages/visit_history_page/visit_history_page_widget.dart b/lib/pages/visit_history_page/visit_history_page_widget.dart index b688d554..b7291b9f 100644 --- a/lib/pages/visit_history_page/visit_history_page_widget.dart +++ b/lib/pages/visit_history_page/visit_history_page_widget.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:hub/actions/actions.dart'; import 'package:hub/app_state.dart'; @@ -6,144 +8,174 @@ import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/components/templates_components/details_component/details_component_action.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart'; import 'package:provider/provider.dart'; -class VisitHistoryWidget extends StatelessWidget { - final ScheduleCompleteVisitPageModel _model; - final Function safeSetState; - - const VisitHistoryWidget({ +class VisitHistoryWidget extends StatefulWidget { + VisitHistoryWidget({ Key? key, - required ScheduleCompleteVisitPageModel model, - required this.safeSetState, - }) : _model = model, - super(key: key); + }) : super(key: key); + @override + _VisitHistoryWidgetState createState() => _VisitHistoryWidgetState(); +} + +class _VisitHistoryWidgetState extends State { @override Widget build(BuildContext context) { + var response = ScheduleCompleteVisitPageModel().visitHistory( + requestFn: () => PhpGroup.getVisitsCall.call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + cliID: FFAppState().cliUUID, + atividade: 'getVisitas', + pageSize: 100, + pageNumber: 1, + ), + ); return Container( width: double.infinity, height: 900.0, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, ), - child: Consumer( - builder: (context, model, _) { - return StreamBuilder( - stream: model.visitHistory( - requestFn: () => PhpGroup.getVisitsCall.call( - devUUID: FFAppState().devUUID, - userUUID: FFAppState().userUUID, - cliID: FFAppState().cliUUID, - atividade: 'getVisitas', - pageSize: 100, - pageNumber: 1, + // child: Consumer( + child: StreamBuilder( + stream: response, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, + ), ), - ), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - FlutterFlowTheme.of(context).primary, - ), - ), - ); - } else if (snapshot.hasError) { - return Center(child: Text('Error: ${snapshot.error}')); - } else if (!snapshot.hasData || snapshot.data!.jsonBody == null) { - return const Center(child: Text('No visits found')); - } - final wrapGetVisitsResponse = snapshot.data!; - final visitaWrap = PhpGroup.getVisitsCall - .visitasList(wrapGetVisitsResponse.jsonBody) - ?.toList() ?? - []; - return ListView.builder( - itemCount: visitaWrap.length, - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - itemBuilder: (context, index) { - final visitaWrapItem = visitaWrap[index]; - return CardItemTemplateComponentWidget( - imageHashMap: { - 'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '', - 'value': 'E', + ); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.jsonBody == null) { + return const Center(child: Text('No visits found')); + } + var wrapGetVisitsResponse = snapshot.data!; + var visitaWrap = PhpGroup.getVisitsCall + .visitasList(wrapGetVisitsResponse.jsonBody) + ?.toList() ?? + []; + log('updated'); + log('visitaWrap: ${visitaWrap[0]}'); + return ListView.builder( + itemCount: visitaWrap.length, + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) { + final visitaWrapItem = visitaWrap[index]; + return CardItemTemplateComponentWidget( + imageHashMap: { + 'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '', + 'value': 'E', + }, + labelsHashMap: { + 'Nome:': visitaWrapItem['VTE_NOME'] ?? '', + 'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '', + 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', + }, + statusHashMap: [ + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).warning, }, - labelsHashMap: { - 'Nome:': visitaWrapItem['VTE_NOME'] ?? '', - 'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '', - 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.finished) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Finalizado', + enText: 'Finished', + ): FlutterFlowTheme.of(context).success, }, - statusHashMap: [ - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.active) - { - FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active', - ): FlutterFlowTheme.of(context).warning, - }, - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.finished) - { - FFLocalizations.of(context).getVariableText( - ptText: 'Finalizado', - enText: 'Finished', - ): FlutterFlowTheme.of(context).success, - }, - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.unknown) - { - FFLocalizations.of(context).getVariableText( - ptText: 'Desconhecido', - enText: 'Unknown', - ): FlutterFlowTheme.of(context).alternate, - }, - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.canceled) - { - FFLocalizations.of(context).getVariableText( - ptText: 'Cancelado', - enText: 'Canceled', - ): FlutterFlowTheme.of(context).error, - }, - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.blocked) - { - FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked', - ): FlutterFlowTheme.of(context).error, - }, - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.inactive) - { - FFLocalizations.of(context).getVariableText( - ptText: 'Inactive', - enText: 'Inactive', - ): FlutterFlowTheme.of(context).error, - }, - ], - onTapCardItemAction: () async { - showModalBottomSheet( - isScrollControlled: true, - isDismissible: true, - backgroundColor: Colors.transparent, - useSafeArea: true, - context: context, - builder: (context) { - return buildDetails( - visitaWrapItem, - context, - changeStatusAction, - ); - }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.unknown) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Desconhecido', + enText: 'Unknown', + ): FlutterFlowTheme.of(context).alternate, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.canceled) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Cancelado', + enText: 'Canceled', + ): FlutterFlowTheme.of(context).error, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.blocked) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.inactive) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Inactive', + enText: 'Inactive', + ): FlutterFlowTheme.of(context).error, + }, + ], + onTapCardItemAction: () async { + await showDialog( + // isScrollControlled: true, + // isDismissible: true, + // backgroundColor: Colors.transparent, + useSafeArea: true, + context: context, + + builder: (context) { + return Dialog( + alignment: Alignment.center, + child: buildDetails( + visitaWrapItem, + context, + changeStatusAction, + ), ); }, - ); + ).whenComplete(() async { + log('Complete'); + final newResponseStream = + ScheduleCompleteVisitPageModel().visitHistory( + requestFn: () => PhpGroup.getVisitsCall.call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + cliID: FFAppState().cliUUID, + atividade: 'getVisitas', + pageSize: 100, + pageNumber: 1, + ), + ); + newResponseStream.listen((newResponse) { + log('New response received: $newResponse'); + if (mounted) { + safeSetState(() { + response = newResponse.jsonBody; + log('Response updated: $response'); + }); + } else { + log('Widget is not mounted, skipping state update.'); + } + }).onError((err) { + log('Error: $err'); + }); + }).catchError((err, stack) { + log('Error: $err'); + log('Stack: $stack'); + }); }, ); },