mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
fix: Video calls
This commit is contained in:
parent
a5e95539e3
commit
672eca6302
@ -5,9 +5,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
|||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
import '../app_config.dart';
|
|
||||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||||
import 'matrix.dart';
|
import 'matrix.dart';
|
||||||
|
|
||||||
@ -30,19 +28,6 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void startCallAction(BuildContext context) async {
|
|
||||||
final url =
|
|
||||||
'${AppConfig.jitsiInstance}${Uri.encodeComponent(widget.room.id.localpart)}';
|
|
||||||
final success = await showFutureLoadingDialog(
|
|
||||||
context: context,
|
|
||||||
future: () => widget.room.sendEvent({
|
|
||||||
'msgtype': Matrix.callNamespace,
|
|
||||||
'body': url,
|
|
||||||
}));
|
|
||||||
if (success.error != null) return;
|
|
||||||
await launch(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
notificationChangeSub ??= Matrix.of(context)
|
notificationChangeSub ??= Matrix.of(context)
|
||||||
@ -110,9 +95,6 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||||||
future: () =>
|
future: () =>
|
||||||
widget.room.setPushRuleState(PushRuleState.notify));
|
widget.room.setPushRuleState(PushRuleState.notify));
|
||||||
break;
|
break;
|
||||||
case 'call':
|
|
||||||
startCallAction(context);
|
|
||||||
break;
|
|
||||||
case 'details':
|
case 'details':
|
||||||
if (AdaptivePageLayout.of(context).viewDataStack.length < 3) {
|
if (AdaptivePageLayout.of(context).viewDataStack.length < 3) {
|
||||||
await AdaptivePageLayout.of(context)
|
await AdaptivePageLayout.of(context)
|
||||||
|
@ -320,14 +320,6 @@ class MatrixState extends State<Matrix> {
|
|||||||
LoadingDialog.defaultBackLabel = L10n.of(context).close;
|
LoadingDialog.defaultBackLabel = L10n.of(context).close;
|
||||||
LoadingDialog.defaultOnError = (Object e) => e.toLocalizedString(context);
|
LoadingDialog.defaultOnError = (Object e) => e.toLocalizedString(context);
|
||||||
|
|
||||||
onJitsiCallSub ??= client.onEvent.stream
|
|
||||||
.where((e) =>
|
|
||||||
e.type == EventUpdateType.timeline &&
|
|
||||||
e.eventType == 'm.room.message' &&
|
|
||||||
e.content['content']['msgtype'] == Matrix.callNamespace &&
|
|
||||||
e.content['sender'] != client.userID)
|
|
||||||
.listen(onJitsiCall);
|
|
||||||
|
|
||||||
onRoomKeyRequestSub ??=
|
onRoomKeyRequestSub ??=
|
||||||
client.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async {
|
client.onRoomKeyRequest.stream.listen((RoomKeyRequest request) async {
|
||||||
final room = request.room;
|
final room = request.room;
|
||||||
@ -437,7 +429,7 @@ class MatrixState extends State<Matrix> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
onRoomKeyRequestSub?.cancel();
|
onRoomKeyRequestSub?.cancel();
|
||||||
onKeyVerificationRequestSub?.cancel();
|
onKeyVerificationRequestSub?.cancel();
|
||||||
onJitsiCallSub?.cancel();
|
onLoginStateChanged?.cancel();
|
||||||
onNotification?.cancel();
|
onNotification?.cancel();
|
||||||
onFocusSub?.cancel();
|
onFocusSub?.cancel();
|
||||||
onBlurSub?.cancel();
|
onBlurSub?.cancel();
|
||||||
|
@ -147,7 +147,7 @@ class MessageContent extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(Icons.phone_outlined),
|
Icon(Icons.phone_outlined, color: Colors.green),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text(L10n.of(context).videoCall),
|
Text(L10n.of(context).videoCall),
|
||||||
],
|
],
|
||||||
|
@ -7,6 +7,7 @@ import 'package:adaptive_page_layout/adaptive_page_layout.dart';
|
|||||||
import 'package:emoji_picker/emoji_picker.dart';
|
import 'package:emoji_picker/emoji_picker.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:file_picker_cross/file_picker_cross.dart';
|
import 'package:file_picker_cross/file_picker_cross.dart';
|
||||||
|
import 'package:fluffychat/app_config.dart';
|
||||||
import 'package:fluffychat/components/avatar.dart';
|
import 'package:fluffychat/components/avatar.dart';
|
||||||
import 'package:fluffychat/components/chat_settings_popup_menu.dart';
|
import 'package:fluffychat/components/chat_settings_popup_menu.dart';
|
||||||
import 'package:fluffychat/components/connection_status_header.dart';
|
import 'package:fluffychat/components/connection_status_header.dart';
|
||||||
@ -33,6 +34,7 @@ import 'package:pedantic/pedantic.dart';
|
|||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:swipe_to_action/swipe_to_action.dart';
|
import 'package:swipe_to_action/swipe_to_action.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../components/dialogs/send_file_dialog.dart';
|
import '../components/dialogs/send_file_dialog.dart';
|
||||||
import '../components/input_bar.dart';
|
import '../components/input_bar.dart';
|
||||||
@ -89,6 +91,20 @@ class _ChatState extends State<Chat> {
|
|||||||
|
|
||||||
bool get _canLoadMore => timeline.events.last.type != EventTypes.RoomCreate;
|
bool get _canLoadMore => timeline.events.last.type != EventTypes.RoomCreate;
|
||||||
|
|
||||||
|
void startCallAction(BuildContext context) async {
|
||||||
|
final url =
|
||||||
|
'${AppConfig.jitsiInstance}${Uri.encodeComponent(Matrix.of(context).client.generateUniqueTransactionId())}';
|
||||||
|
|
||||||
|
final success = await showFutureLoadingDialog(
|
||||||
|
context: context,
|
||||||
|
future: () => room.sendEvent({
|
||||||
|
'msgtype': Matrix.callNamespace,
|
||||||
|
'body': url,
|
||||||
|
}));
|
||||||
|
if (success.error != null) return;
|
||||||
|
await launch(url);
|
||||||
|
}
|
||||||
|
|
||||||
void requestHistory() async {
|
void requestHistory() async {
|
||||||
if (_canLoadMore) {
|
if (_canLoadMore) {
|
||||||
try {
|
try {
|
||||||
@ -554,7 +570,13 @@ class _ChatState extends State<Chat> {
|
|||||||
onPressed: () => redactEventsAction(context),
|
onPressed: () => redactEventsAction(context),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
: <Widget>[ChatSettingsPopupMenu(room, !room.isDirectChat)],
|
: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.call_outlined),
|
||||||
|
onPressed: () => startCallAction(context),
|
||||||
|
),
|
||||||
|
ChatSettingsPopupMenu(room, !room.isDirectChat),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: showScrollDownButton
|
floatingActionButton: showScrollDownButton
|
||||||
? Padding(
|
? Padding(
|
||||||
|
Loading…
Reference in New Issue
Block a user