Ajuste de responsividade, do modal e tratamento de erro

This commit is contained in:
Lucas 2024-08-09 11:25:25 -03:00
parent 4681e8a515
commit 5d6f4209d6
5 changed files with 320 additions and 453 deletions

View File

@ -1,3 +1,4 @@
import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
@ -7,7 +8,6 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/internationalization.dart';
class OptModalWidget extends StatefulWidget { class OptModalWidget extends StatefulWidget {
final String defaultPersonType; final String defaultPersonType;
final String defaultAccessType; final String defaultAccessType;
@ -65,7 +65,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
Map<String, String> filterResult = { Map<String, String> filterResult = {
'personType': '', 'personType': '',
'accessType': '', 'accessType': '',
'search': _model.textController?.text == '' 'search': _model.textController?.text == ''
? '.*' ? '.*'
: _model.textController!.text.toLowerCase(), : _model.textController!.text.toLowerCase(),
}; };
@ -89,7 +89,8 @@ class _OptModalWidgetState extends State<OptModalWidget> {
Navigator.pop(context, filterResult); Navigator.pop(context, filterResult);
} }
Widget _buildCheckboxListTile(String key, List<Map<String, String>> options) { Widget _buildCheckboxListTile(
String key, List<Map<String, String>> options, double fontsize) {
return Column( return Column(
children: [ children: [
Row( Row(
@ -97,14 +98,13 @@ class _OptModalWidgetState extends State<OptModalWidget> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Padding( Padding(
padding: padding: const EdgeInsetsDirectional.fromSTEB(0.0, 3.0, 0.0, 0.0),
const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0),
child: Text( child: Text(
FFLocalizations.of(context).getText('l7tw8b92'), FFLocalizations.of(context).getText('l7tw8b92'),
textAlign: TextAlign textAlign: TextAlign.left,
.left, // Adiciona esta linha para alinhar o texto à esquerda
style: FlutterFlowTheme.of(context).bodyMedium.override( style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
fontSize: fontsize,
letterSpacing: 0.0, letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey( useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily), FlutterFlowTheme.of(context).bodyMediumFamily),
@ -115,6 +115,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
], ],
), ),
ListView.builder( ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemCount: options.length, itemCount: options.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -125,6 +126,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
style: FlutterFlowTheme.of(context).bodyMedium.override( style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
letterSpacing: 0.0, letterSpacing: 0.0,
fontSize: fontsize,
useGoogleFonts: GoogleFonts.asMap().containsKey( useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily), FlutterFlowTheme.of(context).bodyMediumFamily),
color: FlutterFlowTheme.of(context).primaryText, color: FlutterFlowTheme.of(context).primaryText,
@ -148,9 +150,10 @@ class _OptModalWidgetState extends State<OptModalWidget> {
checkboxShape: RoundedRectangleBorder( checkboxShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
), ),
enableFeedback: true, enableFeedback: true,
side: BorderSide( side: BorderSide(
width: 10, width: 5,
color: FlutterFlowTheme.of(context).secondaryText, color: FlutterFlowTheme.of(context).secondaryText,
), ),
controlAffinity: controlAffinity:
@ -178,157 +181,153 @@ class _OptModalWidgetState extends State<OptModalWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( double screenWidth = MediaQuery.of(context).size.width;
child: Align( double screenHeight = MediaQuery.of(context).size.height;
alignment: const AlignmentDirectional(1.0, -1.0),
return Center(
child: Container(
width: screenWidth * 0.75,
height: screenHeight * 0.70,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).primaryBackground,
borderRadius: BorderRadius.circular(24.0),
),
child: Padding( child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 50.0, 50.0, 0.0), padding: const EdgeInsets.all(4.0),
child: Container( child: Column(
width: 300.0, children: [
height: 450.0, Row(
decoration: BoxDecoration( mainAxisSize: MainAxisSize.max,
color: FlutterFlowTheme.of(context).primaryBackground, mainAxisAlignment: MainAxisAlignment.start,
borderRadius: BorderRadius.circular(24.0),
),
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Column(
children: [ children: [
Row( Padding(
mainAxisSize: MainAxisSize.max, padding: const EdgeInsetsDirectional.fromSTEB(
mainAxisAlignment: MainAxisAlignment.start, 10.0, 10.0, 0.0, 10.0),
children: [ child: Text(
Padding( FFLocalizations.of(context)
padding: const EdgeInsetsDirectional.fromSTEB( .getText('yfj9pd6k'), // Filtros
10.0, 10.0, 0.0, 10.0), style:
child: Text( FlutterFlowTheme.of(context).headlineMedium.override(
FFLocalizations.of(context)
.getText('yfj9pd6k'), // Filtros
style: FlutterFlowTheme.of(context)
.headlineMedium
.override(
fontFamily: FlutterFlowTheme.of(context) fontFamily: FlutterFlowTheme.of(context)
.headlineMediumFamily, .headlineMediumFamily,
color: FlutterFlowTheme.of(context).primaryText, color: FlutterFlowTheme.of(context).primaryText,
fontSize: 16.0, fontSize: 18.0,
letterSpacing: 0.0, letterSpacing: 0.0,
fontWeight: FontWeight.bold,
useGoogleFonts: GoogleFonts.asMap().containsKey( useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context) FlutterFlowTheme.of(context)
.headlineMediumFamily), .headlineMediumFamily),
), ),
),
),
],
),
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),
),
),
SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_buildCheckboxListTile(
'personType', personTypeOptions),
_buildCheckboxListTile(
'accessType', accessTypeOptions),
],
),
),
),
ElevatedButton(
onPressed: _applyFilter,
child:
Text(FFLocalizations.of(context).getText('88kshkph')),
style: ElevatedButton.styleFrom(
foregroundColor: FlutterFlowTheme.of(context).info,
backgroundColor: FlutterFlowTheme.of(context).primary,
), ),
), ),
], ],
), ),
), 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(
padding: const EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_buildCheckboxListTile('personType', personTypeOptions,
screenHeight * 0.025),
_buildCheckboxListTile('accessType', accessTypeOptions,
screenHeight * 0.025),
],
),
),
),
),
ElevatedButton(
onPressed: _applyFilter,
style: ElevatedButton.styleFrom(
foregroundColor: FlutterFlowTheme.of(context).info,
backgroundColor: FlutterFlowTheme.of(context).primary,
),
child: Text(FFLocalizations.of(context).getText('88kshkph')),
),
],
), ),
), ),
), ),
); );
} }
} }

