mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-20 20:22:35 +01:00
a9275fc4f6
- defaultly save files on Android instead of share - add dedicated share button for files and images on Android - use ListTile instead of row to display file event - update file_picker_cross Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
78 lines
2.3 KiB
Dart
78 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
class MessageDownloadContent extends StatelessWidget {
|
|
final Event event;
|
|
final Color textColor;
|
|
|
|
const MessageDownloadContent(this.event, this.textColor, {Key? key})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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>[
|
|
ListTile(
|
|
leading: Icon(
|
|
Icons.file_download_outlined,
|
|
color: textColor,
|
|
),
|
|
title: Text(
|
|
filename,
|
|
maxLines: 1,
|
|
style: TextStyle(
|
|
color: textColor,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
trailing: PlatformInfos.isAndroid
|
|
? IconButton(
|
|
onPressed: () => event.shareFile(context),
|
|
tooltip: L10n.of(context)!.share,
|
|
icon: const Icon(Icons.share),
|
|
)
|
|
: null,
|
|
),
|
|
const Divider(),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
filetype,
|
|
style: TextStyle(
|
|
color: textColor.withAlpha(150),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
if (sizeString != null)
|
|
Text(
|
|
sizeString,
|
|
style: TextStyle(
|
|
color: textColor.withAlpha(150),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|