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;
await voipPlugin!.voip.inviteToCall(room!.id, callType).catchError((e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString())
// Text(LocalizedExceptionExtension(context, e)),
),
SnackBar(content: Text((e as Object).toLocalizedString(context))),
);
});
} else {

View File

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

View File

@ -199,6 +199,13 @@ class MessageContent extends StatelessWidget {
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:
return _ButtonContent(
label: L10n.of(context)!
@ -227,11 +234,14 @@ class _ButtonContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return TextButton.icon(
return OutlinedButton.icon(
onPressed: onPressed,
icon: icon,
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:matrix/matrix.dart';
import 'package:pedantic/pedantic.dart';
import 'package:universal_html/html.dart' as darthtml;
import 'package:wakelock/wakelock.dart';
import 'package:fluffychat/utils/platform_infos.dart';
@ -174,12 +173,7 @@ class _MyCallingPage extends State<Calling> {
void _playCallSound() async {
const path = 'assets/sounds/call.ogg';
if (kIsWeb) {
darthtml.AudioElement()
..src = 'assets/$path'
..autoplay = true
..load();
} else if (PlatformInfos.isMobile) {
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isMacOS) {
await AssetsAudioPlayer.newPlayer().open(Audio(path));
} else {
Logs().w('Playing sound not implemented for this platform!');
@ -269,7 +263,6 @@ class _MyCallingPage extends State<Calling> {
}
void _hangUp() {
_playCallSound();
setState(() {
if (call != null && (call?.isRinging ?? false)) {
call?.reject();

View File

@ -1,7 +1,10 @@
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:fluffychat/utils/platform_infos.dart';
class UserMediaManager {
factory UserMediaManager() {
return _instance;
@ -11,17 +14,27 @@ class UserMediaManager {
static final UserMediaManager _instance = UserMediaManager._internal();
Future<void> startRingingTone() {
if (kIsWeb) {
throw 'Platform [web] not supported';
AssetsAudioPlayer? _assetsAudioPlayer;
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() {
if (kIsWeb) {
throw 'Platform [web] not supported';
Future<void> stopRingingTone() async {
if (PlatformInfos.isMobile) {
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
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
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 ${${plugin}_bundled_libraries})
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
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.3"
latlong2:
dependency: transitive
description:
@ -1107,7 +1107,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.0"
path_drawing:
dependency: transitive
description:
@ -1560,21 +1560,21 @@ packages:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.20.1"
version: "1.19.5"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.8"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.11"
version: "0.4.9"
timezone:
dependency: transitive
description:
@ -1898,5 +1898,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.16.0-100.0.dev <3.0.0"
dart: ">=2.15.1 <3.0.0"
flutter: ">=2.8.0"

View File

@ -12,9 +12,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
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 ${${plugin}_bundled_libraries})
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)