View File

@ -1,6 +1,8 @@
import 'dart:collection'; import 'dart:collection';
import 'dart:developer'; import 'dart:developer';
import 'package:auto_size_text/auto_size_text.dart';
import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_util.dart';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
@ -12,8 +14,6 @@ export 'card_item_template_component_model.dart';
/// ///
class CardItemTemplateComponentWidget extends StatefulWidget { class CardItemTemplateComponentWidget extends StatefulWidget {
const CardItemTemplateComponentWidget({ const CardItemTemplateComponentWidget({
super.key, super.key,
@ -25,7 +25,7 @@ class CardItemTemplateComponentWidget extends StatefulWidget {
final Map<String, String>? labelsHashMap; final Map<String, String>? labelsHashMap;
final List<Map<String, Color>?> statusHashMap; final List<Map<String, Color>?> statusHashMap;
final Map<String, String> imageHashMap; final Map<String, String> imageHashMap;
final Future Function()? onTapCardItemAction; final Future Function()? onTapCardItemAction;
@override @override
@ -40,7 +40,9 @@ class _CardItemTemplateComponentWidgetState
LinkedHashMap.from(widget.labelsHashMap ?? {}); LinkedHashMap.from(widget.labelsHashMap ?? {});
List<LinkedHashMap<String, Color>> get statusLinkedHashMap => List<LinkedHashMap<String, Color>> get statusLinkedHashMap =>
widget.statusHashMap.map((map) => LinkedHashMap<String, Color>.from(map ?? {})).toList(); widget.statusHashMap
.map((map) => LinkedHashMap<String, Color>.from(map ?? {}))
.toList();
@override @override
void setState(VoidCallback callback) { void setState(VoidCallback callback) {
@ -71,12 +73,18 @@ class _CardItemTemplateComponentWidgetState
} }
} }
String truncate(int cutoff, String mytext) {
return (mytext.length <= cutoff)
? mytext
: '${mytext.substring(0, cutoff)}...';
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
context.watch<FFAppState>(); context.watch<FFAppState>();
return InkWell( return InkWell(
splashColor: Colors.transparent, splashColor: Colors.transparent,
focusColor: Colors.transparent, focusColor: Colors.transparent,
@ -123,7 +131,8 @@ class _CardItemTemplateComponentWidgetState
labelsLinkedHashMap.keys.elementAt(index); labelsLinkedHashMap.keys.elementAt(index);
String value = labelsLinkedHashMap[key]!; String value = labelsLinkedHashMap[key]!;
return Padding( return Padding(
padding: const EdgeInsets.only(bottom: 5.0), padding:
const EdgeInsets.fromLTRB(0, 5, 0, 3),
child: Padding( child: Padding(
padding: padding:
const EdgeInsets.fromLTRB(20, 0, 0, 0), const EdgeInsets.fromLTRB(20, 0, 0, 0),
@ -140,7 +149,7 @@ class _CardItemTemplateComponentWidgetState
fontFamily: fontFamily:
FlutterFlowTheme.of(context) FlutterFlowTheme.of(context)
.bodyMediumFamily, .bodyMediumFamily,
fontSize: 12.5, fontSize: screenWidth * 0.025,
letterSpacing: 0.0, letterSpacing: 0.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
useGoogleFonts: GoogleFonts useGoogleFonts: GoogleFonts
@ -151,21 +160,23 @@ class _CardItemTemplateComponentWidgetState
.bodyMediumFamily), .bodyMediumFamily),
color: color:
FlutterFlowTheme.of(context) FlutterFlowTheme.of(context)
.primaryText, .customColor6,
), ),
), ),
const SizedBox( const SizedBox(
width: width:
5.0), // Espaçamento entre o label e o valor 5.0), // Espaçamento entre o label e o valor
Text( Text(
value, truncate(20, value),
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: FlutterFlowTheme.of(context) style: FlutterFlowTheme.of(context)
.bodyMedium .bodyMedium
.override( .override(
fontFamily: fontFamily:
FlutterFlowTheme.of(context) FlutterFlowTheme.of(context)
.bodyMediumFamily, .bodyMediumFamily,
fontSize: 12.5, fontSize: screenWidth * 0.030,
letterSpacing: 0.0, letterSpacing: 0.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
useGoogleFonts: GoogleFonts useGoogleFonts: GoogleFonts
@ -183,40 +194,52 @@ class _CardItemTemplateComponentWidgetState
}, },
), ),
), ),
Row( Padding(
mainAxisAlignment: MainAxisAlignment.center, padding: const EdgeInsets.fromLTRB(20, 0, 0, 0),
mainAxisSize: MainAxisSize.max, child: Row(
children: statusLinkedHashMap.expand((linkedHashMap) { mainAxisAlignment: MainAxisAlignment.start,
return linkedHashMap.entries.map((MapEntry<String, Color> item) { mainAxisSize: MainAxisSize.max,
return Container( children:
child: Row( statusLinkedHashMap.expand((linkedHashMap) {
mainAxisAlignment: MainAxisAlignment.spaceBetween, return linkedHashMap.entries
children: [ .map((MapEntry<String, Color> item) {
Padding( return Container(
padding: const EdgeInsets.symmetric(horizontal: 1.0, vertical: 3.0), child: Row(
child: Container( mainAxisAlignment:
width: 100.0, MainAxisAlignment.spaceBetween,
height: 27.0, children: [
decoration: BoxDecoration( Padding(
color: item.value, // Usa a cor do item atual padding: const EdgeInsets.symmetric(
borderRadius: BorderRadius.circular(5.0), horizontal: 1.0, vertical: 3.0),
), child: Container(
child: Align( width: screenWidth * 0.20,
alignment: Alignment.center, height: 27.0,
child: Text( decoration: BoxDecoration(
item.key, // Usa a chave do item atual como texto color: item
style: TextStyle( .value, // Usa a cor do item atual
color: FlutterFlowTheme.of(context).info, // Ajuste conforme necessário borderRadius:
BorderRadius.circular(5.0),
),
child: Align(
alignment: Alignment.center,
child: Text(
item.key, // Usa a chave do item atual como texto
style: TextStyle(
fontSize: screenWidth * 0.03,
color: FlutterFlowTheme.of(
context)
.info, // Ajuste conforme necessário
),
), ),
), ),
), ),
), ),
), ],
], ),
), );
); }).toList();
}).toList(); }).toList(),
}).toList(), ),
), ),
]), ]),
), ),
@ -245,4 +268,4 @@ class _CardItemTemplateComponentWidgetState
), ),
); );
} }
} }

