From fdc68fc5e196fa09e9579de751ee502916ac6dcf Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 27 Sep 2024 00:12:30 +0800 Subject: [PATCH] :lipstick: Optimize attachment editor controls --- assets/locales/zh_cn.json | 2 +- lib/models/attachment.dart | 2 +- lib/models/attachment.g.dart | 2 +- .../attachments/attachment_editor.dart | 119 +++++++++--------- pubspec.yaml | 2 +- 5 files changed, 66 insertions(+), 61 deletions(-) diff --git a/assets/locales/zh_cn.json b/assets/locales/zh_cn.json index d444d0a..7cfc434 100644 --- a/assets/locales/zh_cn.json +++ b/assets/locales/zh_cn.json @@ -459,5 +459,5 @@ "friendAdd": "添加好友", "blockUser": "屏蔽用户", "unblockUser": "解除屏蔽用户", - "learMoreAboutPerson": "了解关于 TA 的更多" + "learnMoreAboutPerson": "了解关于 TA 的更多" } diff --git a/lib/models/attachment.dart b/lib/models/attachment.dart index 2d351f2..bd6c00f 100644 --- a/lib/models/attachment.dart +++ b/lib/models/attachment.dart @@ -34,7 +34,7 @@ class Attachment { String alt; String mimetype; String hash; - String destination; + int destination; bool isAnalyzed; bool isUploaded; Map? metadata; diff --git a/lib/models/attachment.g.dart b/lib/models/attachment.g.dart index eb15493..5628ca5 100644 --- a/lib/models/attachment.g.dart +++ b/lib/models/attachment.g.dart @@ -36,7 +36,7 @@ Attachment _$AttachmentFromJson(Map json) => Attachment( alt: json['alt'] as String, mimetype: json['mimetype'] as String, hash: json['hash'] as String, - destination: json['destination'] as String, + destination: (json['destination'] as num).toInt(), isAnalyzed: json['is_analyzed'] as bool, isUploaded: json['is_uploaded'] as bool, metadata: json['metadata'] as Map?, diff --git a/lib/widgets/attachments/attachment_editor.dart b/lib/widgets/attachments/attachment_editor.dart index ea3c467..e764ccd 100644 --- a/lib/widgets/attachments/attachment_editor.dart +++ b/lib/widgets/attachments/attachment_editor.dart @@ -744,8 +744,8 @@ class _AttachmentEditorPopupState extends State { return IgnorePointer( ignoring: _uploadController.isUploading.value, child: Container( - height: 64, width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.all(8), decoration: BoxDecoration( border: Border( top: BorderSide( @@ -754,67 +754,72 @@ class _AttachmentEditorPopupState extends State { ), ), ), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Wrap( - spacing: 8, - runSpacing: 0, - alignment: WrapAlignment.center, - runAlignment: WrapAlignment.center, - children: [ - if ((PlatformInfo.isDesktop || - PlatformInfo.isIOS || - PlatformInfo.isWeb) && - !widget.imageOnly) - ElevatedButton.icon( - icon: const Icon(Icons.paste), - label: Text('attachmentAddClipboard'.tr), - style: const ButtonStyle(visualDensity: density), - onPressed: () => _pasteFileToUpload(), - ), - ElevatedButton.icon( - icon: const Icon(Icons.add_photo_alternate), - label: Text('attachmentAddGalleryPhoto'.tr), + child: Wrap( + spacing: 8, + runSpacing: 8, + alignment: WrapAlignment.center, + runAlignment: WrapAlignment.center, + children: [ + if ((PlatformInfo.isDesktop || + PlatformInfo.isIOS || + PlatformInfo.isWeb) && + !widget.imageOnly) + IconButton( + icon: const Icon(Icons.paste), + tooltip: 'attachmentAddClipboard'.tr, style: const ButtonStyle(visualDensity: density), - onPressed: () => _pickPhotoToUpload(), + color: Theme.of(context).colorScheme.primary, + onPressed: () => _pasteFileToUpload(), ), - if (!widget.imageOnly) - ElevatedButton.icon( - icon: const Icon(Icons.add_road), - label: Text('attachmentAddGalleryVideo'.tr), - style: const ButtonStyle(visualDensity: density), - onPressed: () => _pickVideoToUpload(), - ), - ElevatedButton.icon( - icon: const Icon(Icons.photo_camera_back), - label: Text('attachmentAddCameraPhoto'.tr), + IconButton( + icon: const Icon(Icons.add_photo_alternate), + tooltip: 'attachmentAddGalleryPhoto'.tr, + style: const ButtonStyle(visualDensity: density), + color: Theme.of(context).colorScheme.primary, + onPressed: () => _pickPhotoToUpload(), + ), + if (!widget.imageOnly) + IconButton( + icon: const Icon(Icons.add_road), + tooltip: 'attachmentAddGalleryVideo'.tr, style: const ButtonStyle(visualDensity: density), + color: Theme.of(context).colorScheme.primary, + onPressed: () => _pickVideoToUpload(), + ), + if (PlatformInfo.isMobile) + IconButton( + icon: const Icon(Icons.photo_camera_back), + tooltip: 'attachmentAddCameraPhoto'.tr, + style: const ButtonStyle(visualDensity: density), + color: Theme.of(context).colorScheme.primary, onPressed: () => _takeMediaToUpload(false), ), - if (!widget.imageOnly) - ElevatedButton.icon( - icon: const Icon(Icons.video_camera_back_outlined), - label: Text('attachmentAddCameraVideo'.tr), - style: const ButtonStyle(visualDensity: density), - onPressed: () => _takeMediaToUpload(true), - ), - if (!widget.imageOnly) - ElevatedButton.icon( - icon: const Icon(Icons.file_present_rounded), - label: Text('attachmentAddFile'.tr), - style: const ButtonStyle(visualDensity: density), - onPressed: () => _pickFileToUpload(), - ), - if (!widget.imageOnly) - ElevatedButton.icon( - icon: const Icon(Icons.link), - label: Text('attachmentAddFile'.tr), - style: const ButtonStyle(visualDensity: density), - onPressed: () => _linkAttachments(), - ), - ], - ).paddingSymmetric(horizontal: 12), - ), + if (!widget.imageOnly && PlatformInfo.isMobile) + IconButton( + icon: const Icon(Icons.video_camera_back_outlined), + tooltip: 'attachmentAddCameraVideo'.tr, + style: const ButtonStyle(visualDensity: density), + color: Theme.of(context).colorScheme.primary, + onPressed: () => _takeMediaToUpload(true), + ), + if (!widget.imageOnly) + IconButton( + icon: const Icon(Icons.file_present_rounded), + tooltip: 'attachmentAddFile'.tr, + style: const ButtonStyle(visualDensity: density), + color: Theme.of(context).colorScheme.primary, + onPressed: () => _pickFileToUpload(), + ), + if (!widget.imageOnly) + IconButton( + icon: const Icon(Icons.link), + tooltip: 'attachmentAddLink'.tr, + style: const ButtonStyle(visualDensity: density), + color: Theme.of(context).colorScheme.primary, + onPressed: () => _linkAttachments(), + ), + ], + ).paddingSymmetric(horizontal: 12), ) .animate( target: _uploadController.isUploading.value ? 0 : 1, diff --git a/pubspec.yaml b/pubspec.yaml index 2fa2a16..58fe2af 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: solian description: "The Solar Network App" publish_to: "none" -version: 1.2.4+1 +version: 1.2.4+2 environment: sdk: ">=3.3.4 <4.0.0"