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

Improve buttons bar

This commit is contained in:
Pierre HUBERT 2020-05-10 14:32:44 +02:00
parent ef186f79d2
commit 1d7e846973
2 changed files with 58 additions and 24 deletions

View File

@ -28,10 +28,15 @@ enum _PopupMenuOption { STOP_STREAMING, SWITCH_CAMERA }
class CallScreen extends StatefulWidget { class CallScreen extends StatefulWidget {
final int convID; final int convID;
final bool floatingButtons;
const CallScreen({Key key, @required this.convID}) const CallScreen({
: assert(convID != null), Key key,
@required this.convID,
this.floatingButtons = true,
}) : assert(convID != null),
assert(convID > 0), assert(convID > 0),
assert(floatingButtons != null),
super(key: key); super(key: key);
@override @override
@ -479,7 +484,10 @@ class _CallScreenState extends SafeState<CallScreen> {
return Column( return Column(
children: <Widget>[ children: <Widget>[
_canHideMenuBar ? Container() : _buildMembersArea(), _canHideMenuBar ? Container() : _buildMembersArea(),
Expanded(child: LayoutBuilder(builder: _buildVideosArea)) Expanded(child: LayoutBuilder(builder: _buildVideosArea)),
_canHideMenuBar || widget.floatingButtons
? Container()
: _buildFooterArea()
], ],
); );
} }
@ -536,7 +544,7 @@ class _CallScreenState extends SafeState<CallScreen> {
return Stack( return Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
// Remove peers videos // Remote peers videos
Column( Column(
children: rows, children: rows,
), ),
@ -547,7 +555,10 @@ class _CallScreenState extends SafeState<CallScreen> {
: Container(), : Container(),
// Buttons bar // Buttons bar
_canHideMenuBar ? Container() : _buildFooterArea() _canHideMenuBar || !widget.floatingButtons
? Container()
: Positioned(
bottom: 10, right: 0, left: 0, child: _buildFooterArea())
], ],
); );
} }
@ -562,16 +573,15 @@ class _CallScreenState extends SafeState<CallScreen> {
height: 50, height: 50,
width: 50, width: 50,
right: 10, right: 10,
bottom: (_canHideMenuBar ? 10 : 80), bottom: (_canHideMenuBar || !widget.floatingButtons ? 10 : 80),
); );
} }
/// Footer area /// Footer area
Widget _buildFooterArea() { Widget _buildFooterArea() {
return Positioned( return Container(
bottom: 10, color: !widget.floatingButtons ? Colors.black : null,
right: 0, height: !widget.floatingButtons ? 40 : null,
left: 0,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -582,6 +592,7 @@ class _CallScreenState extends SafeState<CallScreen> {
icon: Icon(_isLocalStreamVisible icon: Icon(_isLocalStreamVisible
? Icons.visibility ? Icons.visibility
: Icons.visibility_off), : Icons.visibility_off),
roundedButtons: widget.floatingButtons,
onPressed: () => _toggleLocalStreamVisibility(), onPressed: () => _toggleLocalStreamVisibility(),
), ),
@ -590,12 +601,14 @@ class _CallScreenState extends SafeState<CallScreen> {
onPressed: () => _toggleStreaming(false), onPressed: () => _toggleStreaming(false),
icon: Icon( icon: Icon(
isStreamingAudio && !isAudioMuted ? Icons.mic : Icons.mic_off), isStreamingAudio && !isAudioMuted ? Icons.mic : Icons.mic_off),
roundedButtons: widget.floatingButtons,
), ),
// Hang up call // Hang up call
_FooterButton( _FooterButton(
width: 60, width: 60,
icon: Icon(Icons.phone), icon: Icon(Icons.phone),
roundedButtons: widget.floatingButtons,
bgColor: Colors.red.shade900, bgColor: Colors.red.shade900,
onPressed: () => _leaveCall(), onPressed: () => _leaveCall(),
), ),
@ -606,6 +619,7 @@ class _CallScreenState extends SafeState<CallScreen> {
icon: Icon(isStreamingVideo && !isVideoMuted icon: Icon(isStreamingVideo && !isVideoMuted
? Icons.videocam ? Icons.videocam
: Icons.videocam_off), : Icons.videocam_off),
roundedButtons: widget.floatingButtons,
onPressed: () => _toggleStreaming(true), onPressed: () => _toggleStreaming(true),
), ),
@ -624,7 +638,11 @@ class _CallScreenState extends SafeState<CallScreen> {
child: Text(tr("Stop streaming")), child: Text(tr("Stop streaming")),
value: _PopupMenuOption.STOP_STREAMING) value: _PopupMenuOption.STOP_STREAMING)
], ],
child: _FooterButton(icon: Icon(Icons.menu), onPressed: null), child: _FooterButton(
icon: Icon(Icons.menu, color: Colors.white),
onPressed: null,
roundedButtons: widget.floatingButtons,
),
onSelected: (d) => _handleSelectedMenuOption(d), onSelected: (d) => _handleSelectedMenuOption(d),
) )
], ],
@ -639,22 +657,28 @@ class _FooterButton extends StatelessWidget {
final bool visible; final bool visible;
final double width; final double width;
final Color bgColor; final Color bgColor;
final bool roundedButtons;
const _FooterButton( const _FooterButton({
{Key key, Key key,
@required this.icon, @required this.icon,
@required this.onPressed, @required this.onPressed,
this.visible = true, this.visible = true,
this.width = 45, this.width = 45,
this.bgColor = Colors.black}) this.bgColor = Colors.black,
: assert(icon != null), @required this.roundedButtons,
}) : assert(icon != null),
assert(visible != null), assert(visible != null),
assert(roundedButtons != null),
super(key: key); super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!visible) return Container(); if (!visible) return Container();
return Padding( return roundedButtons ? _buildFAB() : _buildRectangleButton();
}
Widget _buildFAB() => Padding(
padding: const EdgeInsets.only(left: 6, right: 6), padding: const EdgeInsets.only(left: 6, right: 6),
child: Container( child: Container(
width: width, width: width,
@ -664,7 +688,12 @@ class _FooterButton extends StatelessWidget {
onPressed: onPressed == null ? null : () => onPressed(), onPressed: onPressed == null ? null : () => onPressed(),
backgroundColor: bgColor, backgroundColor: bgColor,
), ),
), ));
);
} Widget _buildRectangleButton() => MaterialButton(
onPressed: onPressed,
child: icon,
color: bgColor,
textColor: Colors.white,
);
} }

View File

@ -41,7 +41,12 @@ class _CallWindowWidgetState extends State<CallWindowWidget> {
left: _left, left: _left,
top: _top, top: _top,
child: Draggable( child: Draggable(
child: Card(child: CallScreen(convID: widget.convID)), child: Card(
child: CallScreen(
convID: widget.convID,
floatingButtons: false,
),
),
feedback: Container( feedback: Container(
width: _WindowSize.width, width: _WindowSize.width,
height: _WindowSize.height, height: _WindowSize.height,