From a1d361b7777cad1f1df5479bc8578720bd439168 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Mon, 9 Dec 2024 16:18:36 -0300 Subject: [PATCH] WIP --- lib/backend/api_requests/api_calls.dart | 36 ++- .../card_item_template_component_widget.dart | 1 + .../pages/prov_schedule_page.dart | 5 +- .../presentation/widgets/filter_modal.dart | 229 ++++++++++++++++++ .../histories/presentation/widgets/index.dart | 1 + lib/pages/visits_on_the_property/model.dart | 19 +- .../visits_on_the_property_screen.dart | 4 +- 7 files changed, 263 insertions(+), 32 deletions(-) create mode 100644 lib/features/histories/presentation/widgets/filter_modal.dart diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index ab81afc1..6822bd1a 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -63,36 +63,34 @@ class PhpGroup { } class GetProvSchedules { - Future call(final String page) async { - // final String baseUrl = PhpGroup.getBaseUrl(); - // final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - // final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - // final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - // const String atividade = 'getProvSchedules'; - // const String pageSize = '10'; - final String baseUrl = 'http://localhost:3000'; + Future call(final String page, final String status) async { + final String baseUrl = PhpGroup.getBaseUrl(); + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + const String atividade = 'getAgendamentoProv'; + const String pageSize = '10'; + // const String baseUrl = 'http://localhost:3000'; return await ApiManager.instance.makeApiCall( callName: 'getProvSchedules', - apiUrl: '$baseUrl/getAgendamentoProv.php', + apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, headers: {'Content-Type': 'application/x-www-form-urlencoded'}, params: { - "proId": "8", - "status": "AT", - "page": page, - "pageSize": "10" - // 'devUUID': devUUID, - // 'userUUID': userUUID, - // 'cliID': cliID, - // 'atividade': atividade, - // 'page': page, - // 'pageSize': pageSize, + if(status != '') 'status': status, + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'atividade': atividade, + 'page': page, + 'pageSize': pageSize, }, bodyType: BodyType.X_WWW_FORM_URL_ENCODED, returnBody: true, encodeBodyUtf8: false, decodeUtf8: false, cache: false, + isStreamingApi: false, alwaysAllowBody: false, ); } diff --git a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart index 4814763e..f93d6d8a 100644 --- a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart +++ b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart @@ -165,6 +165,7 @@ class _CardItemTemplateComponentWidgetState extends State fetchProvisionalScheduleHistoryService() async { try { setState(() => _loading = true); - var response = await PhpGroup.getProvSchedules.call( - _pageNumber.toString() - ); + var response = await PhpGroup.getProvSchedules.call(_pageNumber.toString()); final List ProvisionalScheduleHistory = response.jsonBody['agendamento']['value'] ?? []; @@ -447,4 +445,5 @@ class _ProvisionalScheduleHistoryState extends State { + FocusNode? textFieldFocusNode; + TextEditingController? textController; + String? Function(BuildContext, String?)? textControllerValidator; + bool? checkboxValue1; + bool? checkboxValue2; + FormFieldController>? checkboxGroupValueController; + List? get checkboxGroupValues => checkboxGroupValueController?.value; + set checkboxGroupValues(List? v) => checkboxGroupValueController?.value = v; + + @override + void initState(BuildContext context) {} + + @override + void dispose() { + textFieldFocusNode?.dispose(); + textController?.dispose(); + } +} + +class FilterModalWidget extends StatefulWidget { + final Map defaultSelections; + final Map>> filterOptions; + final Map filterTitles; + + const FilterModalWidget({ + super.key, + required this.defaultSelections, + required this.filterOptions, + required this.filterTitles, + }); + + @override + _FilterModalWidgetState createState() => _FilterModalWidgetState(); +} + +class _FilterModalWidgetState extends State { + late FilterModal _model; + late Map selected; + + @override + void setState(VoidCallback callback) { + super.setState(callback); + _model.onUpdate(); + } + + @override + void initState() { + super.initState(); + + _model = createModel(context, () => FilterModal()); + + _model.textController ??= TextEditingController(); + _model.textFieldFocusNode ??= FocusNode(); + + selected = widget.defaultSelections; + } + + void _applyFilter() { + Map filterResult = { + 'search': _model.textController?.text == '' ? '' : _model.textController!.text.toLowerCase(), + }; + + widget.filterOptions.forEach((key, options) { + filterResult[key] = selected[key]!.isEmpty || selected[key]!.length > 1 + ? '' + : selected[key]!; + }); + + context.pop(filterResult); + } + + Widget _buildCheckboxListTile(String key, List> options, double fontsize) { + double limitedInputFontSize = LimitedFontSizeUtil.getInputFontSize(context); + return Column( + children: [ + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 3.0, 0.0, 0.0), + child: Text( + widget.filterTitles[key]!, + textAlign: TextAlign.left, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + fontSize: limitedInputFontSize, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + color: FlutterFlowTheme.of(context).primaryText, + ), + ), + ), + ], + ), + ListView.builder( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: options.length, + itemBuilder: (context, index) { + final option = options[index]; + return CheckboxListTile( + title: Text( + option['title']!, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + fontSize: limitedInputFontSize, + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + color: FlutterFlowTheme.of(context).primaryText, + ), + ), + dense: true, + value: selected[key]!.contains(option['value']), + onChanged: (bool? value) { + setState(() { + if (value == true) { + if (!selected[key]!.contains(option['value'])) { + selected[key] = (option['value']); + } + } else { + selected[key] = ''; + } + }); + }, + activeColor: FlutterFlowTheme.of(context).primary, + checkColor: FlutterFlowTheme.of(context).info, + checkboxShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(100), + ), + enableFeedback: true, + side: BorderSide( + width: 5, + color: FlutterFlowTheme.of(context).secondaryText, + ), + controlAffinity: ListTileControlAffinity.leading, + ); + }, + ), + ], + ); + } + + @override + Widget build(BuildContext context) { + double screenWidth = MediaQuery.of(context).size.width; + + return Center( + child: Container( + width: screenWidth - (screenWidth * 0.35), + height: screenWidth - (screenWidth * 0.1), + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primaryBackground, + borderRadius: BorderRadius.circular(24.0), + ), + child: Padding( + padding: const EdgeInsets.all(4.0), + child: Column( + children: [ + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(10.0, 10.0, 0.0, 10.0), + child: Text( + FFLocalizations.of(context).getText('yfj9pd6k'), + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + fontSize: LimitedFontSizeUtil.getHeaderFontSize(context), + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineMediumFamily), + ), + ), + ), + ], + ), + Expanded( + child: SingleChildScrollView( + child: Container( + padding: const EdgeInsets.all(10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: widget.filterOptions.keys.map((key) { + return _buildCheckboxListTile(key, widget.filterOptions[key]!, 14); + }).toList(), + ), + ), + ), + ), + ElevatedButton( + onPressed: _applyFilter, + style: ElevatedButton.styleFrom( + foregroundColor: FlutterFlowTheme.of(context).info, + backgroundColor: FlutterFlowTheme.of(context).primary, + ), + child: Text(FFLocalizations.of(context).getText('88kshkph'), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).info, + fontSize: LimitedFontSizeUtil.getInputFontSize(context), + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + )), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/histories/presentation/widgets/index.dart b/lib/features/histories/presentation/widgets/index.dart index e69de29b..2191ab0c 100644 --- a/lib/features/histories/presentation/widgets/index.dart +++ b/lib/features/histories/presentation/widgets/index.dart @@ -0,0 +1 @@ +export 'filter_modal.dart'; diff --git a/lib/pages/visits_on_the_property/model.dart b/lib/pages/visits_on_the_property/model.dart index 9870b4bb..8a317179 100644 --- a/lib/pages/visits_on_the_property/model.dart +++ b/lib/pages/visits_on_the_property/model.dart @@ -75,13 +75,16 @@ class VisitsModel extends FlutterFlowModel { imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&cliID=${cliUUID}&atividade=getFoto&Documento=${item['VDO_DOCUMENTO']}&tipo=E', statusHashMap: [ - if (item['VTA_FIXA'] != null) - Map.from({ - item['VTA_FIXA'] - ? FFLocalizations.of(context).getVariableText(ptText: "Entrada Única", enText: "Single Entry") - : FFLocalizations.of(context).getVariableText( - ptText: "Entrada Recorrente", enText: "Recurrent Entry"): FlutterFlowTheme.of(context).warning - }), - ]); + Map.from({ + if (item['VTA_FIXA'] != null) + FFLocalizations.of(context).getVariableText( + ptText: item['VTA_FIXA'] ? "Entrada Única" : "Entrada Recorrente", + enText: item['VTA_FIXA'] ? "Single Entry" : "Recurrent Entry", + ): item['VTA_FIXA'] == true + ? FlutterFlowTheme.of(context).success + : FlutterFlowTheme.of(context).warning, + }) + ], + ); } } diff --git a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart index b4a283eb..ddc81d31 100644 --- a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart +++ b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart @@ -232,14 +232,14 @@ class _VisitsOnThePropertyState extends State with TickerPr uItem['MOT_DESCRICAO'][0].toUpperCase() + uItem['MOT_DESCRICAO'].substring(1).toLowerCase(), }, statusHashMap: [ - if (uItem['VTA_FIXA'] == true) + if (uItem['VTA_FIXA'] == false) { FFLocalizations.of(context).getVariableText( ptText: 'Recorrente', enText: 'Recurrent', ): FlutterFlowTheme.of(context).warning, }, - if (uItem['VTA_FIXA'] == false) + if (uItem['VTA_FIXA'] == true) { FFLocalizations.of(context).getVariableText( ptText: 'Única',