mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59: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
|
||||
|
||||
enum _Actions { START_CALL, OPEN_MEMBERS, OPEN_SETTINGS }
|
||||
enum _Actions { OPEN_MEMBERS, OPEN_SETTINGS }
|
||||
|
||||
class ConversationWindow extends StatefulWidget {
|
||||
final int convID;
|
||||
@ -119,21 +119,19 @@ 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>[
|
||||
action: (_conversation.callCapabilities != CallCapabilities.NONE
|
||||
? [IconButton(icon: Icon(Icons.call), onPressed: _startCall)]
|
||||
: [])
|
||||
..addAll(<Widget>[
|
||||
PopupMenuButton<_Actions>(
|
||||
itemBuilder: (c) => [
|
||||
// Start a new call
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Start call")),
|
||||
value: _Actions.START_CALL,
|
||||
enabled: _conversation.callCapabilities != CallCapabilities.NONE,
|
||||
),
|
||||
|
||||
// Show the list of members
|
||||
PopupMenuItem(
|
||||
@ -149,7 +147,7 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
|
||||
],
|
||||
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);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:comunic/ui/widgets/custom_app_bar_size.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Conversation window
|
||||
@ -40,7 +41,10 @@ class ConversationWindowContainer extends StatelessWidget {
|
||||
width: 300,
|
||||
height: !isCollapsed ? 400 : 40,
|
||||
child: Scaffold(
|
||||
appBar: AppBarWrapper(
|
||||
height: 40,
|
||||
appBar: AppBar(
|
||||
textTheme: TextTheme(title: TextStyle(fontSize: 15)),
|
||||
backgroundColor: appBarBgColor,
|
||||
leading: icon,
|
||||
title: GestureDetector(child: title, onTap: onToggleCollapse),
|
||||
@ -48,7 +52,7 @@ class ConversationWindowContainer extends StatelessWidget {
|
||||
..add(
|
||||
IconButton(icon: Icon(Icons.close), onPressed: onClose),
|
||||
),
|
||||
),
|
||||
)),
|
||||
body: Visibility(
|
||||
child: body,
|
||||
visible: !isCollapsed,
|
||||
|
Loading…
Reference in New Issue
Block a user