mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-22 13:32:37 +01:00
fix: AudioPlayer color and remove web workaround
This commit is contained in:
parent
b2d250c5ef
commit
01093c7e3d
@ -13,6 +13,7 @@ abstract class AppConfig {
|
|||||||
static const bool enableRegistration = true;
|
static const bool enableRegistration = true;
|
||||||
static const Color primaryColor = Color(0xFF5625BA);
|
static const Color primaryColor = Color(0xFF5625BA);
|
||||||
static const Color primaryColorLight = Color(0xFFCCBDEA);
|
static const Color primaryColorLight = Color(0xFFCCBDEA);
|
||||||
|
static const Color secondaryColor = Color(0xFF41a2bc);
|
||||||
static String _privacyUrl = 'https://fluffychat.im/en/privacy.html';
|
static String _privacyUrl = 'https://fluffychat.im/en/privacy.html';
|
||||||
static String get privacyUrl => _privacyUrl;
|
static String get privacyUrl => _privacyUrl;
|
||||||
static const String appId = 'im.fluffychat.FluffyChat';
|
static const String appId = 'im.fluffychat.FluffyChat';
|
||||||
|
@ -37,6 +37,7 @@ abstract class FluffyThemes {
|
|||||||
colorScheme: ThemeData.light().colorScheme.copyWith(
|
colorScheme: ThemeData.light().colorScheme.copyWith(
|
||||||
primary: AppConfig.primaryColor,
|
primary: AppConfig.primaryColor,
|
||||||
secondary: AppConfig.primaryColor,
|
secondary: AppConfig.primaryColor,
|
||||||
|
secondaryVariant: AppConfig.secondaryColor,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
secondaryHeaderColor: lighten(AppConfig.primaryColor, .51),
|
secondaryHeaderColor: lighten(AppConfig.primaryColor, .51),
|
||||||
@ -121,6 +122,7 @@ abstract class FluffyThemes {
|
|||||||
colorScheme: ThemeData.dark().colorScheme.copyWith(
|
colorScheme: ThemeData.dark().colorScheme.copyWith(
|
||||||
primary: AppConfig.primaryColorLight,
|
primary: AppConfig.primaryColorLight,
|
||||||
secondary: AppConfig.primaryColorLight,
|
secondary: AppConfig.primaryColorLight,
|
||||||
|
secondaryVariant: AppConfig.secondaryColor,
|
||||||
),
|
),
|
||||||
secondaryHeaderColor: FluffyThemes.darken(AppConfig.primaryColorLight, .65),
|
secondaryHeaderColor: FluffyThemes.darken(AppConfig.primaryColorLight, .65),
|
||||||
textTheme: Typography.material2018().white.merge(fallback_text_theme),
|
textTheme: Typography.material2018().white.merge(fallback_text_theme),
|
||||||
|
@ -3,16 +3,14 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:audioplayers/audioplayers.dart';
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:fluffychat/utils/sentry_controller.dart';
|
import 'package:fluffychat/utils/sentry_controller.dart';
|
||||||
import 'package:fluffychat/widgets/event_content/message_download_content.dart';
|
import 'package:fluffychat/widgets/event_content/message_download_content.dart';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:path_provider/path_provider.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 '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';
|
import '../../utils/matrix_sdk_extensions.dart/event_extension.dart';
|
||||||
|
|
||||||
class AudioPlayerWidget extends StatefulWidget {
|
class AudioPlayerWidget extends StatefulWidget {
|
||||||
@ -45,22 +43,6 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
|
|||||||
|
|
||||||
File audioFile;
|
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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
if (audioPlayer.state == AudioPlayerState.PLAYING) {
|
if (audioPlayer.state == AudioPlayerState.PLAYING) {
|
||||||
@ -149,17 +131,7 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (kIsWeb) {
|
if (PlatformInfos.isLinux || PlatformInfos.isWindows) {
|
||||||
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'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return MessageDownloadContent(widget.event, widget.color);
|
return MessageDownloadContent(widget.event, widget.color);
|
||||||
}
|
}
|
||||||
return Row(
|
return Row(
|
||||||
@ -190,6 +162,8 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Slider(
|
child: Slider(
|
||||||
|
activeColor: Theme.of(context).colorScheme.secondaryVariant,
|
||||||
|
inactiveColor: widget.color.withAlpha(64),
|
||||||
value: currentPosition,
|
value: currentPosition,
|
||||||
onChanged: (double position) =>
|
onChanged: (double position) =>
|
||||||
audioPlayer.seek(Duration(milliseconds: position.toInt())),
|
audioPlayer.seek(Duration(milliseconds: position.toInt())),
|
||||||
|
Loading…
Reference in New Issue
Block a user