1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 23:09:21 +00:00
comunicmobile/lib/ui/widgets/tablet_mode/calls/calls_area.dart

49 lines
1.1 KiB
Dart
Raw Normal View History

2020-05-10 11:46:45 +00:00
import 'package:comunic/ui/widgets/tablet_mode/calls/call_window_widget.dart';
2020-05-09 17:45:07 +00:00
import 'package:flutter/material.dart';
/// Tablets mode calls area
///
/// @author Pierre Hubert
class CallsArea extends StatefulWidget {
const CallsArea({Key key}) : super(key: key);
@override
CallsAreaState createState() => CallsAreaState();
}
class CallsAreaState extends State<CallsArea> {
2020-05-10 11:46:45 +00:00
final _openCalls = Map<int, Key>();
2020-05-09 17:45:07 +00:00
@override
Widget build(BuildContext context) {
2020-05-10 11:46:45 +00:00
return Stack(
children: _openCalls
2020-05-10 13:00:26 +00:00
.map((convID, key) => MapEntry(
convID,
CallWindowWidget(
key: key,
convID: convID,
onClose: () => closeCall(convID),
)))
2020-05-10 11:46:45 +00:00
.values
.toList(),
);
2020-05-09 17:45:07 +00:00
}
/// Open a new call
void openCall(int convID) {
2020-05-10 11:46:45 +00:00
if (!_openCalls.containsKey(convID)) {
setState(() {
_openCalls[convID] = UniqueKey();
});
}
2020-05-09 17:45:07 +00:00
}
2020-05-10 13:00:26 +00:00
/// Close a call
void closeCall(int convID) {
if (_openCalls.containsKey(convID))
setState(() => _openCalls.remove(convID));
}
2020-05-09 17:45:07 +00:00
}