mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Can collpase conversation window
This commit is contained in:
		@@ -31,11 +31,16 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
 | 
			
		||||
  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<void> _refresh() async {
 | 
			
		||||
    try {
 | 
			
		||||
      _setError(false);
 | 
			
		||||
@@ -71,6 +76,8 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
 | 
			
		||||
      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<ConversationWindow> {
 | 
			
		||||
      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,
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
@@ -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: <Widget>[
 | 
			
		||||
              IconButton(icon: Icon(Icons.close), onPressed: onClose),
 | 
			
		||||
            ],
 | 
			
		||||
          ),
 | 
			
		||||
          body: body,
 | 
			
		||||
          body: Visibility(
 | 
			
		||||
            child: body,
 | 
			
		||||
            visible: !isCollapsed,
 | 
			
		||||
            maintainState: true,
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user