Adicionado tratamento de erro, corrigido modal, corrigido erro de espaçamento do card e adicionado Snackbar.
This commit is contained in:
parent
b678ed5142
commit
4d45de2890
|
@ -30,10 +30,6 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
|||
{'title': 'zok7lu4w', 'value': 'E'},
|
||||
{'title': 'oonqk812', 'value': 'O'},
|
||||
];
|
||||
final List<Map<String, String>> accessTypeOptions = [
|
||||
{'title': '580z80ct', 'value': '0'},
|
||||
{'title': '1nbwqtzs', 'value': '1'},
|
||||
];
|
||||
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
|
@ -187,7 +183,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
|||
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<OptModalWidget> {
|
|||
),
|
||||
],
|
||||
),
|
||||
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<OptModalWidget> {
|
|||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildCheckboxListTile('personType', personTypeOptions,
|
||||
screenHeight * 0.025),
|
||||
_buildCheckboxListTile('accessType', accessTypeOptions,
|
||||
screenHeight * 0.025),
|
||||
_buildCheckboxListTile(
|
||||
'personType', personTypeOptions, 14),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
@ -67,7 +68,8 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
|||
late Future<void> _accessFuture;
|
||||
List<dynamic> _accessWrap = [];
|
||||
|
||||
_AcessHistoryPageWidgetState(Map<String, String> opt) : selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
||||
_AcessHistoryPageWidgetState(Map<String, String> opt)
|
||||
: selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
||||
selectedTypeSubject.listen((value) {});
|
||||
}
|
||||
|
||||
|
@ -77,11 +79,20 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
|||
_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<AcessHistoryPageWidget> {
|
|||
body: _body(context));
|
||||
}
|
||||
|
||||
|
||||
PreferredSizeWidget _appBar(BuildContext context, FlutterFlowTheme theme) {
|
||||
return AppBar(
|
||||
backgroundColor: theme.primaryBackground,
|
||||
|
@ -111,9 +121,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
|||
title: _title(context, theme),
|
||||
centerTitle: true,
|
||||
elevation: 0.0,
|
||||
actions: [
|
||||
_filterButton(context)
|
||||
],
|
||||
actions: [_filterButton(context)],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -141,7 +149,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
|||
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<AcessHistoryPageWidget> {
|
|||
child: IconButton(
|
||||
icon: const Icon(Icons.filter_list),
|
||||
onPressed: () async {
|
||||
final Map<String, String>? selectedFilter = await showModalBottomSheet<Map<String, String>>(
|
||||
final Map<String, String>? selectedFilter =
|
||||
await showModalBottomSheet<Map<String, String>>(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
context: context,
|
||||
|
@ -167,8 +176,12 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
|||
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<AcessHistoryPageWidget> {
|
|||
final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? [];
|
||||
|
||||
List<dynamic> 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<AcessHistoryPageWidget> {
|
|||
}
|
||||
}
|
||||
|
||||
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<Color>(
|
||||
FlutterFlowTheme.of(context).info,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
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<Color>(
|
||||
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<AcessHistoryPageWidget> {
|
|||
return FutureBuilder<void>(
|
||||
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<AcessHistoryPageWidget> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _accessHistoryCardMoleculeWidget(BuildContext context, dynamic accessHistoryItem) {
|
||||
|
||||
Widget _accessHistoryCardMoleculeWidget(
|
||||
BuildContext context, dynamic accessHistoryItem) {
|
||||
return CardItemTemplateComponentWidget(
|
||||
imageHashMap: Map<String, String>.from({
|
||||
'key': accessHistoryItem['PES_ID'] ?? '',
|
||||
|
|
Loading…
Reference in New Issue