chore: Follow up send file dialog for images

pull/1503/head
Krille 12 months ago
parent a1f4462593
commit 363eabbe1c
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -1689,6 +1689,13 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"sendImages": "Send {count} image",
"@sendImages": {
"type": "text",
"placeholders": {
"count": {}
}
},
"sendMessages": "Send messages", "sendMessages": "Send messages",
"@sendMessages": { "@sendMessages": {
"type": "text", "type": "text",
@ -2806,7 +2813,7 @@
"name": "Name", "name": "Name",
"version": "Version", "version": "Version",
"website": "Website", "website": "Website",
"sendUncompressed": "Send uncompressed", "compress": "Compress",
"boldText": "Bold text", "boldText": "Bold text",
"italicText": "Italic text", "italicText": "Italic text",
"strikeThrough": "Strikethrough", "strikeThrough": "Strikethrough",

@ -163,7 +163,11 @@ class SendFileDialogState extends State<SendFileDialog> {
.toUpperCase(); .toUpperCase();
if (uniqueMimeType?.startsWith('image') ?? false) { if (uniqueMimeType?.startsWith('image') ?? false) {
if (widget.files.length == 1) {
sendStr = L10n.of(context).sendImage; sendStr = L10n.of(context).sendImage;
} else {
sendStr = L10n.of(context).sendImages(widget.files.length);
}
} else if (uniqueMimeType?.startsWith('audio') ?? false) { } else if (uniqueMimeType?.startsWith('audio') ?? false) {
sendStr = L10n.of(context).sendAudio; sendStr = L10n.of(context).sendAudio;
} else if (uniqueMimeType?.startsWith('video') ?? false) { } else if (uniqueMimeType?.startsWith('video') ?? false) {
@ -187,25 +191,33 @@ class SendFileDialogState extends State<SendFileDialog> {
if (uniqueMimeType?.startsWith('image') ?? false) if (uniqueMimeType?.startsWith('image') ?? false)
Padding( Padding(
padding: const EdgeInsets.only(bottom: 16.0), padding: const EdgeInsets.only(bottom: 16.0),
child: SizedBox(
height: 256,
child: ListView.builder(
itemCount: widget.files.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, i) => Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Material( child: Material(
borderRadius: borderRadius: BorderRadius.circular(
BorderRadius.circular(AppConfig.borderRadius / 2), AppConfig.borderRadius / 2,
),
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
child: kIsWeb child: kIsWeb
? Image.network( ? Image.network(
widget.files.first.path, widget.files[i].path,
fit: BoxFit.contain, height: 256,
height: 156,
) )
: Image.file( : Image.file(
File(widget.files.first.path), File(widget.files[i].path),
fit: BoxFit.contain, height: 256,
height: 156, ),
),
),
), ),
), ),
), ),
if (uniqueMimeType?.startsWith('image') != true || if (uniqueMimeType?.startsWith('image') != true)
widget.files.length > 1)
Padding( Padding(
padding: const EdgeInsets.only(bottom: 16.0), padding: const EdgeInsets.only(bottom: 16.0),
child: Row( child: Row(
@ -253,19 +265,19 @@ class SendFileDialogState extends State<SendFileDialog> {
if ({TargetPlatform.iOS, TargetPlatform.macOS} if ({TargetPlatform.iOS, TargetPlatform.macOS}
.contains(theme.platform)) .contains(theme.platform))
CupertinoSwitch( CupertinoSwitch(
value: !compress, value: compress,
onChanged: uniqueMimeType.startsWith('video') && onChanged: uniqueMimeType.startsWith('video') &&
!PlatformInfos.isMobile !PlatformInfos.isMobile
? null ? null
: (v) => setState(() => compress = !v), : (v) => setState(() => compress = v),
) )
else else
Switch.adaptive( Switch.adaptive(
value: !compress, value: compress,
onChanged: uniqueMimeType.startsWith('video') && onChanged: uniqueMimeType.startsWith('video') &&
!PlatformInfos.isMobile !PlatformInfos.isMobile
? null ? null
: (v) => setState(() => compress = !v), : (v) => setState(() => compress = v),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
Expanded( Expanded(
@ -277,12 +289,13 @@ class SendFileDialogState extends State<SendFileDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
L10n.of(context).sendUncompressed, L10n.of(context).compress,
style: theme.textTheme.titleMedium, style: theme.textTheme.titleMedium,
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
], ],
), ),
if (!compress)
Text( Text(
' ($sizeString)', ' ($sizeString)',
style: theme.textTheme.labelSmall, style: theme.textTheme.labelSmall,

Loading…
Cancel
Save