fix(ui): fix MessageListView header and footer while reverse: false

This commit is contained in:
Salvatore Giordano
2021-09-20 15:51:47 +02:00
parent 6f677de528
commit 59ded0e033
@@ -494,14 +494,18 @@ class _MessageListViewState extends State<MessageListView> {
return _buildThreadSeparator(); return _buildThreadSeparator();
} }
if (i == itemCount - 3) { if (i == itemCount - 3) {
if (widget.headerBuilder == null) { if (widget.reverse
? widget.headerBuilder == null
: widget.footerBuilder == null) {
if (_isThreadConversation) return const Offstage(); if (_isThreadConversation) return const Offstage();
return const SizedBox(height: 52); return const SizedBox(height: 52);
} }
return const SizedBox(height: 8); return const SizedBox(height: 8);
} }
if (i == 0) { if (i == 0) {
if (widget.footerBuilder == null) { if (widget.reverse
? widget.footerBuilder == null
: widget.headerBuilder == null) {
return const SizedBox(height: 30); return const SizedBox(height: 30);
} }
return const SizedBox(height: 8); return const SizedBox(height: 8);
@@ -560,8 +564,13 @@ class _MessageListViewState extends State<MessageListView> {
} }
if (i == itemCount - 2) { if (i == itemCount - 2) {
return widget.headerBuilder?.call(context) ?? if (widget.reverse) {
const Offstage(); return widget.headerBuilder?.call(context) ??
const Offstage();
} else {
return widget.footerBuilder?.call(context) ??
const Offstage();
}
} }
if (i == itemCount - 3) { if (i == itemCount - 3) {
@@ -579,8 +588,13 @@ class _MessageListViewState extends State<MessageListView> {
} }
if (i == 0) { if (i == 0) {
return widget.footerBuilder?.call(context) ?? if (widget.reverse) {
const Offstage(); return widget.footerBuilder?.call(context) ??
const Offstage();
} else {
return widget.headerBuilder?.call(context) ??
const Offstage();
}
} }
const bottomMessageIndex = 2; // 1 -> loader // 0 -> footer const bottomMessageIndex = 2; // 1 -> loader // 0 -> footer
@@ -1199,12 +1213,10 @@ class _MessageListViewState extends State<MessageListView> {
initialAlignment = _initialAlignment; initialAlignment = _initialAlignment;
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
if (_scrollController?.isAttached == true) { _scrollController?.jumpTo(
_scrollController?.jumpTo( index: initialIndex,
index: initialIndex, alignment: initialAlignment,
alignment: initialAlignment, );
);
}
}); });
_messageNewListener = _messageNewListener =