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

Ready to start to show the list of members

This commit is contained in:
Pierre HUBERT 2020-05-09 12:16:55 +02:00
parent 032815b29f
commit 099f282cd6
3 changed files with 78 additions and 3 deletions

View File

@ -0,0 +1,43 @@
import 'dart:math';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Screen dialog
///
/// @author Pierre Hubert
/// Show a screen dialog
///
/// This widget automatically adapt himself if we are in tablet
/// or in mobile mode
Future<T> showScreenDialog<T>(BuildContext context, Widget screen) async {
// TODO : add mobile support
if (!isTablet(context)) throw Exception("Unsupported mode!");
return await showDialog(
context: context, builder: (c) => _ScreenDialog(body: screen));
}
class _ScreenDialog extends StatelessWidget {
final Widget body;
const _ScreenDialog({Key key, this.body}) : super(key: key);
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final width = min(500.0, size.width - 50);
final height = min(800.0, size.height - 50);
return AlertDialog(
contentPadding: EdgeInsets.all(0.0),
content: Container(
width: width,
height: height,
child: body,
),
);
}
}

View File

@ -1,7 +1,9 @@
import 'package:comunic/helpers/conversations_helper.dart';
import 'package:comunic/helpers/events_helper.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/dialogs/screen_dialog.dart';
import 'package:comunic/ui/screens/conversation_screen.dart';
import 'package:comunic/ui/screens/user_page_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';
@ -13,6 +15,8 @@ import 'package:flutter/material.dart';
///
/// @author Pierre Hubert
enum _Actions { OPEN_MEMBERS }
class ConversationWindow extends StatefulWidget {
final int convID;
final Function() onClose;
@ -119,10 +123,35 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
onClose: widget.onClose,
onToggleCollapse: _toggleVisibility,
isCollapsed: _collapsed,
action: <Widget>[
PopupMenuButton<_Actions>(
itemBuilder: (c) => [
// Show the list of members
PopupMenuItem(
child: Text(tr("Members")),
value: _Actions.OPEN_MEMBERS,
)
],
onSelected: _menuCallback,
),
],
body: ConversationScreen(
key: _convKey,
conversationID: _convID,
),
);
}
void _menuCallback(_Actions value) {
switch (value) {
case _Actions.OPEN_MEMBERS:
_openMembersList();
break;
}
}
void _openMembersList() {
// dummy test
showScreenDialog(context, UserPageScreen(userID: 1));
}
}

View File

@ -14,6 +14,7 @@ class ConversationWindowContainer extends StatelessWidget {
final void Function() onToggleCollapse;
final bool isCollapsed;
final Widget body;
final List<Widget> action;
const ConversationWindowContainer({
Key key,
@ -24,6 +25,7 @@ class ConversationWindowContainer extends StatelessWidget {
@required this.body,
@required this.onToggleCollapse,
@required this.isCollapsed,
this.action,
}) : assert(title != null),
assert(onClose != null),
assert(body != null),
@ -42,9 +44,10 @@ class ConversationWindowContainer extends StatelessWidget {
backgroundColor: appBarBgColor,
leading: icon,
title: GestureDetector(child: title, onTap: onToggleCollapse),
actions: <Widget>[
IconButton(icon: Icon(Icons.close), onPressed: onClose),
],
actions: (action == null ? [] : action)
..add(
IconButton(icon: Icon(Icons.close), onPressed: onClose),
),
),
body: Visibility(
child: body,