1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 06:53:23 +00:00

Manage to add call button in a visible way

This commit is contained in:
Pierre HUBERT 2020-05-09 20:11:54 +02:00
parent 642820127c
commit 25222e9156
3 changed files with 60 additions and 38 deletions

View File

@ -0,0 +1,22 @@
import 'package:flutter/material.dart';
/// Customize the size of the AppBar
///
/// @author Pierre Hubert
/// Reduce the size of the appbar
class AppBarWrapper extends StatelessWidget implements PreferredSizeWidget {
final Widget appBar;
final double height;
const AppBarWrapper({@required this.height, @required this.appBar})
: assert(height != null),
assert(appBar != null),
super();
@override
Widget build(BuildContext context) => appBar;
@override
Size get preferredSize => Size.fromHeight(height);
}

View File

@ -17,7 +17,7 @@ import 'package:flutter/material.dart';
///
/// @author Pierre Hubert
enum _Actions { START_CALL, OPEN_MEMBERS, OPEN_SETTINGS }
enum _Actions { OPEN_MEMBERS, OPEN_SETTINGS }
class ConversationWindow extends StatefulWidget {
final int convID;
@ -119,37 +119,35 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
);
return ConversationWindowContainer(
icon: Icon(_hasNewMessages ? Icons.trip_origin : Icons.comment),
icon: _hasNewMessages ? Icon(Icons.trip_origin) : null,
appBarBgColor: _hasNewMessages ? Colors.green : null,
title: Text(_convTitle),
onClose: widget.onClose,
onToggleCollapse: _toggleVisibility,
isCollapsed: _collapsed,
action: <Widget>[
PopupMenuButton<_Actions>(
itemBuilder: (c) => [
// Start a new call
PopupMenuItem(
child: Text(tr("Start call")),
value: _Actions.START_CALL,
enabled: _conversation.callCapabilities != CallCapabilities.NONE,
),
action: (_conversation.callCapabilities != CallCapabilities.NONE
? [IconButton(icon: Icon(Icons.call), onPressed: _startCall)]
: [])
..addAll(<Widget>[
PopupMenuButton<_Actions>(
itemBuilder: (c) => [
// Start a new call
// Show the list of members
PopupMenuItem(
child: Text(tr("Members")),
value: _Actions.OPEN_MEMBERS,
),
// Show the list of members
PopupMenuItem(
child: Text(tr("Members")),
value: _Actions.OPEN_MEMBERS,
),
// Show conversation settings
PopupMenuItem(
child: Text(tr("Settings")),
value: _Actions.OPEN_SETTINGS,
)
],
onSelected: _menuCallback,
),
],
// Show conversation settings
PopupMenuItem(
child: Text(tr("Settings")),
value: _Actions.OPEN_SETTINGS,
)
],
onSelected: _menuCallback,
),
]),
body: ConversationScreen(
key: _convKey,
conversationID: _convID,
@ -159,10 +157,6 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
void _menuCallback(_Actions value) {
switch (value) {
case _Actions.START_CALL:
MainController.of(context).startCall(_convID);
break;
case _Actions.OPEN_MEMBERS:
_openMembersList();
break;
@ -182,4 +176,6 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
context, UpdateConversationRoute(conversationID: _convID));
_refresh();
}
void _startCall() => MainController.of(context).startCall(_convID);
}

View File

@ -1,3 +1,4 @@
import 'package:comunic/ui/widgets/custom_app_bar_size.dart';
import 'package:flutter/material.dart';
/// Conversation window
@ -40,15 +41,18 @@ class ConversationWindowContainer extends StatelessWidget {
width: 300,
height: !isCollapsed ? 400 : 40,
child: Scaffold(
appBar: AppBar(
backgroundColor: appBarBgColor,
leading: icon,
title: GestureDetector(child: title, onTap: onToggleCollapse),
actions: (action == null ? [] : action)
..add(
IconButton(icon: Icon(Icons.close), onPressed: onClose),
),
),
appBar: AppBarWrapper(
height: 40,
appBar: AppBar(
textTheme: TextTheme(title: TextStyle(fontSize: 15)),
backgroundColor: appBarBgColor,
leading: icon,
title: GestureDetector(child: title, onTap: onToggleCollapse),
actions: (action == null ? [] : action)
..add(
IconButton(icon: Icon(Icons.close), onPressed: onClose),
),
)),
body: Visibility(
child: body,
visible: !isCollapsed,