From b0e4e86391c0939d1e78c4d3a6dc2e90fd051679 Mon Sep 17 00:00:00 2001 From: jantunesmessias Date: Mon, 10 Feb 2025 14:00:03 -0300 Subject: [PATCH] add infinite_scroll_View --- lib/flutter_flow/flutter_flow_util.dart | 45 +- .../liberation_history_widget.dart | 4 +- lib/pages/pets_page/pets_page_model.dart | 6 +- .../schedule_complete_visit_page_model.dart | 6 +- .../vehicle_history_screen.dart | 492 +++++++++--------- .../vehicle_model.dart | 41 +- .../vehicles_on_the_property.dart | 1 + 7 files changed, 310 insertions(+), 285 deletions(-) diff --git a/lib/flutter_flow/flutter_flow_util.dart b/lib/flutter_flow/flutter_flow_util.dart index b86d9da4..13308e5e 100644 --- a/lib/flutter_flow/flutter_flow_util.dart +++ b/lib/flutter_flow/flutter_flow_util.dart @@ -529,7 +529,7 @@ void setAppLanguage(BuildContext context, String language) => void setDarkModeSetting(BuildContext context, ThemeMode themeMode) => App.of(context).setThemeMode(themeMode); -void showSnackbar( +void showSnackbarMessenger( BuildContext context, String message, bool error, { @@ -573,6 +573,47 @@ void showSnackbar( ); } +SnackBar showSnackbar( + BuildContext context, + String message, + bool error, { + bool loading = false, + int duration = 4, +}) { + return SnackBar( + content: Row( + children: [ + if (loading) + Padding( + padding: const EdgeInsetsDirectional.only(end: 10.0), + child: SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator( + color: FlutterFlowTheme.of(context).info, + ), + ), + ), + Text( + message, + style: TextStyle( + color: FlutterFlowTheme.of(context).info, + fontSize: LimitedFontSizeUtil.getBodyFontSize(context), + ), + ), + ], + ), + duration: Duration(seconds: duration), + backgroundColor: error + ? FlutterFlowTheme.of(context).error + : FlutterFlowTheme.of(context).success, + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ); +} + void showAlertDialog(BuildContext context, String title, String content, Future Function() action) { double limitedBodyFontSize = LimitedFontSizeUtil.getBodyFontSize(context); @@ -785,5 +826,3 @@ double computeGradientAlignmentY(double evaluatedAngle) { } return double.parse(roundTo(y, 2)); } - - diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index f69abdee..d4f4ce88 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -299,7 +299,7 @@ class _LiberationHistoryWidgetState extends State { ) .then((message) { if (message != null || message != '') { - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Successfully resolved visit', @@ -308,7 +308,7 @@ class _LiberationHistoryWidgetState extends State { false, ); } else { - showSnackbar(context, message, true); + showSnackbarMessenger(context, message, true); } }).whenComplete(() { safeSetState(() { diff --git a/lib/pages/pets_page/pets_page_model.dart b/lib/pages/pets_page/pets_page_model.dart index e7de27fe..6671c468 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -474,7 +474,7 @@ class PetsPageModel extends FlutterFlowModel { context.pop(value); if (value == false) { - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( ptText: 'Erro ao excluir pet', @@ -483,7 +483,7 @@ class PetsPageModel extends FlutterFlowModel { true, ); } else if (value == true) { - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Success deleting pet', @@ -494,7 +494,7 @@ class PetsPageModel extends FlutterFlowModel { } }).catchError((err, stack) { context.pop(); - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Error deleting pet', 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 f7248d93..f6c80364 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 @@ -472,7 +472,7 @@ class ScheduleCompleteVisitPageModel context.pop(value); if (value == false) { - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Error blocking visit', @@ -481,7 +481,7 @@ class ScheduleCompleteVisitPageModel true, ); } else if (value == true) { - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Success canceling visit', @@ -492,7 +492,7 @@ class ScheduleCompleteVisitPageModel } }).catchError((err, stack) { context.pop(); - showSnackbar( + showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Error blocking visit', diff --git a/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart b/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart index 4f6c6bdf..a75000c3 100644 --- a/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart +++ b/lib/pages/vehicles_on_the_property/vehicle_history_screen.dart @@ -1,13 +1,10 @@ part of 'vehicles_on_the_property.dart'; -/// [VehicleHistoryScreen] is a StatefulWidget that displays a list of vehicles. - -// ignore: must_be_immutable +/// Widget que exibe o histórico de veículos na propriedade. class VehicleHistoryScreen extends StatefulWidget { + final VehicleModel model; + VehicleHistoryScreen(this.model, {super.key}); - late VehicleModel model; - final scaffoldKey = GlobalKey(); - final builderKey = GlobalKey(); @override State createState() => _VehicleHistoryScreenState(); @@ -15,167 +12,268 @@ class VehicleHistoryScreen extends StatefulWidget { class _VehicleHistoryScreenState extends State with Remotable { - @override - void dispose() { - super.dispose(); - _pagingController.dispose(); - } + final apiCall = PhpGroup.getVehiclesByProperty; @override void initState() { super.initState(); - _initializeScrollController(); - _pagingController.addPageRequestListener(_fetch); + _pagingController.addPageRequestListener( + (dynamic pageKey) => _fetch( + hasData: () async { + final newItems = await apiCall.call(pageKey.toString()); + if (newItems.jsonBody == null) return (false, null); + final List vehicles = + (newItems.jsonBody['vehicles'] as List?) ?? []; + _pagingController.nextPageKey = pageKey + 1; + + safeSetState(() { + count = newItems.jsonBody['total_rows'] ?? 0; + }); + return (vehicles.isNotEmpty, vehicles); + }, + onNotHas: () { + _showNoMoreDataSnackBar(context); + setState(() { + // _hasData = false; + // _loading = false; + }); + }, + onHas: (vehicles) { + setState(() { + // _loading = false; + }); + _pagingController.appendLastPage(vehicles); + }, + onError: (e, s) { + DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed( + "proccessRequest.php", "", "Consulta de Veículo", e, s); + setState(() { + // _hasData = false; + // _loading = false; + }); + }, + ), + ); + _pagingController.addStatusListener(_showError); + } + + @override + void dispose() { + _pagingController.dispose(); + super.dispose(); + } + + Future _showError(PagingStatus status) async { + if (status == PagingStatus.subsequentPageError) { + final message = FFLocalizations.of(context).getVariableText( + enText: 'Something went wrong while fetching a new page.', + ptText: 'Algo deu errado ao buscar uma nova página.', + ); + final retry = FFLocalizations.of(context).getVariableText( + enText: 'Retry', + ptText: 'Recarregar', + ); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + action: SnackBarAction( + label: retry, + onPressed: () => _pagingController.retryLastFailedRequest(), + ), + ), + ); + } } @override Widget build(BuildContext context) { - late final limitedHeaderTextSize = - LimitedFontSizeUtil.getHeaderFontSize(context); - late final double limitedBodyTextSize = - LimitedFontSizeUtil.getBodyFontSize(context); - return Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, children: [ - // if (_hasData == false && - // _pageNumber <= 1 && - // _loading == false) - // _buildNoDataFound(context, limitedHeaderTextSize) - // else if (_hasData == true || _pageNumber >= 1) - _buildHistoryList(context, limitedBodyTextSize), - // if (_hasData == true && _loading == true) - // _buildLoadingIndicator(context), - ].addToStart(const SizedBox(height: 0)), + _buildHeader(context), + _buildBody(), + ], ); } - Widget _buildNoDataFound(BuildContext context, double limitedHeaderTextSize) { - return Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Center( - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Nenhum veículo encontrado!", - enText: "No vehicle found", - ), - style: TextStyle( - fontFamily: 'Nunito', - fontSize: limitedHeaderTextSize, - ), - ), - ) - ], + Widget _buildHeader(BuildContext context) { + final bodyFontSize = LimitedFontSizeUtil.getBodyFontSize(context); + return SizedBox( + height: 30, + child: Center( + child: Text( + (widget.model.amountRegister == '0' || + widget.model.amountRegister == null) + ? '' + : "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Veículos: ", enText: "Amount of Vehicles: ")}${widget.model.amountRegister}/$count", + textAlign: TextAlign.right, + style: TextStyle( + fontFamily: 'Nunito', + fontSize: bodyFontSize, + ), + ), ), ); } - Widget _buildHistoryList(BuildContext context, double limitedBodyTextSize) { + Expanded _buildBody() { + final noDataFound = FFLocalizations.of(context).getVariableText( + ptText: "Nenhum veículo encontrado!", + enText: "No vehicle found", + ); return Expanded( child: RefreshIndicator( onRefresh: () async => _pagingController.refresh(), child: PagedListView( - // separatorBuilder: (context, index) => const Divider(), pagingController: _pagingController, - builderDelegate: PagedChildBuilderDelegate( + builderDelegate: PagedChildBuilderDelegate( animateTransitions: true, itemBuilder: (context, item, index) => _generateItems(context, index, item), - firstPageErrorIndicatorBuilder: (context) => Placeholder(), - newPageErrorIndicatorBuilder: (context) => Placeholder(), + // noMoreItemsIndicatorBuilder: , + newPageProgressIndicatorBuilder: (context) => + _buildLoadingIndicator(context), + firstPageProgressIndicatorBuilder: (context) => + _buildLoadingIndicator(context), + noItemsFoundIndicatorBuilder: (context) => + _buildNoDataFound(context, noDataFound), + firstPageErrorIndicatorBuilder: (context) => const Placeholder(), + newPageErrorIndicatorBuilder: (context) => const Placeholder(), ), ), ), ); } - // ListView.builder( - // shrinkWrap: true, - // addAutomaticKeepAlives: true, - // restorationId: '', - // physics: const BouncingScrollPhysics(), - // controller: _scrollController, - // itemCount: _wrap.length, - // itemBuilder: (context, index) => _generateItems(context, _wrap[index], index), + Widget _generateItems(BuildContext context, int index, dynamic item) { + log('item: $item'); + final bool? isOwner = item['isOwnerVehicle']; + final IconData iconData = + isOwner == true ? Symbols.garage : Symbols.directions_car; - // ), + final FreCardIcon? cardIcon = isOwner != null + ? FreCardIcon( + height: 50, + width: 100, + icon: Icon(iconData, size: 80, opticalSize: 10), + ) + : null; - Widget _buildLoadingIndicator(BuildContext context) { - return Container( - padding: const EdgeInsets.only(top: 15, bottom: 15), - child: Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - FlutterFlowTheme.of(context).primary, - ), - ), - ), + final String? tag = item['tag']; + final bool containTag = tag.isNotNullAndEmpty; + final Map labelsHashMap = + _generateLabelsHashMap(context, item, tag, containTag); + + final List> statusHashMapList = + _generateStatusHashMapList(item); + + Future onTapCardItemAction() async { + await _handleCardItemTap(context, cardIcon, item); + } + + final statusLinkedHashMap = statusHashMapList + .map((map) => LinkedHashMap.from(map)) + .toList(); + final length = statusLinkedHashMap.expand((e) => [e.length]); + final double itemWidthFactor = length == 1 ? 0.25 : 0.50; + + return CardItemTemplateComponentWidget( + icon: cardIcon, + labelsHashMap: labelsHashMap, + statusHashMap: statusHashMapList, + onTapCardItemAction: onTapCardItemAction, + itemWidthFactor: itemWidthFactor, ); } + + Map _generateLabelsHashMap( + BuildContext context, + Map item, + String? tag, + bool containTag, + ) { + final localization = FFLocalizations.of(context); + return { + '${localization.getVariableText(ptText: "Placa", enText: "License Plate")}:': + item['licensePlate'] ?? '', + '${localization.getVariableText(ptText: "Modelo", enText: "Model")}:': + item['model'] ?? '', + '${localization.getVariableText(ptText: "Proprietário", enText: "Owner")}:': + item['personName'] ?? '', + if (containTag) + '${localization.getVariableText(ptText: "Tag", enText: "Tag")}:': + tag ?? '', + }; + } + + List> _generateStatusHashMapList( + Map item) { + final statusHashMap = widget.model.generateStatusColorMap(item, false); + return statusHashMap != null ? [statusHashMap] : []; + } + + Future _handleCardItemTap( + BuildContext context, + FreCardIcon? cardIcon, + Map item, + ) async { + try { + final dialogContent = widget.model.buildVehicleDetails( + icon: cardIcon, + item: item, + context: context, + model: widget.model, + ); + + await showDialog( + useSafeArea: true, + context: context, + builder: (context) => Dialog( + alignment: Alignment.center, + child: dialogContent, + ), + ).whenComplete(() { + safeSetState(() { + // _pagingController.refresh(); + }); + }); + } catch (e, s) { + DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed( + "proccessRequest.php", "", "Consulta de Veículos", e, s); + safeSetState(() { + // _hasData = false; + // _loading = false; + }); + } + } } mixin Remotable on State { final PagingController _pagingController = PagingController(firstPageKey: 1); - // late ScrollController _scrollController; double offset = 0.0; - List _wrap = []; - int _pageNumber = 1; - bool _hasData = true; - bool _loading = true; + // bool _hasData = true; + // bool _loading = true; int count = 0; - Future _fetch(dynamic pageKey) async { - if (!_hasData || !_loading) return; - print('hasHasData'); - // setState(() => _loading = true); + Future _fetch({ + required Future<(bool, dynamic)> Function() hasData, + required void Function(dynamic) onHas, + required void Function() onNotHas, + required void Function(Object, StackTrace) onError, + }) async { + // if (!_hasData || !_loading) return; try { - var newItems = - await PhpGroup.getVehiclesByProperty.call(pageKey.toString()); - final bool isLastPage = newItems.jsonBody == null || - newItems.jsonBody == [] || - newItems.jsonBody == ''; - - if (newItems.jsonBody == null) { - } else { - final List vehicles = - newItems.jsonBody['vehicles'] as List? ?? []; - _pagingController.nextPageKey = pageKey + 1; - - safeSetState(() => count = newItems.jsonBody['total_rows'] ?? 0); - if (vehicles.isNotEmpty) { - // setState(() { - // _hasData = true; - // _loading = false; - // _wrap.addAll(vehicles); - // }); - _pagingController.appendLastPage(vehicles); - - return; - } - _showNoMoreDataSnackBar(context); - setState(() { - _hasData = false; - _loading = false; - }); - print('hasEmpty: ${_wrap.length}'); - return; - } + final (bool, dynamic) data = await hasData(); + if (data.$1) + onHas(data.$2); + else + onNotHas(); } catch (e, s) { - DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Veículo", e, s); - setState(() { - _hasData = false; - _loading = false; - }); - print('hasError'); - return; + onError(e, s); } } @@ -188,142 +286,32 @@ mixin Remotable on State { showSnackbar(context, message, true); } - Widget _buildHeader(BuildContext context) { - double limitedBodyTextSize = LimitedFontSizeUtil.getBodyFontSize(context); - log('amountRegister: ${widget.model.amountRegister}'); - return Padding( - padding: const EdgeInsets.only(right: 30, top: 10), - child: Text( - (widget.model.amountRegister == '0' || - widget.model.amountRegister == null) - ? '' - : "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Veículos: ", enText: "Amount of Vehicles: ")}${widget.model.amountRegister}/$count", - textAlign: TextAlign.right, - style: TextStyle( - fontFamily: 'Nunito', - fontSize: limitedBodyTextSize, + Widget _buildNoDataFound(BuildContext context, String title) { + final headerFontSize = LimitedFontSizeUtil.getHeaderFontSize(context); + // final bodyFontSize = LimitedFontSizeUtil.getBodyFontSize(context); + return Expanded( + child: Center( + child: Text( + title, + style: TextStyle( + fontFamily: 'Nunito', + fontSize: headerFontSize, + ), ), ), ); } - Widget _generateItems(BuildContext context, int index, dynamic item) { - log('item: $item'); - - // return Placeholder(); - - // if (index == 0) return _buildHeader(context); - - final bool? isOwner = item['isOwnerVehicle']; - final IconData? iconData = - isOwner == true ? Symbols.garage : Symbols.directions_car; - final FreCardIcon? cardIcon = isOwner != null - ? FreCardIcon( - height: 50, - width: 100, - icon: Icon(iconData, size: 80, opticalSize: 10)) - : null; - - final String? tag = item['tag']; - final bool containTag = tag.isNotNullAndEmpty; - final Map labelsHashMap = - _generateLabelsHashMap(context, item, tag, containTag); - - final List> statusHashMapList = - _generateStatusHashMapList(item); - - Future onTapCardItemAction() async { - _handleCardItemTap(context, cardIcon, item); - } - - final statusLinkedHashMap = statusHashMapList - .map((map) => LinkedHashMap.from(map)) - .toList(); - final length = statusLinkedHashMap.expand((e) => [e.length]); - - return CardItemTemplateComponentWidget( - icon: cardIcon, - labelsHashMap: labelsHashMap, - statusHashMap: statusHashMapList, - onTapCardItemAction: onTapCardItemAction, - itemWidthFactor: length == 1 ? 0.25 : 0.50, + Widget _buildLoadingIndicator(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 15), + child: Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, + ), + ), + ), ); } - - Map _generateLabelsHashMap(BuildContext context, - Map uItem, String? tag, bool containTag) { - return { - '${FFLocalizations.of(context).getVariableText(ptText: "Placa", enText: "License Plate")}:': - uItem['licensePlate'] ?? '', - '${FFLocalizations.of(context).getVariableText(ptText: "Modelo", enText: "Model")}:': - uItem['model'] ?? '', - '${FFLocalizations.of(context).getVariableText(ptText: "Proprietário", enText: "Owner")}:': - uItem['personName'] ?? '', - if (containTag) - '${FFLocalizations.of(context).getVariableText(ptText: "Tag", enText: "Tag")}:': - tag ?? '', - }; - } - - List> _generateStatusHashMapList( - Map uItem) { - final statusHashMap = widget.model.generateStatusColorMap(uItem, false); - return statusHashMap != null ? [statusHashMap] : []; - } - - Future _handleCardItemTap(BuildContext context, FreCardIcon? cardIcon, - Map uItem) async { - try { - final dialogContent = widget.model.buildVehicleDetails( - icon: cardIcon, - item: uItem, - context: context, - model: widget.model, - ); - - await showDialog( - useSafeArea: true, - context: context, - builder: (context) => - Dialog(alignment: Alignment.center, child: dialogContent), - ).whenComplete(() { - safeSetState(() { - _pageNumber = 1; - _fetch(1); - }); - }); - } catch (e, s) { - DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Veículos", e, s); - safeSetState(() { - _hasData = false; - _loading = false; - }); - } - } - - void _initializeScrollController() { - // _scrollController = ScrollController(keepScrollOffset: true, initialScrollOffset: offset) - // ..addListener(() { - // print('ScrollController'); - // if(!_hasData) return; - // if - // // (_scrollController.position.pixels >= _scrollController.position.maxScrollExtent) - // (_scrollController.position.atEdge && _scrollController.position.pixels != 0) - // { - // print('ScrollController -> loadMore'); - // offset = _scrollController.offset; - // _loadMore(); - // } - // },); - } - - // void _loadMore() { - // if (_hasData) { - // _pageNumber+=1; - // _loading = true; - // _fetch(_pageNumber); - // } - // } } diff --git a/lib/pages/vehicles_on_the_property/vehicle_model.dart b/lib/pages/vehicles_on_the_property/vehicle_model.dart index 5bee0d41..39d24f0e 100644 --- a/lib/pages/vehicles_on_the_property/vehicle_model.dart +++ b/lib/pages/vehicles_on_the_property/vehicle_model.dart @@ -71,7 +71,8 @@ class VehicleModel extends FlutterFlowModel Future initAsync() async { amountRegister = await StorageHelper().get(LocalsStorageKey.vehicleAmountRegister.key); - autoApproval= await StorageHelper().get(LocalsStorageKey.vehicleAutoApproval.key); + autoApproval = + await StorageHelper().get(LocalsStorageKey.vehicleAutoApproval.key); } bool isFormValid(BuildContext context, GlobalKey formKey) { @@ -91,7 +92,6 @@ mixin class _BaseVehiclePage { ApiCallResponse? vehicleResponse; String? amountRegister = '0'; late final String? autoApproval; - VoidCallback? onUpdateVehicle; VoidCallback? onRegisterVehicle; @@ -240,10 +240,7 @@ mixin _VehicleUpdateScreenModel on _BaseVehiclePage { /// [_VehicleHistoryScreenModel] is a mixin that contains the business logic of the vehicle history page. mixin _VehicleHistoryScreenModel on _BaseVehiclePage { - - - Map? generateStatusColorMap(dynamic uItem, bool isDetail) { - + Map? generateStatusColorMap(dynamic uItem, bool isDetail) { if (autoApproval.toBoolean == true) return null; final theme = FlutterFlowTheme.of(context); final localization = FFLocalizations.of(context); @@ -299,7 +296,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { return {}; } - List generateActionButtons(dynamic item) { + List generateActionButtons(dynamic item) { final Color iconButtonColor = FlutterFlowTheme.of(context).primaryText; final FFButtonOptions buttonOptions = FFButtonOptions( height: 40, @@ -342,7 +339,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ptText: 'Você tem certeza que deseja cancelar essa solicitação?', enText: 'Are you sure you want to delete this request?', ), - () async => processCancelRequest(item['status'], item)); + () async => processCancelRequest(item['status'], item)); } final deleteText = FFLocalizations.of(context) @@ -359,7 +356,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ptText: 'Você tem certeza que deseja excluir esse veículo?', enText: 'Are you sure you want to delete this vehicle?', ), - () async => processDeleteRequest(item), + () async => processDeleteRequest(item), ); } @@ -420,7 +417,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { // ignore: unrelated_type_equality_checks if (value.jsonBody['error'] == true) { final String errorMsg = value.jsonBody['error_msg']; - return showSnackbar( + return showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( ptText: errorMsg, @@ -430,7 +427,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ); // ignore: unrelated_type_equality_checks } - return showSnackbar( + return showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Success deleting vehicle', @@ -440,7 +437,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ); }).catchError((err, stack) { context.pop(); - return showSnackbar( + return showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Error deleting vehicle', @@ -473,7 +470,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { if (value.jsonBody['error'] == true) { final String errorMsg = value.jsonBody['error_msg']; - return showSnackbar( + return showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( ptText: errorMsg, @@ -482,7 +479,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { true, ); } - return showSnackbar( + return showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Success canceling request', @@ -492,7 +489,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ); } catch (err) { context.pop(); - return showSnackbar( + return showSnackbarMessenger( context, FFLocalizations.of(context).getVariableText( enText: 'Error canceling request', @@ -503,7 +500,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { } } - Future processCancelDeleteRequest(dynamic item) async{ + Future processCancelDeleteRequest(dynamic item) async { return await PhpGroup.deleteVehicle.call( vehicleId: item['vehicleId'], licensePlate: item['licensePlate'], @@ -512,7 +509,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ); } - Future processCancelUpdateRequest(dynamic item) async { + Future processCancelUpdateRequest(dynamic item) async { return await PhpGroup.deleteVehicle.call( vehicleId: item['vehicleId'], licensePlate: item['licensePlate'], @@ -530,7 +527,7 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { ); } - Map generateLabelsHashMap(dynamic item) { + Map generateLabelsHashMap(dynamic item) { return { if (item['model'] != null && item['model'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Modelo", enText: "Model")}:': @@ -555,10 +552,10 @@ mixin _VehicleHistoryScreenModel on _BaseVehiclePage { required BuildContext context, required VehicleModel model, required FreCardIcon? icon, - }) { - final status = generateStatusColorMap(item, true); - final buttons = generateActionButtons(item); - final labels = generateLabelsHashMap(item); + }) { + final status = generateStatusColorMap(item, true); + final buttons = generateActionButtons(item); + final labels = generateLabelsHashMap(item); return DetailsComponentWidget( icon: icon, buttons: buttons, diff --git a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart index 174519fb..4a01ca63 100644 --- a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart +++ b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart @@ -1,6 +1,7 @@ import 'dart:collection'; import 'dart:developer'; +import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';