mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Can collpase conversation window
This commit is contained in:
		@@ -31,11 +31,16 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
 | 
				
			|||||||
  Conversation _conversation;
 | 
					  Conversation _conversation;
 | 
				
			||||||
  String _convTitle;
 | 
					  String _convTitle;
 | 
				
			||||||
  bool _error = false;
 | 
					  bool _error = false;
 | 
				
			||||||
 | 
					  bool _collapsed = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int get _convID => widget.convID;
 | 
					  int get _convID => widget.convID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  final _convKey = UniqueKey();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void _setError(bool e) => setState(() => _error = e);
 | 
					  void _setError(bool e) => setState(() => _error = e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void _toggleVisibility() => setState(() => _collapsed = !_collapsed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Future<void> _refresh() async {
 | 
					  Future<void> _refresh() async {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      _setError(false);
 | 
					      _setError(false);
 | 
				
			||||||
@@ -71,6 +76,8 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
 | 
				
			|||||||
      return ConversationWindowContainer(
 | 
					      return ConversationWindowContainer(
 | 
				
			||||||
        title: Text(tr("Error")),
 | 
					        title: Text(tr("Error")),
 | 
				
			||||||
        onClose: widget.onClose,
 | 
					        onClose: widget.onClose,
 | 
				
			||||||
 | 
					        onToggleCollpase: _toggleVisibility,
 | 
				
			||||||
 | 
					        isCollapsed: _collapsed,
 | 
				
			||||||
        body: buildErrorCard(tr("Could not load conversation information!"),
 | 
					        body: buildErrorCard(tr("Could not load conversation information!"),
 | 
				
			||||||
            actions: [
 | 
					            actions: [
 | 
				
			||||||
              FlatButton(
 | 
					              FlatButton(
 | 
				
			||||||
@@ -86,13 +93,18 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
 | 
				
			|||||||
      return ConversationWindowContainer(
 | 
					      return ConversationWindowContainer(
 | 
				
			||||||
        title: Text(tr("Loading...")),
 | 
					        title: Text(tr("Loading...")),
 | 
				
			||||||
        onClose: widget.onClose,
 | 
					        onClose: widget.onClose,
 | 
				
			||||||
 | 
					        onToggleCollpase: _toggleVisibility,
 | 
				
			||||||
 | 
					        isCollapsed: _collapsed,
 | 
				
			||||||
        body: buildCenteredProgressBar(),
 | 
					        body: buildCenteredProgressBar(),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ConversationWindowContainer(
 | 
					    return ConversationWindowContainer(
 | 
				
			||||||
      title: Text(_convTitle),
 | 
					      title: Text(_convTitle),
 | 
				
			||||||
      onClose: widget.onClose,
 | 
					      onClose: widget.onClose,
 | 
				
			||||||
 | 
					      onToggleCollpase: _toggleVisibility,
 | 
				
			||||||
 | 
					      isCollapsed: _collapsed,
 | 
				
			||||||
      body: ConversationScreen(
 | 
					      body: ConversationScreen(
 | 
				
			||||||
 | 
					        key: _convKey,
 | 
				
			||||||
        conversationID: _convID,
 | 
					        conversationID: _convID,
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@ import 'package:flutter/material.dart';
 | 
				
			|||||||
class ConversationWindowContainer extends StatelessWidget {
 | 
					class ConversationWindowContainer extends StatelessWidget {
 | 
				
			||||||
  final Widget title;
 | 
					  final Widget title;
 | 
				
			||||||
  final void Function() onClose;
 | 
					  final void Function() onClose;
 | 
				
			||||||
 | 
					  final void Function() onToggleCollpase;
 | 
				
			||||||
 | 
					  final bool isCollapsed;
 | 
				
			||||||
  final Widget body;
 | 
					  final Widget body;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const ConversationWindowContainer({
 | 
					  const ConversationWindowContainer({
 | 
				
			||||||
@@ -16,9 +18,13 @@ class ConversationWindowContainer extends StatelessWidget {
 | 
				
			|||||||
    @required this.title,
 | 
					    @required this.title,
 | 
				
			||||||
    @required this.onClose,
 | 
					    @required this.onClose,
 | 
				
			||||||
    @required this.body,
 | 
					    @required this.body,
 | 
				
			||||||
 | 
					    @required this.onToggleCollpase,
 | 
				
			||||||
 | 
					    @required this.isCollapsed,
 | 
				
			||||||
  })  : assert(title != null),
 | 
					  })  : assert(title != null),
 | 
				
			||||||
        assert(onClose != null),
 | 
					        assert(onClose != null),
 | 
				
			||||||
        assert(body != null),
 | 
					        assert(body != null),
 | 
				
			||||||
 | 
					        assert(onToggleCollpase != null),
 | 
				
			||||||
 | 
					        assert(isCollapsed != null),
 | 
				
			||||||
        super(key: key);
 | 
					        super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@@ -26,15 +32,19 @@ class ConversationWindowContainer extends StatelessWidget {
 | 
				
			|||||||
    return Card(
 | 
					    return Card(
 | 
				
			||||||
      child: Container(
 | 
					      child: Container(
 | 
				
			||||||
        width: 300,
 | 
					        width: 300,
 | 
				
			||||||
        height: 400,
 | 
					        height: !isCollapsed ? 400 : 40,
 | 
				
			||||||
        child: Scaffold(
 | 
					        child: Scaffold(
 | 
				
			||||||
          appBar: AppBar(
 | 
					          appBar: AppBar(
 | 
				
			||||||
            title: title,
 | 
					            title: GestureDetector(child: title, onTap: onToggleCollpase),
 | 
				
			||||||
            actions: <Widget>[
 | 
					            actions: <Widget>[
 | 
				
			||||||
              IconButton(icon: Icon(Icons.close), onPressed: onClose),
 | 
					              IconButton(icon: Icon(Icons.close), onPressed: onClose),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
          body: body,
 | 
					          body: Visibility(
 | 
				
			||||||
 | 
					            child: body,
 | 
				
			||||||
 | 
					            visible: !isCollapsed,
 | 
				
			||||||
 | 
					            maintainState: true,
 | 
				
			||||||
 | 
					          ),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user