mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Manage to add call button in a visible way
This commit is contained in:
parent
642820127c
commit
25222e9156
22
lib/ui/widgets/custom_app_bar_size.dart
Normal file
22
lib/ui/widgets/custom_app_bar_size.dart
Normal 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);
|
||||||
|
}
|
@ -17,7 +17,7 @@ import 'package:flutter/material.dart';
|
|||||||
///
|
///
|
||||||
/// @author Pierre Hubert
|
/// @author Pierre Hubert
|
||||||
|
|
||||||
enum _Actions { START_CALL, OPEN_MEMBERS, OPEN_SETTINGS }
|
enum _Actions { OPEN_MEMBERS, OPEN_SETTINGS }
|
||||||
|
|
||||||
class ConversationWindow extends StatefulWidget {
|
class ConversationWindow extends StatefulWidget {
|
||||||
final int convID;
|
final int convID;
|
||||||
@ -119,37 +119,35 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return ConversationWindowContainer(
|
return ConversationWindowContainer(
|
||||||
icon: Icon(_hasNewMessages ? Icons.trip_origin : Icons.comment),
|
icon: _hasNewMessages ? Icon(Icons.trip_origin) : null,
|
||||||
appBarBgColor: _hasNewMessages ? Colors.green : null,
|
appBarBgColor: _hasNewMessages ? Colors.green : null,
|
||||||
title: Text(_convTitle),
|
title: Text(_convTitle),
|
||||||
onClose: widget.onClose,
|
onClose: widget.onClose,
|
||||||
onToggleCollapse: _toggleVisibility,
|
onToggleCollapse: _toggleVisibility,
|
||||||
isCollapsed: _collapsed,
|
isCollapsed: _collapsed,
|
||||||
action: <Widget>[
|
action: (_conversation.callCapabilities != CallCapabilities.NONE
|
||||||
PopupMenuButton<_Actions>(
|
? [IconButton(icon: Icon(Icons.call), onPressed: _startCall)]
|
||||||
itemBuilder: (c) => [
|
: [])
|
||||||
// Start a new call
|
..addAll(<Widget>[
|
||||||
PopupMenuItem(
|
PopupMenuButton<_Actions>(
|
||||||
child: Text(tr("Start call")),
|
itemBuilder: (c) => [
|
||||||
value: _Actions.START_CALL,
|
// Start a new call
|
||||||
enabled: _conversation.callCapabilities != CallCapabilities.NONE,
|
|
||||||
),
|
|
||||||
|
|
||||||
// Show the list of members
|
// Show the list of members
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(tr("Members")),
|
child: Text(tr("Members")),
|
||||||
value: _Actions.OPEN_MEMBERS,
|
value: _Actions.OPEN_MEMBERS,
|
||||||
),
|
),
|
||||||
|
|
||||||
// Show conversation settings
|
// Show conversation settings
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(tr("Settings")),
|
child: Text(tr("Settings")),
|
||||||
value: _Actions.OPEN_SETTINGS,
|
value: _Actions.OPEN_SETTINGS,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
onSelected: _menuCallback,
|
onSelected: _menuCallback,
|
||||||
),
|
),
|
||||||
],
|
]),
|
||||||
body: ConversationScreen(
|
body: ConversationScreen(
|
||||||
key: _convKey,
|
key: _convKey,
|
||||||
conversationID: _convID,
|
conversationID: _convID,
|
||||||
@ -159,10 +157,6 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
|||||||
|
|
||||||
void _menuCallback(_Actions value) {
|
void _menuCallback(_Actions value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case _Actions.START_CALL:
|
|
||||||
MainController.of(context).startCall(_convID);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case _Actions.OPEN_MEMBERS:
|
case _Actions.OPEN_MEMBERS:
|
||||||
_openMembersList();
|
_openMembersList();
|
||||||
break;
|
break;
|
||||||
@ -182,4 +176,6 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
|||||||
context, UpdateConversationRoute(conversationID: _convID));
|
context, UpdateConversationRoute(conversationID: _convID));
|
||||||
_refresh();
|
_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _startCall() => MainController.of(context).startCall(_convID);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:comunic/ui/widgets/custom_app_bar_size.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Conversation window
|
/// Conversation window
|
||||||
@ -40,15 +41,18 @@ class ConversationWindowContainer extends StatelessWidget {
|
|||||||
width: 300,
|
width: 300,
|
||||||
height: !isCollapsed ? 400 : 40,
|
height: !isCollapsed ? 400 : 40,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBarWrapper(
|
||||||
backgroundColor: appBarBgColor,
|
height: 40,
|
||||||
leading: icon,
|
appBar: AppBar(
|
||||||
title: GestureDetector(child: title, onTap: onToggleCollapse),
|
textTheme: TextTheme(title: TextStyle(fontSize: 15)),
|
||||||
actions: (action == null ? [] : action)
|
backgroundColor: appBarBgColor,
|
||||||
..add(
|
leading: icon,
|
||||||
IconButton(icon: Icon(Icons.close), onPressed: onClose),
|
title: GestureDetector(child: title, onTap: onToggleCollapse),
|
||||||
),
|
actions: (action == null ? [] : action)
|
||||||
),
|
..add(
|
||||||
|
IconButton(icon: Icon(Icons.close), onPressed: onClose),
|
||||||
|
),
|
||||||
|
)),
|
||||||
body: Visibility(
|
body: Visibility(
|
||||||
child: body,
|
child: body,
|
||||||
visible: !isCollapsed,
|
visible: !isCollapsed,
|
||||||
|
Loading…
Reference in New Issue
Block a user