diff --git a/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart b/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart index 3759912..750fde3 100644 --- a/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart +++ b/packages/flutter_community_chat_view/lib/src/config/chat_translations.dart @@ -5,6 +5,7 @@ class ChatTranslations { const ChatTranslations({ this.chatsTitle = 'Chats', + this.chatsUnread = 'unread', this.newChatButton = 'Start chat', this.newChatTitle = 'Start chat', this.image = 'Image', @@ -22,6 +23,7 @@ class ChatTranslations { }); final String chatsTitle; + final String chatsUnread; final String newChatButton; final String newChatTitle; final String deleteChatButton; diff --git a/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart b/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart index fe038d1..b04ef38 100644 --- a/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart +++ b/packages/flutter_community_chat_view/lib/src/screens/chat_screen.dart @@ -13,6 +13,7 @@ class ChatScreen extends StatefulWidget { required this.onPressStartChat, required this.onPressChat, required this.onDeleteChat, + this.unreadChats, this.translations = const ChatTranslations(), super.key, }); @@ -20,6 +21,7 @@ class ChatScreen extends StatefulWidget { final ChatOptions options; final ChatTranslations translations; final Stream> chats; + final Stream? unreadChats; final VoidCallback? onPressStartChat; final void Function(ChatModel chat) onDeleteChat; final void Function(ChatModel chat) onPressChat; @@ -37,6 +39,27 @@ class _ChatScreenState extends State { return widget.options.scaffoldBuilder( AppBar( title: Text(translations.chatsTitle), + centerTitle: true, + actions: widget.unreadChats != null + ? [ + StreamBuilder( + stream: widget.unreadChats, + builder: (BuildContext context, snapshot) => Align( + alignment: Alignment.centerRight, + child: Padding( + padding: const EdgeInsets.only(right: 22.0), + child: Text( + '${snapshot.data ?? 0} ${translations.chatsUnread}', + style: const TextStyle( + color: Color(0xFFBBBBBB), + fontSize: 14, + ), + ), + ), + ), + ), + ] + : [], ), Column( children: [