feat: Display file description on all file events
This commit is contained in:
parent
a5dc6db4e8
commit
f68a9de6bf
7 changed files with 213 additions and 142 deletions
|
|
@ -4,17 +4,16 @@ import 'dart:io';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:opus_caf_converter_dart/opus_caf_converter_dart.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/pages/chat/events/html_message.dart';
|
||||
import 'package:fluffychat/utils/error_reporter.dart';
|
||||
import 'package:fluffychat/utils/file_description.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import '../../../utils/matrix_sdk_extensions/event_extension.dart';
|
||||
|
||||
class AudioPlayerWidget extends StatefulWidget {
|
||||
|
|
@ -240,17 +239,11 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
final statusText = this.statusText ??= _durationString ?? '00:00';
|
||||
final audioPlayer = this.audioPlayer;
|
||||
|
||||
final body = widget.event.content.tryGet<String>('body') ??
|
||||
widget.event.content.tryGet<String>('filename');
|
||||
final displayBody = body != null &&
|
||||
body.isNotEmpty &&
|
||||
widget.event.content['org.matrix.msc1767.audio'] == null;
|
||||
final fileDescription = widget.event.fileDescription;
|
||||
|
||||
final wavePosition =
|
||||
(currentPosition / maxPosition) * AudioPlayerWidget.wavesCount;
|
||||
|
||||
final fontSize = 12 * AppConfig.fontSizeFactor;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Column(
|
||||
|
|
@ -380,22 +373,12 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (displayBody) ...[
|
||||
if (fileDescription != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Linkify(
|
||||
text: body,
|
||||
style: TextStyle(
|
||||
color: widget.color,
|
||||
fontSize: fontSize,
|
||||
),
|
||||
options: const LinkifyOptions(humanize: false),
|
||||
linkStyle: TextStyle(
|
||||
color: widget.color.withAlpha(150),
|
||||
fontSize: fontSize,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: widget.color.withAlpha(150),
|
||||
),
|
||||
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
||||
HtmlMessage(
|
||||
html: fileDescription,
|
||||
textColor: widget.color,
|
||||
room: widget.event.room,
|
||||
),
|
||||
],
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue