From 01093c7e3d900d1d2aa1d951a76fe44c1b3f4c3c Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 31 May 2021 17:43:27 +0200 Subject: [PATCH] fix: AudioPlayer color and remove web workaround --- lib/config/app_config.dart | 1 + lib/config/themes.dart | 2 ++ lib/widgets/event_content/audio_player.dart | 34 +++------------------ 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index 962aa4db..1d82cfd7 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -13,6 +13,7 @@ abstract class AppConfig { static const bool enableRegistration = true; static const Color primaryColor = Color(0xFF5625BA); static const Color primaryColorLight = Color(0xFFCCBDEA); + static const Color secondaryColor = Color(0xFF41a2bc); static String _privacyUrl = 'https://fluffychat.im/en/privacy.html'; static String get privacyUrl => _privacyUrl; static const String appId = 'im.fluffychat.FluffyChat'; diff --git a/lib/config/themes.dart b/lib/config/themes.dart index ba39fee6..9db493b4 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -37,6 +37,7 @@ abstract class FluffyThemes { colorScheme: ThemeData.light().colorScheme.copyWith( primary: AppConfig.primaryColor, secondary: AppConfig.primaryColor, + secondaryVariant: AppConfig.secondaryColor, ), backgroundColor: Colors.white, secondaryHeaderColor: lighten(AppConfig.primaryColor, .51), @@ -121,6 +122,7 @@ abstract class FluffyThemes { colorScheme: ThemeData.dark().colorScheme.copyWith( primary: AppConfig.primaryColorLight, secondary: AppConfig.primaryColorLight, + secondaryVariant: AppConfig.secondaryColor, ), secondaryHeaderColor: FluffyThemes.darken(AppConfig.primaryColorLight, .65), textTheme: Typography.material2018().white.merge(fallback_text_theme), diff --git a/lib/widgets/event_content/audio_player.dart b/lib/widgets/event_content/audio_player.dart index 1788f001..22f0c889 100644 --- a/lib/widgets/event_content/audio_player.dart +++ b/lib/widgets/event_content/audio_player.dart @@ -3,16 +3,14 @@ import 'dart:io'; import 'package:audioplayers/audioplayers.dart'; import 'package:famedlysdk/famedlysdk.dart'; +import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/sentry_controller.dart'; import 'package:fluffychat/widgets/event_content/message_download_content.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:universal_html/html.dart' as html; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import '../../utils/ui_fake.dart' if (dart.library.html) 'dart:ui' as ui; -import '../matrix.dart'; import '../../utils/matrix_sdk_extensions.dart/event_extension.dart'; class AudioPlayerWidget extends StatefulWidget { @@ -45,22 +43,6 @@ class _AudioPlayerState extends State { File audioFile; - String webSrcUrl; - - @override - void initState() { - super.initState(); - if (kIsWeb) { - ui.platformViewRegistry.registerViewFactory( - 'web_audio_player', - (int viewId) => html.AudioElement() - ..src = webSrcUrl - ..autoplay = false - ..controls = true - ..style.border = 'none'); - } - } - @override void dispose() { if (audioPlayer.state == AudioPlayerState.PLAYING) { @@ -149,17 +131,7 @@ class _AudioPlayerState extends State { @override Widget build(BuildContext context) { - if (kIsWeb) { - if (widget.event.content['url'] is String) { - webSrcUrl = Uri.parse(widget.event.content['url']) - .getDownloadLink(Matrix.of(context).client) - .toString(); - return Container( - height: 50, - width: 300, - child: HtmlElementView(viewType: 'web_audio_player'), - ); - } + if (PlatformInfos.isLinux || PlatformInfos.isWindows) { return MessageDownloadContent(widget.event, widget.color); } return Row( @@ -190,6 +162,8 @@ class _AudioPlayerState extends State { ), Expanded( child: Slider( + activeColor: Theme.of(context).colorScheme.secondaryVariant, + inactiveColor: widget.color.withAlpha(64), value: currentPosition, onChanged: (double position) => audioPlayer.seek(Duration(milliseconds: position.toInt())),