mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +00:00
Use custom app bar for call windows
This commit is contained in:
parent
cf9f93dcb3
commit
476f08681b
@ -32,10 +32,15 @@ class CallScreen extends StatefulWidget {
|
||||
/// This settings should be always true except for the small call window...
|
||||
final bool floatingButtons;
|
||||
|
||||
/// Use custom application bar. This function takes as parameter a nullable
|
||||
/// String which is the title of the conversation
|
||||
final PreferredSizeWidget Function(String) buildCustomAppBar;
|
||||
|
||||
const CallScreen({
|
||||
Key key,
|
||||
@required this.convID,
|
||||
this.floatingButtons = true,
|
||||
this.buildCustomAppBar,
|
||||
}) : assert(convID != null),
|
||||
assert(convID > 0),
|
||||
assert(floatingButtons != null),
|
||||
@ -453,22 +458,26 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
return GestureDetector(
|
||||
onDoubleTap: () => _toggleMenuBarsVisibility(),
|
||||
child: Scaffold(
|
||||
appBar: _canHideMenuBar
|
||||
? null
|
||||
: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () => _leaveCall(),
|
||||
),
|
||||
title: _convName == null
|
||||
? CircularProgressIndicator()
|
||||
: Text(_convName),
|
||||
),
|
||||
appBar: _canHideMenuBar ? null : _buildAppBar(),
|
||||
body: _buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build application bar
|
||||
PreferredSizeWidget _buildAppBar() {
|
||||
if (widget.buildCustomAppBar != null)
|
||||
return widget.buildCustomAppBar(_convName);
|
||||
|
||||
return AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () => _leaveCall(),
|
||||
),
|
||||
title: _convName == null ? CircularProgressIndicator() : Text(_convName),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build widget body
|
||||
Widget _buildBody() {
|
||||
// Handle errors
|
||||
|
@ -1,20 +1,25 @@
|
||||
import 'package:comunic/ui/screens/call_screen.dart';
|
||||
import 'package:comunic/ui/widgets/custom_app_bar_size.dart';
|
||||
import 'package:comunic/ui/widgets/tablet_mode/calls/calls_area.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Call window widget
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
const _WindowSize = Size(500, 200);
|
||||
const _WindowSize = Size(450, 200);
|
||||
|
||||
class CallWindowWidget extends StatefulWidget {
|
||||
final int convID;
|
||||
final void Function() onClose;
|
||||
|
||||
const CallWindowWidget({
|
||||
Key key,
|
||||
this.convID,
|
||||
@required this.convID,
|
||||
@required this.onClose,
|
||||
}) : assert(convID != null),
|
||||
assert(onClose != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@ -43,6 +48,19 @@ class _CallWindowWidgetState extends State<CallWindowWidget> {
|
||||
child: Draggable(
|
||||
child: Card(
|
||||
child: CallScreen(
|
||||
buildCustomAppBar: (convName) => AppBarWrapper(
|
||||
height: 30,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
title: Text(convName == null ? tr("Loading...") : convName),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
iconSize: 16,
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: widget.onClose,
|
||||
)
|
||||
],
|
||||
)),
|
||||
convID: widget.convID,
|
||||
floatingButtons: false,
|
||||
),
|
||||
|
@ -19,8 +19,13 @@ class CallsAreaState extends State<CallsArea> {
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: _openCalls
|
||||
.map((convID, key) =>
|
||||
MapEntry(convID, CallWindowWidget(key: key, convID: convID)))
|
||||
.map((convID, key) => MapEntry(
|
||||
convID,
|
||||
CallWindowWidget(
|
||||
key: key,
|
||||
convID: convID,
|
||||
onClose: () => closeCall(convID),
|
||||
)))
|
||||
.values
|
||||
.toList(),
|
||||
);
|
||||
@ -34,4 +39,10 @@ class CallsAreaState extends State<CallsArea> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Close a call
|
||||
void closeCall(int convID) {
|
||||
if (_openCalls.containsKey(convID))
|
||||
setState(() => _openCalls.remove(convID));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user