chore: Better call UX sounds and timeline design

This commit is contained in:
Krille Fear 2022-02-19 11:05:21 +01:00
parent 4aa6ad4621
commit 5df9dc0db8
9 changed files with 50 additions and 45 deletions

BIN
assets/sounds/phone.ogg Normal file

Binary file not shown.

View File

@ -990,9 +990,7 @@ class ChatController extends State<Chat> {
final voipPlugin = Matrix.of(context).voipPlugin; final voipPlugin = Matrix.of(context).voipPlugin;
await voipPlugin!.voip.inviteToCall(room!.id, callType).catchError((e) { await voipPlugin!.voip.inviteToCall(room!.id, callType).catchError((e) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString()) SnackBar(content: Text((e as Object).toLocalizedString(context))),
// Text(LocalizedExceptionExtension(context, e)),
),
); );
}); });
} else { } else {

View File

@ -45,8 +45,15 @@ class Message extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (![EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted] if (!{
.contains(event.type)) { EventTypes.Message,
EventTypes.Sticker,
EventTypes.Encrypted,
EventTypes.CallInvite
}.contains(event.type)) {
if (event.type.startsWith('m.call.')) {
return Container();
}
return StateMessage(event, unfold: unfold); return StateMessage(event, unfold: unfold);
} }

View File

@ -199,6 +199,13 @@ class MessageContent extends StatelessWidget {
onLinkTap: (url) => UrlLauncher(context, url).launchUrl(), onLinkTap: (url) => UrlLauncher(context, url).launchUrl(),
); );
} }
case EventTypes.CallInvite:
return _ButtonContent(
label: L10n.of(context)!.startedACall(event.sender.calcDisplayname()),
icon: const Icon(Icons.phone_outlined),
textColor: buttonTextColor,
onPressed: () => onInfoTab!(event),
);
default: default:
return _ButtonContent( return _ButtonContent(
label: L10n.of(context)! label: L10n.of(context)!
@ -227,11 +234,14 @@ class _ButtonContent extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return TextButton.icon( return OutlinedButton.icon(
onPressed: onPressed, onPressed: onPressed,
icon: icon, icon: icon,
label: Text(label, overflow: TextOverflow.ellipsis), label: Text(label, overflow: TextOverflow.ellipsis),
style: TextButton.styleFrom(primary: textColor), style: OutlinedButton.styleFrom(
primary: textColor,
backgroundColor: Colors.white.withAlpha(64),
),
); );
} }
} }

View File

@ -26,7 +26,6 @@ import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:pedantic/pedantic.dart'; import 'package:pedantic/pedantic.dart';
import 'package:universal_html/html.dart' as darthtml;
import 'package:wakelock/wakelock.dart'; import 'package:wakelock/wakelock.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
@ -174,12 +173,7 @@ class _MyCallingPage extends State<Calling> {
void _playCallSound() async { void _playCallSound() async {
const path = 'assets/sounds/call.ogg'; const path = 'assets/sounds/call.ogg';
if (kIsWeb) { if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isMacOS) {
darthtml.AudioElement()
..src = 'assets/$path'
..autoplay = true
..load();
} else if (PlatformInfos.isMobile) {
await AssetsAudioPlayer.newPlayer().open(Audio(path)); await AssetsAudioPlayer.newPlayer().open(Audio(path));
} else { } else {
Logs().w('Playing sound not implemented for this platform!'); Logs().w('Playing sound not implemented for this platform!');
@ -269,7 +263,6 @@ class _MyCallingPage extends State<Calling> {
} }
void _hangUp() { void _hangUp() {
_playCallSound();
setState(() { setState(() {
if (call != null && (call?.isRinging ?? false)) { if (call != null && (call?.isRinging ?? false)) {
call?.reject(); call?.reject();

View File

@ -1,7 +1,10 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:flutter_ringtone_player/flutter_ringtone_player.dart'; import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';
import 'package:fluffychat/utils/platform_infos.dart';
class UserMediaManager { class UserMediaManager {
factory UserMediaManager() { factory UserMediaManager() {
return _instance; return _instance;
@ -11,17 +14,27 @@ class UserMediaManager {
static final UserMediaManager _instance = UserMediaManager._internal(); static final UserMediaManager _instance = UserMediaManager._internal();
Future<void> startRingingTone() { AssetsAudioPlayer? _assetsAudioPlayer;
if (kIsWeb) {
throw 'Platform [web] not supported'; Future<void> startRingingTone() async {
if (PlatformInfos.isMobile) {
await FlutterRingtonePlayer.playRingtone(volume: 80);
} else if ((kIsWeb || PlatformInfos.isMacOS) &&
_assetsAudioPlayer != null) {
const path = 'assets/sounds/phone.ogg';
final player = _assetsAudioPlayer = AssetsAudioPlayer.newPlayer();
await player.open(Audio(path),
autoStart: true, loopMode: LoopMode.playlist);
} }
return FlutterRingtonePlayer.playRingtone(volume: 80); return;
} }
Future<void> stopRingingTone() { Future<void> stopRingingTone() async {
if (kIsWeb) { if (PlatformInfos.isMobile) {
throw 'Platform [web] not supported'; await FlutterRingtonePlayer.stop();
} }
return FlutterRingtonePlayer.stop(); await _assetsAudioPlayer?.stop();
_assetsAudioPlayer = null;
return;
} }
} }

View File

@ -10,9 +10,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux url_launcher_linux
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST}) foreach(plugin ${FLUTTER_PLUGIN_LIST})
@ -21,8 +18,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin) endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -890,7 +890,7 @@ packages:
name: js name: js
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.4" version: "0.6.3"
latlong2: latlong2:
dependency: transitive dependency: transitive
description: description:
@ -1107,7 +1107,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.0"
path_drawing: path_drawing:
dependency: transitive dependency: transitive
description: description:
@ -1560,21 +1560,21 @@ packages:
name: test name: test
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.20.1" version: "1.19.5"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.8"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.11" version: "0.4.9"
timezone: timezone:
dependency: transitive dependency: transitive
description: description:
@ -1898,5 +1898,5 @@ packages:
source: hosted source: hosted
version: "3.1.0" version: "3.1.0"
sdks: sdks:
dart: ">=2.16.0-100.0.dev <3.0.0" dart: ">=2.15.1 <3.0.0"
flutter: ">=2.8.0" flutter: ">=2.8.0"

View File

@ -12,9 +12,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows url_launcher_windows
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST}) foreach(plugin ${FLUTTER_PLUGIN_LIST})
@ -23,8 +20,3 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin) endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)