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': 'zok7lu4w', 'value': 'E'},
|
||||||
{'title': 'oonqk812', 'value': 'O'},
|
{'title': 'oonqk812', 'value': 'O'},
|
||||||
];
|
];
|
||||||
final List<Map<String, String>> accessTypeOptions = [
|
|
||||||
{'title': '580z80ct', 'value': '0'},
|
|
||||||
{'title': '1nbwqtzs', 'value': '1'},
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void setState(VoidCallback callback) {
|
void setState(VoidCallback callback) {
|
||||||
|
@ -187,7 +183,7 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
||||||
return Center(
|
return Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: screenWidth * 0.75,
|
width: screenWidth * 0.75,
|
||||||
height: screenHeight * 0.70,
|
height: screenHeight * 0.35,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
borderRadius: BorderRadius.circular(24.0),
|
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(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -307,10 +225,8 @@ class _OptModalWidgetState extends State<OptModalWidget> {
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildCheckboxListTile('personType', personTypeOptions,
|
_buildCheckboxListTile(
|
||||||
screenHeight * 0.025),
|
'personType', personTypeOptions, 14),
|
||||||
_buildCheckboxListTile('accessType', accessTypeOptions,
|
|
||||||
screenHeight * 0.025),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -132,7 +132,7 @@ class _CardItemTemplateComponentWidgetState
|
||||||
String value = labelsLinkedHashMap[key]!;
|
String value = labelsLinkedHashMap[key]!;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.fromLTRB(0, 5, 0, 3),
|
const EdgeInsets.fromLTRB(0, 2, 0, 5),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.fromLTRB(20, 0, 0, 0),
|
const EdgeInsets.fromLTRB(20, 0, 0, 0),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
@ -67,7 +68,8 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
late Future<void> _accessFuture;
|
late Future<void> _accessFuture;
|
||||||
List<dynamic> _accessWrap = [];
|
List<dynamic> _accessWrap = [];
|
||||||
|
|
||||||
_AcessHistoryPageWidgetState(Map<String, String> opt) : selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
_AcessHistoryPageWidgetState(Map<String, String> opt)
|
||||||
|
: selectedTypeSubject = BehaviorSubject.seeded(opt) {
|
||||||
selectedTypeSubject.listen((value) {});
|
selectedTypeSubject.listen((value) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +79,20 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
_model = createModel(context, () => AcessHistoryPageModel());
|
_model = createModel(context, () => AcessHistoryPageModel());
|
||||||
_accessFuture = fetchAccessHistoryService();
|
_accessFuture = fetchAccessHistoryService();
|
||||||
|
|
||||||
_scrollController = ScrollController()..addListener(() {
|
_scrollController = ScrollController()
|
||||||
if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) {
|
..addListener(() {
|
||||||
_loadMoreAccess();
|
if (_scrollController.position.atEdge &&
|
||||||
}
|
_scrollController.position.pixels != 0) {
|
||||||
});
|
_loadMoreAccess();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
Timer(const Duration(seconds: 3), () {
|
||||||
|
if (!_hasData && _pageNumber > 1) {
|
||||||
|
_showNoMoreDataSnackbar(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -102,7 +113,6 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
body: _body(context));
|
body: _body(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PreferredSizeWidget _appBar(BuildContext context, FlutterFlowTheme theme) {
|
PreferredSizeWidget _appBar(BuildContext context, FlutterFlowTheme theme) {
|
||||||
return AppBar(
|
return AppBar(
|
||||||
backgroundColor: theme.primaryBackground,
|
backgroundColor: theme.primaryBackground,
|
||||||
|
@ -111,9 +121,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
title: _title(context, theme),
|
title: _title(context, theme),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
elevation: 0.0,
|
elevation: 0.0,
|
||||||
actions: [
|
actions: [_filterButton(context)],
|
||||||
_filterButton(context)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +149,7 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
fontSize: 16.0,
|
fontSize: 16.0,
|
||||||
letterSpacing: 0.0,
|
letterSpacing: 0.0,
|
||||||
useGoogleFonts:
|
useGoogleFonts:
|
||||||
GoogleFonts.asMap().containsKey(theme.headlineMediumFamily),
|
GoogleFonts.asMap().containsKey(theme.headlineMediumFamily),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +163,8 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(Icons.filter_list),
|
icon: const Icon(Icons.filter_list),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final Map<String, String>? selectedFilter = await showModalBottomSheet<Map<String, String>>(
|
final Map<String, String>? selectedFilter =
|
||||||
|
await showModalBottomSheet<Map<String, String>>(
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -167,8 +176,12 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: OptModalWidget(
|
child: OptModalWidget(
|
||||||
defaultAccessType: selectedTypeSubject.value['accessType'] ?? '.*',
|
defaultAccessType:
|
||||||
defaultPersonType: selectedTypeSubject.value['personType'] ?? '.*',
|
selectedTypeSubject.value['accessType'] ??
|
||||||
|
'.*',
|
||||||
|
defaultPersonType:
|
||||||
|
selectedTypeSubject.value['personType'] ??
|
||||||
|
'.*',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -220,9 +233,15 @@ class _AcessHistoryPageWidgetState extends State<AcessHistoryPageWidget> {
|
||||||
final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? [];
|
final List<dynamic> accessHistory = response.jsonBody['acessos'] ?? [];
|
||||||
|
|
||||||
List<dynamic> filteredAccess = accessHistory.where((item) {
|
List<dynamic> filteredAccess = accessHistory.where((item) {
|
||||||
final personTypeMatches = _personType == '.*' || item["PES_TIPO"].toString() == _personType;
|
final personTypeMatches =
|
||||||
final accessTypeMatches = _accessType == '.*' || item["ACE_TIPO"].toString() == _accessType;
|
_personType == '.*' || item["PES_TIPO"].toString() == _personType;
|
||||||
final searchMatches = _search == '.*' || item["PES_NOME"].toString().toLowerCase().contains(_search.toLowerCase());
|
final accessTypeMatches =
|
||||||
|
_accessType == '.*' || item["ACE_TIPO"].toString() == _accessType;
|
||||||
|
final searchMatches = _search == '.*' ||
|
||||||
|
item["PES_NOME"]
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.contains(_search.toLowerCase());
|
||||||
return personTypeMatches && accessTypeMatches && searchMatches;
|
return personTypeMatches && accessTypeMatches && searchMatches;
|
||||||
}).toList();
|
}).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) {
|
Widget _body(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: <Widget>[
|
||||||
Expanded(child: _cardListViewOrganismWidget()),
|
if (_hasData == false && _pageNumber <= 1 && _loading == false)
|
||||||
if (_loading) Container(
|
Expanded(
|
||||||
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
child: Column(
|
||||||
color: FlutterFlowTheme.of(context).primary,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: Center(
|
mainAxisSize: MainAxisSize.max,
|
||||||
child: CircularProgressIndicator(
|
children: [
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
Center(
|
||||||
FlutterFlowTheme.of(context).info,
|
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>(
|
return FutureBuilder<void>(
|
||||||
future: _accessFuture,
|
future: _accessFuture,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting && _accessWrap.isEmpty) {
|
if (snapshot.connectionState == ConnectionState.waiting &&
|
||||||
|
_accessWrap.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 50.0,
|
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(
|
return CardItemTemplateComponentWidget(
|
||||||
imageHashMap: Map<String, String>.from({
|
imageHashMap: Map<String, String>.from({
|
||||||
'key': accessHistoryItem['PES_ID'] ?? '',
|
'key': accessHistoryItem['PES_ID'] ?? '',
|
||||||
|
|
Loading…
Reference in New Issue