Merge branch 'krille/audioandfiles' into 'main'

Krille/audioandfiles

See merge request famedly/fluffychat!664
This commit is contained in:
Krille Fear 2022-01-02 09:29:52 +00:00
commit 9490843eca
3 changed files with 59 additions and 26 deletions

View File

@ -162,7 +162,7 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
eventWaveForm.removeAt(i); eventWaveForm.removeAt(i);
i = (i + step) % AudioPlayerWidget.wavesCount; i = (i + step) % AudioPlayerWidget.wavesCount;
} }
return eventWaveForm; return eventWaveForm.map((i) => i > 1024 ? 1024 : i).toList();
} }
late final List<int> waveform; late final List<int> waveform;

View File

@ -1,42 +1,75 @@
//@dart=2.12
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
import 'package:fluffychat/widgets/matrix.dart';
class MessageDownloadContent extends StatelessWidget { class MessageDownloadContent extends StatelessWidget {
final Event event; final Event event;
final Color textColor; final Color textColor;
const MessageDownloadContent(this.event, this.textColor, {Key key}) const MessageDownloadContent(this.event, this.textColor, {Key? key})
: super(key: key); : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String filename = event.content.containsKey('filename') final filename = event.content.tryGet<String>('filename') ?? event.body;
? event.content['filename'] final filetype = (filename.contains('.')
: event.body; ? filename.split('.').last.toUpperCase()
return Column( : event.content
crossAxisAlignment: CrossAxisAlignment.start, .tryGetMap<String, dynamic>('info')
mainAxisSize: MainAxisSize.min, ?.tryGet<String>('mimetype')
children: <Widget>[ ?.toUpperCase() ??
TextButton.icon( 'UNKNOWN');
onPressed: () => event.saveFile(context), final sizeString = event.sizeString;
icon: const Icon(Icons.download_outlined), return InkWell(
label: Text(filename), onTap: () => event.saveFile(context),
style: event.senderId == Matrix.of(context).client.userID child: Column(
? TextButton.styleFrom(primary: textColor) crossAxisAlignment: CrossAxisAlignment.start,
: null, mainAxisSize: MainAxisSize.min,
), children: <Widget>[
if (event.sizeString != null) Row(
Text( children: [
event.sizeString, Icon(
style: TextStyle( Icons.file_download_outlined,
color: textColor, color: Theme.of(context).colorScheme.secondary,
), ),
const SizedBox(width: 8),
Expanded(
child: Text(
filename,
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
],
), ),
], const Divider(),
Row(
children: [
Text(
filetype,
style: TextStyle(
color: textColor,
),
),
const Spacer(),
if (sizeString != null)
Text(
sizeString,
style: TextStyle(
color: textColor,
),
),
],
),
],
),
); );
} }
} }

View File

@ -98,7 +98,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
: (amplitudeTimeline.length / waveCount).round(); : (amplitudeTimeline.length / waveCount).round();
final waveform = <int>[]; final waveform = <int>[];
for (var i = 0; i < amplitudeTimeline.length; i += step) { for (var i = 0; i < amplitudeTimeline.length; i += step) {
waveform.add((amplitudeTimeline[i] / waveCount * 1024).round()); waveform.add((amplitudeTimeline[i] / 100 * 1024).round());
} }
Navigator.of(context, rootNavigator: false).pop<RecordingResult>( Navigator.of(context, rootNavigator: false).pop<RecordingResult>(
RecordingResult( RecordingResult(