1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 22:39:22 +00:00

Create window container

This commit is contained in:
Pierre HUBERT 2020-05-09 09:30:46 +02:00
parent 109ba3f04b
commit af8e558d9f
3 changed files with 63 additions and 3 deletions

View File

@ -1,3 +1,8 @@
import 'package:comunic/models/conversation.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/intl_utils.dart';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// Single conversation window /// Single conversation window
@ -6,20 +11,30 @@ import 'package:flutter/material.dart';
class ConversationWindow extends StatefulWidget { class ConversationWindow extends StatefulWidget {
final int convID; final int convID;
final Function() onClose;
const ConversationWindow({ const ConversationWindow({
Key key, Key key,
@required this.convID, @required this.convID,
@required this.onClose,
}) : assert(convID != null), }) : assert(convID != null),
assert(onClose != null),
super(key: key); super(key: key);
@override @override
_ConversationWindowState createState() => _ConversationWindowState(); _ConversationWindowState createState() => _ConversationWindowState();
} }
class _ConversationWindowState extends State<ConversationWindow> { class _ConversationWindowState extends SafeState<ConversationWindow> {
Conversation _conversation;
String _convTitle;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card();//TODO : continue here return ConversationWindowContainer(
title: Text(tr("Loading...")),
onClose: widget.onClose,
body: buildCenteredProgressBar(),
);
} }
} }

View File

@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
/// Conversation window
///
/// Simple container for a conversation
///
/// @author Pierre Hubert
class ConversationWindowContainer extends StatelessWidget {
final Widget title;
final void Function() onClose;
final Widget body;
const ConversationWindowContainer({
Key key,
@required this.title,
@required this.onClose,
@required this.body,
}) : assert(title != null),
assert(onClose != null),
assert(body != null),
super(key: key);
@override
Widget build(BuildContext context) {
return Card(
child: Container(
width: 300,
height: 400,
child: Scaffold(
appBar: AppBar(
title: title,
actions: <Widget>[
IconButton(icon: Icon(Icons.close), onPressed: onClose),
],
),
body: body,
),
),
);
}
}

View File

@ -34,5 +34,8 @@ class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
setState(() => _openConversations.add(convID)); setState(() => _openConversations.add(convID));
} }
Widget _conversationWindow(int convID) => ConversationWindow(convID: convID); Widget _conversationWindow(int convID) => ConversationWindow(
convID: convID,
onClose: () => setState(() => _openConversations.remove(convID)),
);
} }