diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart index 1e8ec9f..a289bf8 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart @@ -1,8 +1,10 @@ import 'package:comunic/helpers/conversations_helper.dart'; +import 'package:comunic/helpers/events_helper.dart'; import 'package:comunic/models/conversation.dart'; import 'package:comunic/ui/screens/conversation_screen.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/ui/widgets/tablet_mode/conversations/conversation_window_container.dart'; +import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; import 'package:flutter/material.dart'; @@ -32,6 +34,7 @@ class _ConversationWindowState extends SafeState { String _convTitle; bool _error = false; bool _collapsed = false; + bool _hasNewMessages = false; int get _convID => widget.convID; @@ -39,7 +42,10 @@ class _ConversationWindowState extends SafeState { void _setError(bool e) => setState(() => _error = e); - void _toggleVisibility() => setState(() => _collapsed = !_collapsed); + void _toggleVisibility() => setState(() { + _collapsed = !_collapsed; + if (!_collapsed) _hasNewMessages = false; + }); Future _refresh() async { try { @@ -67,6 +73,12 @@ class _ConversationWindowState extends SafeState { void initState() { super.initState(); _refresh(); + + listen((e) { + if (e.msg.conversationID == _convID && + _collapsed && + e.msg.userID != userID()) setState(() => _hasNewMessages = true); + }); } @override @@ -101,7 +113,8 @@ class _ConversationWindowState extends SafeState { ); return ConversationWindowContainer( - icon: Icon(Icons.comment), + icon: Icon(_hasNewMessages ? Icons.trip_origin : Icons.comment), + appBarBgColor: _hasNewMessages ? Colors.green : null, title: Text(_convTitle), onClose: widget.onClose, onToggleCollapse: _toggleVisibility, diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart index 35156b6..3dcf755 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; /// @author Pierre Hubert class ConversationWindowContainer extends StatelessWidget { + final Color appBarBgColor; final Widget icon; final Widget title; final void Function() onClose; @@ -16,6 +17,7 @@ class ConversationWindowContainer extends StatelessWidget { const ConversationWindowContainer({ Key key, + this.appBarBgColor, this.icon, @required this.title, @required this.onClose, @@ -37,6 +39,7 @@ class ConversationWindowContainer extends StatelessWidget { height: !isCollapsed ? 400 : 40, child: Scaffold( appBar: AppBar( + backgroundColor: appBarBgColor, leading: icon, title: GestureDetector(child: title, onTap: onToggleCollapse), actions: [