1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-24 22:09:21 +00:00

Show a message if user has no friend yet

This commit is contained in:
Pierre HUBERT 2022-03-12 09:44:21 +01:00
parent 2ac5caaf96
commit a0abdc4f1b

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:comunic/helpers/friends_helper.dart'; import 'package:comunic/helpers/friends_helper.dart';
import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/lists/friends_list.dart'; import 'package:comunic/lists/friends_list.dart';
@ -133,8 +135,16 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
onRefresh: () => _loadList(true), onRefresh: () => _loadList(true),
child: ListView.builder( child: ListView.builder(
physics: AlwaysScrollableScrollPhysics(), physics: AlwaysScrollableScrollPhysics(),
itemCount: _friendsList!.length, itemCount: max(_friendsList!.length, 1),
itemBuilder: (c, i) => _friendsList![i].accepted itemBuilder: (c, i) {
if (_friendsList!.isEmpty)
return Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(tr("You do not have any friend yet!")!)),
);
return _friendsList![i].accepted
? AcceptedFriendTile( ? AcceptedFriendTile(
friend: _friendsList![i], friend: _friendsList![i],
user: _usersInfo.getUser(_friendsList![i].id), user: _usersInfo.getUser(_friendsList![i].id),
@ -146,7 +156,8 @@ class _FriendsListScreenState extends SafeState<FriendsListScreen> {
friend: _friendsList![i], friend: _friendsList![i],
user: _usersInfo.getUser(_friendsList![i].id), user: _usersInfo.getUser(_friendsList![i].id),
onRespond: _respondRequest, onRespond: _respondRequest,
)), );
}),
), ),
), ),
], ],