mirror of
				https://gitlab.com/famedly/fluffychat.git
				synced 2025-11-03 22:07:23 +01:00 
			
		
		
		
	Merge branch 'krille/audioandfiles' into 'main'
Krille/audioandfiles See merge request famedly/fluffychat!664
This commit is contained in:
		
						commit
						9490843eca
					
				@ -162,7 +162,7 @@ class _AudioPlayerState extends State<AudioPlayerWidget> {
 | 
			
		||||
      eventWaveForm.removeAt(i);
 | 
			
		||||
      i = (i + step) % AudioPlayerWidget.wavesCount;
 | 
			
		||||
    }
 | 
			
		||||
    return eventWaveForm;
 | 
			
		||||
    return eventWaveForm.map((i) => i > 1024 ? 1024 : i).toList();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  late final List<int> waveform;
 | 
			
		||||
 | 
			
		||||
@ -1,42 +1,75 @@
 | 
			
		||||
//@dart=2.12
 | 
			
		||||
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:matrix/matrix.dart';
 | 
			
		||||
 | 
			
		||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
 | 
			
		||||
import 'package:fluffychat/widgets/matrix.dart';
 | 
			
		||||
 | 
			
		||||
class MessageDownloadContent extends StatelessWidget {
 | 
			
		||||
  final Event event;
 | 
			
		||||
  final Color textColor;
 | 
			
		||||
 | 
			
		||||
  const MessageDownloadContent(this.event, this.textColor, {Key key})
 | 
			
		||||
  const MessageDownloadContent(this.event, this.textColor, {Key? key})
 | 
			
		||||
      : super(key: key);
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    final String filename = event.content.containsKey('filename')
 | 
			
		||||
        ? event.content['filename']
 | 
			
		||||
        : event.body;
 | 
			
		||||
    return Column(
 | 
			
		||||
      crossAxisAlignment: CrossAxisAlignment.start,
 | 
			
		||||
      mainAxisSize: MainAxisSize.min,
 | 
			
		||||
      children: <Widget>[
 | 
			
		||||
        TextButton.icon(
 | 
			
		||||
          onPressed: () => event.saveFile(context),
 | 
			
		||||
          icon: const Icon(Icons.download_outlined),
 | 
			
		||||
          label: Text(filename),
 | 
			
		||||
          style: event.senderId == Matrix.of(context).client.userID
 | 
			
		||||
              ? TextButton.styleFrom(primary: textColor)
 | 
			
		||||
              : null,
 | 
			
		||||
        ),
 | 
			
		||||
        if (event.sizeString != null)
 | 
			
		||||
          Text(
 | 
			
		||||
            event.sizeString,
 | 
			
		||||
            style: TextStyle(
 | 
			
		||||
              color: textColor,
 | 
			
		||||
            ),
 | 
			
		||||
    final filename = event.content.tryGet<String>('filename') ?? event.body;
 | 
			
		||||
    final filetype = (filename.contains('.')
 | 
			
		||||
        ? filename.split('.').last.toUpperCase()
 | 
			
		||||
        : event.content
 | 
			
		||||
                .tryGetMap<String, dynamic>('info')
 | 
			
		||||
                ?.tryGet<String>('mimetype')
 | 
			
		||||
                ?.toUpperCase() ??
 | 
			
		||||
            'UNKNOWN');
 | 
			
		||||
    final sizeString = event.sizeString;
 | 
			
		||||
    return InkWell(
 | 
			
		||||
      onTap: () => event.saveFile(context),
 | 
			
		||||
      child: Column(
 | 
			
		||||
        crossAxisAlignment: CrossAxisAlignment.start,
 | 
			
		||||
        mainAxisSize: MainAxisSize.min,
 | 
			
		||||
        children: <Widget>[
 | 
			
		||||
          Row(
 | 
			
		||||
            children: [
 | 
			
		||||
              Icon(
 | 
			
		||||
                Icons.file_download_outlined,
 | 
			
		||||
                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,
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
            ],
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -98,7 +98,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
 | 
			
		||||
        : (amplitudeTimeline.length / waveCount).round();
 | 
			
		||||
    final waveform = <int>[];
 | 
			
		||||
    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>(
 | 
			
		||||
      RecordingResult(
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user