From 40511a4b47d70b43e460f793a8ba460723217a14 Mon Sep 17 00:00:00 2001 From: Jonatas Antunes Messias Date: Mon, 1 Jul 2024 11:29:54 -0300 Subject: [PATCH] feat: Add OptModalWidget to AcessHistoryPageModel The OptModalWidget is added to the AcessHistoryPageModel to display a modal for selecting person types. This improves the user experience by allowing them to easily toggle between different person types. The togglePersonType function is called when a person type is selected, updating the pesType field in the model and triggering a state update. --- lib/flutter_flow/nav/nav.dart | 10 +-- .../acess_history_page_model.dart | 7 +- .../liberation_history_model.dart | 14 +-- .../liberation_history_widget.dart | 90 ++++++++++--------- 4 files changed, 60 insertions(+), 61 deletions(-) diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index da25e868..97cc4cca 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -140,11 +140,11 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( 'accessType': '.*', 'search': '.*', })), - // FFRoute( - // name: 'liberationHistory', - // path: '/liberationHistory', - // builder: (context, params) => const LiberationHistoryWidget(), - // ), + FFRoute( + name: 'liberationHistory', + path: '/liberationHistory', + builder: (context, params) => const LiberationHistoryWidget(), + ), FFRoute( name: 'signInPage', path: '/signInPage', diff --git a/lib/pages/acess_history_page/acess_history_page_model.dart b/lib/pages/acess_history_page/acess_history_page_model.dart index c3950298..a03ec14e 100644 --- a/lib/pages/acess_history_page/acess_history_page_model.dart +++ b/lib/pages/acess_history_page/acess_history_page_model.dart @@ -48,12 +48,7 @@ class AcessHistoryPageModel extends FlutterFlowModel { : FocusScope.of(context).unfocus(), child: Padding( padding: MediaQuery.viewInsetsOf(context), - child: OptModalWidget( - togglePersonType: (personType) async { - _model.pesType = personType; - setState(() {}); - }, - ), + child: const OptModalWidget(), ), ); }, diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index 3365ba3c..71f5efef 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -5,14 +5,14 @@ import '/flutter_flow/request_manager.dart'; import 'liberation_history_widget.dart' show LiberationHistoryWidget; import 'package:flutter/material.dart'; -// class LiberationHistoryModel extends FlutterFlowModel { -// /// State fields for stateful widgets in this page. +class LiberationHistoryModel extends FlutterFlowModel { + /// State fields for stateful widgets in this page. -// final unfocusNode = FocusNode(); -// // State field(s) for TextField widget. -// FocusNode? textFieldFocusNode; -// TextEditingController? textController; -// String? Function(BuildContext, String?)? textControllerValidator; + final unfocusNode = FocusNode(); + // State field(s) for TextField widget. + FocusNode? textFieldFocusNode; + TextEditingController? textController; + String? Function(BuildContext, String?)? textControllerValidator; /// Query cache managers for this widget. diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index be5d972d..f5435415 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -11,38 +11,38 @@ import 'package:provider/provider.dart'; import 'liberation_history_model.dart'; export 'liberation_history_model.dart'; -// class LiberationHistoryWidget extends StatefulWidget { -// const LiberationHistoryWidget({super.key}); +class LiberationHistoryWidget extends StatefulWidget { + const LiberationHistoryWidget({super.key}); -// @override -// State createState() => -// _LiberationHistoryWidgetState(); -// } + @override + State createState() => + _LiberationHistoryWidgetState(); +} -// class _LiberationHistoryWidgetState extends State { -// late LiberationHistoryModel _model; +class _LiberationHistoryWidgetState extends State { + late LiberationHistoryModel _model; -// final scaffoldKey = GlobalKey(); + final scaffoldKey = GlobalKey(); -// @override -// void initState() { -// super.initState(); -// _model = createModel(context, () => LiberationHistoryModel()); + @override + void initState() { + super.initState(); + _model = createModel(context, () => LiberationHistoryModel()); -// _model.textController ??= TextEditingController(); -// _model.textFieldFocusNode ??= FocusNode(); -// } + _model.textController ??= TextEditingController(); + _model.textFieldFocusNode ??= FocusNode(); + } -// @override -// void dispose() { -// _model.dispose(); + @override + void dispose() { + _model.dispose(); -// super.dispose(); -// } + super.dispose(); + } -// @override -// Widget build(BuildContext context) { -// context.watch(); + @override + Widget build(BuildContext context) { + context.watch(); return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus @@ -97,7 +97,8 @@ export 'liberation_history_model.dart'; ), alignment: const AlignmentDirectional(0.0, -1.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), + padding: + const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: SizedBox( width: 300.0, child: TextFormField( @@ -253,17 +254,16 @@ export 'liberation_history_model.dart'; MainAxisAlignment.spaceBetween, children: [ Padding( - padding: - const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 10.0, 0.0), + padding: const EdgeInsetsDirectional + .fromSTEB(0.0, 0.0, 10.0, 0.0), child: ClipRRect( borderRadius: BorderRadius.circular(100.0), child: CachedNetworkImage( - fadeInDuration: - const Duration(milliseconds: 500), - fadeOutDuration: - const Duration(milliseconds: 500), + fadeInDuration: const Duration( + milliseconds: 500), + fadeOutDuration: const Duration( + milliseconds: 500), imageUrl: valueOrDefault( 'https://freaccess.com.br/freaccess/getImage.php?&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField( liberationHistoryItem, @@ -324,7 +324,8 @@ export 'liberation_history_model.dart'; ), ] .addToStart( - const SizedBox(width: 10.0)) + const SizedBox( + width: 10.0)) .addToEnd(const SizedBox( width: 10.0)), ), @@ -396,10 +397,11 @@ export 'liberation_history_model.dart'; ), ), ] - .divide( - const SizedBox(width: 10.0)) - .addToStart(const SizedBox( - width: 10.0)), + .divide(const SizedBox( + width: 10.0)) + .addToStart( + const SizedBox( + width: 10.0)), ), Row( mainAxisSize: @@ -458,10 +460,11 @@ export 'liberation_history_model.dart'; ), ), ] - .divide( - const SizedBox(width: 10.0)) - .addToStart(const SizedBox( - width: 10.0)), + .divide(const SizedBox( + width: 10.0)) + .addToStart( + const SizedBox( + width: 10.0)), ), Align( alignment: @@ -471,7 +474,7 @@ export 'liberation_history_model.dart'; padding: const EdgeInsetsDirectional .fromSTEB(10.0, 0.0, - 0.0, 0.0), + 0.0, 0.0), child: Container( width: 200.0, height: 27.0, @@ -609,7 +612,8 @@ export 'liberation_history_model.dart'; ), ), ), - ].divide(const SizedBox(height: 3.0)), + ].divide( + const SizedBox(height: 3.0)), ), ), ),