View File

@ -518,8 +518,8 @@ final kTranslationsMap = <Map<String, Map<String, String>>>[
// optModal // optModal
{ {
'0enrtljz': { '0enrtljz': {
'pt': 'Pesquise aqui.....', 'pt': 'Pesquise aqui...',
'en': 'Search here.....', 'en': 'Search here...',
}, },
'l7tw8b92': { 'l7tw8b92': {
'pt': 'Tipo de Pessoa', 'pt': 'Tipo de Pessoa',

View File

@ -1,4 +1,3 @@
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:hub/app_state.dart'; import 'package:hub/app_state.dart';
@ -141,4 +140,4 @@ class _MyAppState extends State<MyApp> {
routerConfig: _router, routerConfig: _router,
); );
} }
} }

View File

@ -19,9 +19,6 @@ import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/pages/acess_history_page/acess_history_page_model.dart'; import 'package:hub/pages/acess_history_page/acess_history_page_model.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
@immutable @immutable
class AcessHistoryPageWidget extends StatefulWidget { class AcessHistoryPageWidget extends StatefulWidget {
late Map<String, String> opt = { late Map<String, String> opt = {
@ -43,8 +40,8 @@ class AccessHistoryItemWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return const Padding(
padding: const EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: Column(), child: Column(),
); );
} }
@ -66,6 +63,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_model = createModel(context, () => AcessHistoryPageModel()); _model = createModel(context, () => AcessHistoryPageModel());
log("initState called in _AcessHistoryPageWidgetState"); log("initState called in _AcessHistoryPageWidgetState");
} }
@ -138,28 +136,44 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
IconButton( Padding(
icon: const Icon(Icons.filter_list), padding: const EdgeInsets.fromLTRB(0, 0, 10, 0),
padding: EdgeInsets.fromLTRB(0, 0, 10, 0), child: IconButton(
onPressed: () async { icon: const Icon(Icons.filter_list),
final Map<String, String>? selectedFilter = onPressed: () async {
await showModalBottomSheet<Map<String, String>>( final Map<String, String>? selectedFilter =
isScrollControlled: true, await showModalBottomSheet<Map<String, String>>(
backgroundColor: Colors.transparent, isScrollControlled: true,
context: context, backgroundColor: Colors.transparent,
builder: (context) => OptModalWidget( context: context,
defaultAccessType: builder: (context) {
selectedTypeSubject.value['accessType'] ?? '.*', return GestureDetector(
defaultPersonType: onTap: () {
selectedTypeSubject.value['personType'] ?? '.*', Navigator.of(context).pop();
), },
); child: Container(
color: Colors.transparent,
child: GestureDetector(
onTap: () {},
child: OptModalWidget(
defaultAccessType:
selectedTypeSubject.value['accessType'] ??
'.*',
defaultPersonType:
selectedTypeSubject.value['personType'] ??
'.*',
),
),
),
);
});
if (selectedFilter != null) { if (selectedFilter != null) {
log('Selected Filter: $selectedFilter'); log('Selected Filter: $selectedFilter');
_updateAccessHistoryAction(selectedFilter); _updateAccessHistoryAction(selectedFilter);
} }
}, },
),
), ),
], ],
); );
@ -227,20 +241,22 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
} }
Widget _accessHistoryListOrganismWidget(BuildContext context) { Widget _accessHistoryListOrganismWidget(BuildContext context) {
return SingleChildScrollView( return Center(
child: Column( child: SingleChildScrollView(
children: [ child: Column(
StreamBuilder<Map<String, String>>( children: [
stream: selectedTypeSubject.stream, StreamBuilder<Map<String, String>>(
builder: (context, snapshot) { stream: selectedTypeSubject.stream,
if (!snapshot.hasData) { builder: (context, snapshot) {
return Center(child: CircularProgressIndicator()); if (!snapshot.hasData) {
} return Center(child: CircularProgressIndicator());
final selected = snapshot.data!; }
return _cardListViewOrganismWidget(selected); final selected = snapshot.data!;
}, return _cardListViewOrganismWidget(selected);
), },
], ),
],
),
), ),
); );
} }
@ -253,8 +269,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
log('Response: ${response.jsonBody}'); log('Response: ${response.jsonBody}');
final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? []; final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? [];
log('Access History Before Filtering: $accessHistory'); log('Access History Before Filtering: $accessHistory');
log( log('Filtering for: Person Type - ${select['personType']}, Access Type - ${select['accessType']}, Search - ${select['search']}');
'Filtering for: Person Type - ${select['personType']}, Access Type - ${select['accessType']}, Search - ${select['search']}');
return accessHistory.where((item) { return accessHistory.where((item) {
final personTypeMatches = select['personType'] == '.*' || final personTypeMatches = select['personType'] == '.*' ||
@ -272,8 +287,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
} }
Widget _cardListViewOrganismWidget(Map<String, String> selected) { Widget _cardListViewOrganismWidget(Map<String, String> selected) {
log( log('Selected types in Card: ${selected['personType']}, ${selected['accessType']}');
'Selected types in Card: ${selected['personType']}, ${selected['accessType']}');
log('_buildAccessHistoryList called'); log('_buildAccessHistoryList called');
return FutureBuilder<List<dynamic>>( return FutureBuilder<List<dynamic>>(
future: fetchCardListViewService(selected), future: fetchCardListViewService(selected),
@ -290,8 +304,18 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
), ),
), ),
); );
} else if (snapshot.hasData && snapshot.data!.isEmpty) {
return Center(
child: Text(FFLocalizations.of(context).getVariableText(
ptText: "Nenhum histórico encontrado!",
enText: "No history found!")),
);
} else if (snapshot.hasError) { } else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}'); return Center(
child: Text(FFLocalizations.of(context).getVariableText(
ptText: "Falha ao efetuar operação!",
enText: "Failed to perform operation!")),
);
} else { } else {
final accessHistory = snapshot.data!; final accessHistory = snapshot.data!;
log('Access History: $accessHistory'); log('Access History: $accessHistory');
@ -301,8 +325,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
itemCount: accessHistory.length, itemCount: accessHistory.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final accessHistoryItem = accessHistory[index]; final accessHistoryItem = accessHistory[index];
log( log('Access History Item: ${accessHistoryItem['PES_TIPO']}');
'Access History Item: ${accessHistoryItem['PES_TIPO']}');
return _accessHistoryCardMoleculeWidget( return _accessHistoryCardMoleculeWidget(
context, accessHistoryItem); context, accessHistoryItem);
}, },
@ -314,7 +337,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
Widget _accessHistoryCardMoleculeWidget( Widget _accessHistoryCardMoleculeWidget(
BuildContext context, dynamic accessHistoryItem) { BuildContext context, dynamic accessHistoryItem) {
log('Access History Item: $accessHistoryItem'); log('Access History Item: $accessHistoryItem');
return CardItemTemplateComponentWidget( return CardItemTemplateComponentWidget(
imageHashMap: Map<String, String>.from({ imageHashMap: Map<String, String>.from({
'key': accessHistoryItem['PES_ID'] ?? '', 'key': accessHistoryItem['PES_ID'] ?? '',
@ -327,230 +350,53 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
}), }),
statusHashMap: [ statusHashMap: [
accessHistoryItem['PES_TIPO'] == 'O' accessHistoryItem['PES_TIPO'] == 'O'
? Map<String, Color>.from({ ? Map<String, Color>.from({
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Morador', ptText: 'Morador',
enText: 'Resident', enText: 'Resident',
): FlutterFlowTheme.of(context).alternate2, ): FlutterFlowTheme.of(context).alternate2,
}) })
: accessHistoryItem['PES_TIPO'] == 'E' : accessHistoryItem['PES_TIPO'] == 'E'
? Map<String, Color>.from({ ? Map<String, Color>.from({
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Visitante', ptText: 'Visitante',
enText: 'Visitor', enText: 'Visitor',
): FlutterFlowTheme.of(context).alternate2, ): FlutterFlowTheme.of(context).alternate2,
}) })
: Map<String, Color>.from({ : Map<String, Color>.from({
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Desconhecido', ptText: 'Desconhecido',
enText: 'Unknown', enText: 'Unknown',
): FlutterFlowTheme.of(context).alternate2, ): FlutterFlowTheme.of(context).alternate2,
}), }),
accessHistoryItem['ACE_TIPO'] == '0' accessHistoryItem['ACE_TIPO'] == '0'
? Map<String, Color>.from({ ? Map<String, Color>.from({
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Entrada', ptText: 'Entrada',
enText: 'Entrance', enText: 'Entrance',
): FlutterFlowTheme.of(context).success, ): FlutterFlowTheme.of(context).success,
}) })
: accessHistoryItem['ACE_TIPO'] == '1' : accessHistoryItem['ACE_TIPO'] == '1'
? Map<String, Color>.from({ ? Map<String, Color>.from({
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Saída', ptText: 'Saída',
enText: 'Exit', enText: 'Exit',
): FlutterFlowTheme.of(context).error, ): FlutterFlowTheme.of(context).error,
}) })
: Map<String, Color>.from({ : Map<String, Color>.from({
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Desconhecido', ptText: 'Desconhecido',
enText: 'Unknown', enText: 'Unknown',
): FlutterFlowTheme.of(context).warning, ): FlutterFlowTheme.of(context).warning,
}) })
], ],
onTapCardItemAction: () async {}); onTapCardItemAction: () async {});
} }
} }
Widget _cardHeaderAtomWidget(BuildContext context, String urlImagem,
String tipoPessoa, Color corFundoTipo, accessHistoryItem) {
return Row(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(100.0),
child: Image.network(
urlImagem,
width: 60.0,
height: 60.0,
fit: BoxFit.cover,
),
),
),
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
getJsonField(
accessHistoryItem,
r'''$.PES_NOME''',
).toString(),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily),
),
),
Container(
width: 100.0,
height: 25.0,
decoration: BoxDecoration(
color: (() {
// Extrai o valor de PES_TIPO, converte para String, remove espaços em branco e aspas
final pesTipo =
jsonToStr(getJsonField(
accessHistoryItem,
r'''$.PES_TIPO''',
))
.trim()
.replaceAll('"', ''); // Remove aspas
// Debug: Imprime o valor de PES_TIPO ajustado
log('PES_TIPO FOR COLORING: $pesTipo');
// Retorna a cor baseada na condição ajustada
return pesTipo == 'E'
? FlutterFlowTheme.of(context).warning
: FlutterFlowTheme.of(context).primary;
})(),
borderRadius: BorderRadius.circular(24.0),
),
child: Align(
alignment: const AlignmentDirectional(0.0, 0.0),
child: Text(
getJsonField(
accessHistoryItem,
r'''$.PES_TIPO''',
).toString() ==
'E'
? FFLocalizations.of(context).getText(
'zok7lu4w',
)
: FFLocalizations.of(context).getText(
'oonqk812',
),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
color: FlutterFlowTheme.of(context).info,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily),
),
),
),
),
],
),
]
.divide(const SizedBox(width: 20.0))
.addToStart(const SizedBox(width: 5.0))
.addToEnd(const SizedBox(width: 5.0)),
);
}
Widget _cardDetailsMoleculeWidget(
BuildContext context, dynamic accessHistoryItem) {
return Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
FFLocalizations.of(context).getText(
'2odgr6hg',
),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
fontSize: 12.5,
letterSpacing: 0.0,
fontWeight: FontWeight.bold,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily),
),
),
Text(
getJsonField(
accessHistoryItem,
r'''$.ACE_DATAHORA''',
).toString(),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
fontSize: 12.5,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily),
),
),
].addToStart(const SizedBox(width: 10.0)),
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
FFLocalizations.of(context).getText(
'zrde3fke',
),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
fontSize: 12.5,
letterSpacing: 0.0,
fontWeight: FontWeight.bold,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily),
),
),
Text(
getJsonField(
accessHistoryItem,
r'''$.ACI_DESCRICAO''',
).toString(),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily:
FlutterFlowTheme.of(context).bodyMediumFamily,
fontSize: 12.5,
letterSpacing: 0.0,
useGoogleFonts: GoogleFonts.asMap().containsKey(
FlutterFlowTheme.of(context).bodyMediumFamily),
),
),
].addToStart(const SizedBox(width: 10.0)),
),
].divide(const SizedBox(height: 3.0)),
),
),
]
.addToStart(const SizedBox(width: 5.0))
.addToEnd(const SizedBox(width: 5.0)),
);
}
String imageUrlAtomWidget(String document, String type) { String imageUrlAtomWidget(String document, String type) {
return valueOrDefault<String>( return valueOrDefault<String>(
"https://freaccess.com.br/freaccess/getImage.php?&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=$document&tipo=$type", "https://freaccess.com.br/freaccess/getImage.php?&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=$document&tipo=$type",
"https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg", "https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg",
); );
} }