chore: Update tab controller length in message widget

This commit is contained in:
jantunesmesias 2024-07-25 10:03:24 -03:00
parent f7e85cea0b
commit 8446569042
1 changed files with 24 additions and 47 deletions

View File

@ -42,7 +42,7 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget> wit
_model.tabBarController = TabController( _model.tabBarController = TabController(
vsync: this, vsync: this,
length: 4, length: 3,
initialIndex: 1, initialIndex: 1,
)..addListener(() => setState(() {})); )..addListener(() => setState(() {}));
@ -169,7 +169,7 @@ Widget bodyMessage(
children: [ children: [
liberationDynamicListView(context, _model, 'P'), liberationDynamicListView(context, _model, 'P'),
liberationDynamicListView(context, _model, 'A'), liberationDynamicListView(context, _model, 'A'),
liberationDynamicListView(context, _model, 'A'), liberationDynamicListView(context, _model, 'T'),
] ]
)), )),
].addToStart(const SizedBox(height: 0)), ].addToStart(const SizedBox(height: 0)),
@ -198,11 +198,16 @@ Widget liberationDynamicListView(
pageSize: '100', pageSize: '100',
pageNumber: '1', pageNumber: '1',
tipoDestino: DestIndex, tipoDestino: DestIndex,
), ).catchError((error) {
log('Error: ${error.toString()}');
return Future.delayed(Duration(seconds: 1), () {
return Center(
child: Text('Erro ao carregar mensagens'),
);
});
}),
builder: (context, snapshot) { builder: (context, snapshot) {
// return SizedBox(); if (snapshot.connectionState == ConnectionState.waiting) {
if (!snapshot.hasData) {
return Center( return Center(
child: SizedBox( child: SizedBox(
width: 50.0, width: 50.0,
@ -214,55 +219,27 @@ Widget liberationDynamicListView(
), ),
); );
} }
// final columnGetLiberationsResponse = snapshot.data!; if (snapshot.hasError == true || snapshot.data == null) {
// final liberationHistory = PhpGroup.getLiberationsCall log('Error: ${snapshot.error.toString()}');
// .rqList( // log('Error: ${snapshot.data!.jsonBody['mensagens']}');
// columnGetLiberationsResponse.jsonBody, return const Center(
// ) child: Text('Erro ao carregar mensagens'),
// ?.toList() ?? );
// []; }
// final filteredLiberationHistory = _model.textController.text.isNotEmpty
// ? liberationHistory
// .where((item) => functions
// .jsonToStr(getJsonField(
// item,
// r'''$.VTE_NOME''',
// ))
// .toLowerCase()
// .contains(
// _model.textController.text.toLowerCase(),
// ))
// .toList()
// : liberationHistory;
return ListView.builder( return ListView.builder(
itemCount: snapshot.data!.jsonBody['total_rows'], itemCount: snapshot.data!.jsonBody['total_rows'],
addAutomaticKeepAlives: false, addAutomaticKeepAlives: false,
addRepaintBoundaries: true, addRepaintBoundaries: true,
cacheExtent: 1000.0, cacheExtent: 1000.0,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return messageHistoryItem(context, snapshot.data!.jsonBody['mensagens'][index]); return messageHistoryItem(
// final liberationHistoryItem = snapshot.data.jsonBody[index]; context,
// return Padding( snapshot.data!.jsonBody['mensagens'][index],
// padding: EdgeInsets.only( );
// top: index == 0
// ? MediaQuery.of(context).size.height * 0.075
// : 8.0,
// left: 8.0,
// right: 8.0,
// bottom: 8.0,
// ),
// child: Align(
// alignment: AlignmentDirectional(0.0, 0.0),
// child: messageHistoryItem(
// context,
// liberationHistoryItem,
// ),
// ),
// );
}, },
); );
}, },
), ),
); );
} }
@ -291,7 +268,7 @@ Widget messageHistoryItem(
color: FlutterFlowTheme.of(context).primary, color: FlutterFlowTheme.of(context).primary,
),), ),),
), ),
Icon(jsonBody['MSG_ORIGEM'] == '20'? Icons.person : Icons.group), Icon(jsonBody['MSG_DESTINO_TP'] == 'T'? Icons.group : Icons.person),
], ],
), ),
Text(jsonBody['MSG_TEXTO'].toString()), Text(jsonBody['MSG_TEXTO'].toString()),