mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +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,21 +119,19 @@ 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
|
||||||
|
? [IconButton(icon: Icon(Icons.call), onPressed: _startCall)]
|
||||||
|
: [])
|
||||||
|
..addAll(<Widget>[
|
||||||
PopupMenuButton<_Actions>(
|
PopupMenuButton<_Actions>(
|
||||||
itemBuilder: (c) => [
|
itemBuilder: (c) => [
|
||||||
// Start a new call
|
// Start a new call
|
||||||
PopupMenuItem(
|
|
||||||
child: Text(tr("Start call")),
|
|
||||||
value: _Actions.START_CALL,
|
|
||||||
enabled: _conversation.callCapabilities != CallCapabilities.NONE,
|
|
||||||
),
|
|
||||||
|
|
||||||
// Show the list of members
|
// Show the list of members
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
@ -149,7 +147,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
|||||||
],
|
],
|
||||||
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,7 +41,10 @@ class ConversationWindowContainer extends StatelessWidget {
|
|||||||
width: 300,
|
width: 300,
|
||||||
height: !isCollapsed ? 400 : 40,
|
height: !isCollapsed ? 400 : 40,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
appBar: AppBarWrapper(
|
||||||
|
height: 40,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
textTheme: TextTheme(title: TextStyle(fontSize: 15)),
|
||||||
backgroundColor: appBarBgColor,
|
backgroundColor: appBarBgColor,
|
||||||
leading: icon,
|
leading: icon,
|
||||||
title: GestureDetector(child: title, onTap: onToggleCollapse),
|
title: GestureDetector(child: title, onTap: onToggleCollapse),
|
||||||
@ -48,7 +52,7 @@ class ConversationWindowContainer extends StatelessWidget {
|
|||||||
..add(
|
..add(
|
||||||
IconButton(icon: Icon(Icons.close), onPressed: onClose),
|
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