From 4d45de2890ebfd52a2ecb9ac28c79ac6869d3490 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Aug 2024 16:46:35 -0300 Subject: [PATCH] =?UTF-8?q?Adicionado=20tratamento=20de=20erro,=20corrigid?= =?UTF-8?q?o=20modal,=20corrigido=20erro=20de=20espa=C3=A7amento=20do=20ca?= =?UTF-8?q?rd=20e=20adicionado=20Snackbar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message_opt_modal/opt_modal_widget.dart | 90 +------------ .../card_item_template_component_widget.dart | 2 +- .../acess_history_page_widget.dart | 126 +++++++++++------- 3 files changed, 85 insertions(+), 133 deletions(-) diff --git a/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart b/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart index 7dfaf73c..bd40eb5a 100644 --- a/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart +++ b/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart @@ -30,10 +30,6 @@ class _OptModalWidgetState extends State { {'title': 'zok7lu4w', 'value': 'E'}, {'title': 'oonqk812', 'value': 'O'}, ]; - final List> accessTypeOptions = [ - {'title': '580z80ct', 'value': '0'}, - {'title': '1nbwqtzs', 'value': '1'}, - ]; @override void setState(VoidCallback callback) { @@ -187,7 +183,7 @@ class _OptModalWidgetState extends State { return Center( child: Container( width: screenWidth * 0.75, - height: screenHeight * 0.70, + height: screenHeight * 0.35, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, borderRadius: BorderRadius.circular(24.0), @@ -222,84 +218,6 @@ class _OptModalWidgetState extends State { ), ], ), - Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), - child: TextFormField( - controller: _model.textController, - focusNode: _model.textFieldFocusNode, - autofocus: false, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - '0enrtljz' /* Pesquise aqui... */, - ), - 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( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).alternate, - width: 1, - ), - borderRadius: BorderRadius.circular(8.0), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primary, - width: 1, - ), - borderRadius: BorderRadius.circular(8.0), - ), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 1, - ), - borderRadius: BorderRadius.circular(8.0), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 1, - ), - borderRadius: BorderRadius.circular(8.0), - ), - filled: true, - fillColor: FlutterFlowTheme.of(context).alternate, - suffixIcon: const Icon( - Icons.search_outlined, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - validator: - _model.textControllerValidator.asValidator(context), - ), - ), Expanded( child: SingleChildScrollView( child: Container( @@ -307,10 +225,8 @@ class _OptModalWidgetState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - _buildCheckboxListTile('personType', personTypeOptions, - screenHeight * 0.025), - _buildCheckboxListTile('accessType', accessTypeOptions, - screenHeight * 0.025), + _buildCheckboxListTile( + 'personType', personTypeOptions, 14), ], ), ), 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 9550f897..a315e2cc 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 @@ -132,7 +132,7 @@ class _CardItemTemplateComponentWidgetState String value = labelsLinkedHashMap[key]!; return Padding( padding: - const EdgeInsets.fromLTRB(0, 5, 0, 3), + const EdgeInsets.fromLTRB(0, 2, 0, 5), child: Padding( padding: const EdgeInsets.fromLTRB(20, 0, 0, 0), diff --git a/lib/pages/acess_history_page/acess_history_page_widget.dart b/lib/pages/acess_history_page/acess_history_page_widget.dart index 4fa801d7..358b70c0 100644 --- a/lib/pages/acess_history_page/acess_history_page_widget.dart +++ b/lib/pages/acess_history_page/acess_history_page_widget.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:developer'; import 'package:flutter/cupertino.dart'; @@ -67,7 +68,8 @@ class _AcessHistoryPageWidgetState extends State { late Future _accessFuture; List _accessWrap = []; - _AcessHistoryPageWidgetState(Map opt) : selectedTypeSubject = BehaviorSubject.seeded(opt) { + _AcessHistoryPageWidgetState(Map opt) + : selectedTypeSubject = BehaviorSubject.seeded(opt) { selectedTypeSubject.listen((value) {}); } @@ -77,11 +79,20 @@ class _AcessHistoryPageWidgetState extends State { _model = createModel(context, () => AcessHistoryPageModel()); _accessFuture = fetchAccessHistoryService(); - _scrollController = ScrollController()..addListener(() { - if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { - _loadMoreAccess(); - } - }); + _scrollController = ScrollController() + ..addListener(() { + if (_scrollController.position.atEdge && + _scrollController.position.pixels != 0) { + _loadMoreAccess(); + WidgetsBinding.instance.addPostFrameCallback((_) { + Timer(const Duration(seconds: 3), () { + if (!_hasData && _pageNumber > 1) { + _showNoMoreDataSnackbar(context); + } + }); + }); + } + }); } @override @@ -102,7 +113,6 @@ class _AcessHistoryPageWidgetState extends State { body: _body(context)); } - PreferredSizeWidget _appBar(BuildContext context, FlutterFlowTheme theme) { return AppBar( backgroundColor: theme.primaryBackground, @@ -111,9 +121,7 @@ class _AcessHistoryPageWidgetState extends State { title: _title(context, theme), centerTitle: true, elevation: 0.0, - actions: [ - _filterButton(context) - ], + actions: [_filterButton(context)], ); } @@ -141,7 +149,7 @@ class _AcessHistoryPageWidgetState extends State { fontSize: 16.0, letterSpacing: 0.0, useGoogleFonts: - GoogleFonts.asMap().containsKey(theme.headlineMediumFamily), + GoogleFonts.asMap().containsKey(theme.headlineMediumFamily), ), ); } @@ -155,7 +163,8 @@ class _AcessHistoryPageWidgetState extends State { child: IconButton( icon: const Icon(Icons.filter_list), onPressed: () async { - final Map? selectedFilter = await showModalBottomSheet>( + final Map? selectedFilter = + await showModalBottomSheet>( isScrollControlled: true, backgroundColor: Colors.transparent, context: context, @@ -167,8 +176,12 @@ class _AcessHistoryPageWidgetState extends State { child: GestureDetector( onTap: () {}, child: OptModalWidget( - defaultAccessType: selectedTypeSubject.value['accessType'] ?? '.*', - defaultPersonType: selectedTypeSubject.value['personType'] ?? '.*', + defaultAccessType: + selectedTypeSubject.value['accessType'] ?? + '.*', + defaultPersonType: + selectedTypeSubject.value['personType'] ?? + '.*', ), ), ), @@ -220,9 +233,15 @@ class _AcessHistoryPageWidgetState extends State { final List accessHistory = response.jsonBody['acessos'] ?? []; List filteredAccess = accessHistory.where((item) { - final personTypeMatches = _personType == '.*' || item["PES_TIPO"].toString() == _personType; - final accessTypeMatches = _accessType == '.*' || item["ACE_TIPO"].toString() == _accessType; - final searchMatches = _search == '.*' || item["PES_NOME"].toString().toLowerCase().contains(_search.toLowerCase()); + final personTypeMatches = + _personType == '.*' || item["PES_TIPO"].toString() == _personType; + final accessTypeMatches = + _accessType == '.*' || item["ACE_TIPO"].toString() == _accessType; + final searchMatches = _search == '.*' || + item["PES_NOME"] + .toString() + .toLowerCase() + .contains(_search.toLowerCase()); return personTypeMatches && accessTypeMatches && searchMatches; }).toList(); @@ -250,35 +269,51 @@ class _AcessHistoryPageWidgetState extends State { } } + void _showNoMoreDataSnackbar(BuildContext context) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: "Não há mais dados.", enText: "No more data."), + ), + duration: const Duration(seconds: 3), + backgroundColor: FlutterFlowTheme.of(context).primary, + ), + ); + } + Widget _body(BuildContext context) { return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: _cardListViewOrganismWidget()), - if (_loading) Container( - padding: const EdgeInsets.only(top: 15, bottom: 15), - color: FlutterFlowTheme.of(context).primary, - child: Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - FlutterFlowTheme.of(context).info, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (_hasData == false && _pageNumber <= 1 && _loading == false) + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Center( + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: "Nenhum histórico encontrado!", + enText: "No history found!"), + )), + ], + ), + ) + else if (_hasData || _pageNumber >= 1) + Expanded(child: _cardListViewOrganismWidget()), + if (_hasData == true && _loading) + Container( + padding: const EdgeInsets.only(top: 15, bottom: 15), + child: Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, + ), ), ), - ), - ), - if (_hasData == false) Container( - padding: const EdgeInsets.only(top: 15, bottom: 15), - color: FlutterFlowTheme.of(context).primary, - child: Center( - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", - enText: "No more data." - ), - style: TextStyle(color: FlutterFlowTheme.of(context).info), - ) - ), - ), + ) ], ); } @@ -303,7 +338,8 @@ class _AcessHistoryPageWidgetState extends State { return FutureBuilder( future: _accessFuture, builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting && _accessWrap.isEmpty) { + if (snapshot.connectionState == ConnectionState.waiting && + _accessWrap.isEmpty) { return Center( child: SizedBox( width: 50.0, @@ -336,8 +372,8 @@ class _AcessHistoryPageWidgetState extends State { ); } - Widget _accessHistoryCardMoleculeWidget(BuildContext context, dynamic accessHistoryItem) { - + Widget _accessHistoryCardMoleculeWidget( + BuildContext context, dynamic accessHistoryItem) { return CardItemTemplateComponentWidget( imageHashMap: Map.from({ 'key': accessHistoryItem['PES_ID'] ?? '',