mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +00:00
Fix issue with posts list
This commit is contained in:
parent
e3130c9e4b
commit
27a56ae533
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:comunic/helpers/events_helper.dart';
|
import 'package:comunic/helpers/events_helper.dart';
|
||||||
import 'package:comunic/helpers/groups_helper.dart';
|
import 'package:comunic/helpers/groups_helper.dart';
|
||||||
import 'package:comunic/helpers/posts_helper.dart';
|
import 'package:comunic/helpers/posts_helper.dart';
|
||||||
@ -192,7 +194,9 @@ class PostsListWidgetState extends SafeState<PostsListWidget> {
|
|||||||
Widget _buildListView() {
|
Widget _buildListView() {
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: _list.length + _numberTopWidgets,
|
// We use max function here to display to post notice in case there are not posts to display but there are custom widgets...
|
||||||
|
itemCount: max(_list.length, 1) + _numberTopWidgets,
|
||||||
|
|
||||||
itemBuilder: _buildItem,
|
itemBuilder: _buildItem,
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
),
|
),
|
||||||
@ -212,6 +216,9 @@ class PostsListWidgetState extends SafeState<PostsListWidget> {
|
|||||||
Widget _buildItem(BuildContext context, int index) {
|
Widget _buildItem(BuildContext context, int index) {
|
||||||
if (index < _numberTopWidgets) return widget.topWidgets[index];
|
if (index < _numberTopWidgets) return widget.topWidgets[index];
|
||||||
|
|
||||||
|
// Show no posts notice if required
|
||||||
|
if (_list.length == 0) return _buildNoPostNotice();
|
||||||
|
|
||||||
return PostTile(
|
return PostTile(
|
||||||
post: _list[index - _numberTopWidgets],
|
post: _list[index - _numberTopWidgets],
|
||||||
usersInfo: _users,
|
usersInfo: _users,
|
||||||
@ -226,7 +233,8 @@ class PostsListWidgetState extends SafeState<PostsListWidget> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_error == ErrorLevel.MAJOR) return _buildErrorCard();
|
if (_error == ErrorLevel.MAJOR) return _buildErrorCard();
|
||||||
if (_list == null) return buildCenteredProgressBar();
|
if (_list == null) return buildCenteredProgressBar();
|
||||||
if (_list.length == 0) return _buildNoPostNotice();
|
if (_list.length == 0 && _numberTopWidgets == 0)
|
||||||
|
return _buildNoPostNotice();
|
||||||
return widget.buildListView ? _buildListView() : _buildColumn();
|
return widget.buildListView ? _buildListView() : _buildColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user