From 75c596226b455062e7a09cdd6348abc22761abca Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 12 Mar 2022 09:47:58 +0100 Subject: [PATCH] Show a message if user has no conversation yet --- lib/ui/screens/conversations_list_screen.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ui/screens/conversations_list_screen.dart b/lib/ui/screens/conversations_list_screen.dart index 339cbae..38a8b09 100644 --- a/lib/ui/screens/conversations_list_screen.dart +++ b/lib/ui/screens/conversations_list_screen.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:comunic/enums/load_error_level.dart'; import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/events_helper.dart'; @@ -179,6 +181,14 @@ class _ConversationScreenState extends SafeState { physics: AlwaysScrollableScrollPhysics(), controller: ScrollController(), itemBuilder: (context, index) { + if (_list!.isEmpty) + return Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Text( + tr("You do not have any conversation yet!")!)), + ); + if (_list![index].isGroupConversation && !_list![index].following) return Container(); @@ -193,7 +203,7 @@ class _ConversationScreenState extends SafeState { onRequestLeave: _requestLeaveConversation, ); }, - itemCount: _list!.length, + itemCount: max(_list!.length, 1), ), ), ),