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 {
|
2022-03-10 18:39:57 +00:00
|
|
|
const CallsArea({Key? key}) : super(key: key);
|
2020-05-09 17:45:07 +00:00
|
|
|
|
|
|
|
@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
|
|
|
}
|