From 2cea14a0121f6f39a355385e802501da5456c453 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 9 May 2020 10:20:06 +0200 Subject: [PATCH] Can collpase conversation window --- .../conversations/conversation_window.dart | 12 ++++++++++++ .../conversation_window_container.dart | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart index 4df7bdd..eb34c82 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart @@ -31,11 +31,16 @@ class _ConversationWindowState extends SafeState { Conversation _conversation; String _convTitle; bool _error = false; + bool _collapsed = false; int get _convID => widget.convID; + final _convKey = UniqueKey(); + void _setError(bool e) => setState(() => _error = e); + void _toggleVisibility() => setState(() => _collapsed = !_collapsed); + Future _refresh() async { try { _setError(false); @@ -71,6 +76,8 @@ class _ConversationWindowState extends SafeState { return ConversationWindowContainer( title: Text(tr("Error")), onClose: widget.onClose, + onToggleCollpase: _toggleVisibility, + isCollapsed: _collapsed, body: buildErrorCard(tr("Could not load conversation information!"), actions: [ FlatButton( @@ -86,13 +93,18 @@ class _ConversationWindowState extends SafeState { return ConversationWindowContainer( title: Text(tr("Loading...")), onClose: widget.onClose, + onToggleCollpase: _toggleVisibility, + isCollapsed: _collapsed, body: buildCenteredProgressBar(), ); return ConversationWindowContainer( title: Text(_convTitle), onClose: widget.onClose, + onToggleCollpase: _toggleVisibility, + isCollapsed: _collapsed, body: ConversationScreen( + key: _convKey, conversationID: _convID, ), ); 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 4f6514d..efad923 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window_container.dart @@ -9,6 +9,8 @@ import 'package:flutter/material.dart'; class ConversationWindowContainer extends StatelessWidget { final Widget title; final void Function() onClose; + final void Function() onToggleCollpase; + final bool isCollapsed; final Widget body; const ConversationWindowContainer({ @@ -16,9 +18,13 @@ class ConversationWindowContainer extends StatelessWidget { @required this.title, @required this.onClose, @required this.body, + @required this.onToggleCollpase, + @required this.isCollapsed, }) : assert(title != null), assert(onClose != null), assert(body != null), + assert(onToggleCollpase != null), + assert(isCollapsed != null), super(key: key); @override @@ -26,15 +32,19 @@ class ConversationWindowContainer extends StatelessWidget { return Card( child: Container( width: 300, - height: 400, + height: !isCollapsed ? 400 : 40, child: Scaffold( appBar: AppBar( - title: title, + title: GestureDetector(child: title, onTap: onToggleCollpase), actions: [ IconButton(icon: Icon(Icons.close), onPressed: onClose), ], ), - body: body, + body: Visibility( + child: body, + visible: !isCollapsed, + maintainState: true, + ), ), ), );