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(
vsync: this,
length: 4,
length: 3,
initialIndex: 1,
)..addListener(() => setState(() {}));
@ -169,7 +169,7 @@ Widget bodyMessage(
children: [
liberationDynamicListView(context, _model, 'P'),
liberationDynamicListView(context, _model, 'A'),
liberationDynamicListView(context, _model, 'A'),
liberationDynamicListView(context, _model, 'T'),
]
)),
].addToStart(const SizedBox(height: 0)),
@ -198,11 +198,16 @@ Widget liberationDynamicListView(
pageSize: '100',
pageNumber: '1',
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) {
// return SizedBox();
if (!snapshot.hasData) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: SizedBox(
width: 50.0,
@ -214,55 +219,27 @@ Widget liberationDynamicListView(
),
);
}
// final columnGetLiberationsResponse = snapshot.data!;
// final liberationHistory = PhpGroup.getLiberationsCall
// .rqList(
// columnGetLiberationsResponse.jsonBody,
// )
// ?.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;
if (snapshot.hasError == true || snapshot.data == null) {
log('Error: ${snapshot.error.toString()}');
// log('Error: ${snapshot.data!.jsonBody['mensagens']}');
return const Center(
child: Text('Erro ao carregar mensagens'),
);
}
return ListView.builder(
itemCount: snapshot.data!.jsonBody['total_rows'],
addAutomaticKeepAlives: false,
addRepaintBoundaries: true,
cacheExtent: 1000.0,
itemBuilder: (BuildContext context, int index) {
return messageHistoryItem(context, snapshot.data!.jsonBody['mensagens'][index]);
// final liberationHistoryItem = snapshot.data.jsonBody[index];
// return Padding(
// 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,
// ),
// ),
// );
return messageHistoryItem(
context,
snapshot.data!.jsonBody['mensagens'][index],
);
},
);
},
),
),
);
}
@ -291,7 +268,7 @@ Widget messageHistoryItem(
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()),