From 2851780ddaaf42ffa69ccb65b0d96cf48361d10c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 26 Dec 2024 23:21:33 +0800 Subject: [PATCH] :lipstick: Better displaying of thumbnail on pending list --- lib/screens/post/post_editor.dart | 65 +++++++------------ lib/widgets/post/post_media_pending_list.dart | 39 +++++++++-- macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 8 +++ pubspec.yaml | 1 + 5 files changed, 68 insertions(+), 47 deletions(-) diff --git a/lib/screens/post/post_editor.dart b/lib/screens/post/post_editor.dart index 39dd462..16225e8 100644 --- a/lib/screens/post/post_editor.dart +++ b/lib/screens/post/post_editor.dart @@ -255,18 +255,13 @@ class _PostEditorScreenState extends State { if (_writeController.replyingPost != null) Column( children: [ - Theme( - data: Theme.of(context).copyWith( - dividerColor: Colors.transparent, - ), - child: ExpansionTile( - minTileHeight: 48, - leading: const Icon(Symbols.reply).padding(left: 4), - title: Text('postReplyingNotice') - .fontSize(15) - .tr(args: ['@${_writeController.replyingPost!.publisher.name}']), - children: [PostItem(data: _writeController.replyingPost!)], - ), + ExpansionTile( + minTileHeight: 48, + leading: const Icon(Symbols.reply).padding(left: 4), + title: Text('postReplyingNotice') + .fontSize(15) + .tr(args: ['@${_writeController.replyingPost!.publisher.name}']), + children: [PostItem(data: _writeController.replyingPost!)], ), const Divider(height: 1), ], @@ -275,22 +270,17 @@ class _PostEditorScreenState extends State { if (_writeController.repostingPost != null) Column( children: [ - Theme( - data: Theme.of(context).copyWith( - dividerColor: Colors.transparent, - ), - child: ExpansionTile( - minTileHeight: 48, - leading: const Icon(Symbols.forward).padding(left: 4), - title: Text('postRepostingNotice') - .fontSize(15) - .tr(args: ['@${_writeController.repostingPost!.publisher.name}']), - children: [ - PostItem( - data: _writeController.repostingPost!, - ) - ], - ), + ExpansionTile( + minTileHeight: 48, + leading: const Icon(Symbols.forward).padding(left: 4), + title: Text('postRepostingNotice') + .fontSize(15) + .tr(args: ['@${_writeController.repostingPost!.publisher.name}']), + children: [ + PostItem( + data: _writeController.repostingPost!, + ) + ], ), const Divider(height: 1), ], @@ -299,18 +289,13 @@ class _PostEditorScreenState extends State { if (_writeController.editingPost != null) Column( children: [ - Theme( - data: Theme.of(context).copyWith( - dividerColor: Colors.transparent, - ), - child: ExpansionTile( - minTileHeight: 48, - leading: const Icon(Symbols.edit_note).padding(left: 4), - title: Text('postEditingNotice') - .fontSize(15) - .tr(args: ['@${_writeController.editingPost!.publisher.name}']), - children: [PostItem(data: _writeController.editingPost!)], - ), + ExpansionTile( + minTileHeight: 48, + leading: const Icon(Symbols.edit_note).padding(left: 4), + title: Text('postEditingNotice') + .fontSize(15) + .tr(args: ['@${_writeController.editingPost!.publisher.name}']), + children: [PostItem(data: _writeController.editingPost!)], ), const Divider(height: 1), ], diff --git a/lib/widgets/post/post_media_pending_list.dart b/lib/widgets/post/post_media_pending_list.dart index afa5e5e..6dda66b 100644 --- a/lib/widgets/post/post_media_pending_list.dart +++ b/lib/widgets/post/post_media_pending_list.dart @@ -136,10 +136,7 @@ class PostMediaPendingList extends StatelessWidget { onSelected: () { onUpload!(idx); }), - if (media.attachment != null && - media.type == SnMediaType.image && - onPostSetThumbnail != null && - idx != -1) + if (media.attachment != null && media.type == SnMediaType.image && onPostSetThumbnail != null && idx != -1) MenuItem( label: 'attachmentSetAsPostThumbnail'.tr(), icon: Symbols.gallery_thumbnail, @@ -293,10 +290,38 @@ class _PostMediaPendingItem extends StatelessWidget { ), SnMediaType.video => Container( color: Theme.of(context).colorScheme.surfaceContainer, - child: media.attachment?.metadata['thumbnail'] != null - ? AutoResizeUniversalImage(sn.getAttachmentUrl(media.attachment?.metadata['thumbnail'])) - : const Icon(Symbols.videocam).center(), + child: Stack( + fit: StackFit.expand, + children: [ + if (media.attachment?.thumbnail != null) + AutoResizeUniversalImage(sn.getAttachmentUrl(media.attachment!.thumbnail!)), + const Icon(Symbols.videocam, color: Colors.white, shadows: [ + Shadow( + offset: Offset(1, 1), + blurRadius: 8.0, + color: Color.fromARGB(255, 0, 0, 0), + ), + ]), + ], + ), ), + SnMediaType.audio => Container( + color: Theme.of(context).colorScheme.surfaceContainer, + child: Stack( + fit: StackFit.expand, + children: [ + if (media.attachment?.thumbnail != null) + AutoResizeUniversalImage(sn.getAttachmentUrl(media.attachment!.thumbnail!)), + const Icon(Symbols.audio_file, color: Colors.white, shadows: [ + Shadow( + offset: Offset(1, 1), + blurRadius: 8.0, + color: Color.fromARGB(255, 0, 0, 0), + ), + ]), + ], + ), + ), _ => Container( color: Theme.of(context).colorScheme.surfaceContainer, child: const Icon(Symbols.docs).center(), diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 463e510..9cdba3d 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -28,6 +28,7 @@ import share_plus import shared_preferences_foundation import sqflite_darwin import url_launcher_macos +import video_compress import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -54,5 +55,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + VideoCompressPlugin.register(with: registry.registrar(forPlugin: "VideoCompressPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 09a41da..39c5356 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -2047,6 +2047,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.0" + video_compress: + dependency: "direct main" + description: + name: video_compress + sha256: "5b42d89f3970c956bad7a86c29682b0892c11a4ddf95ae6e29897ee28788e377" + url: "https://pub.dev" + source: hosted + version: "3.1.3" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bf33e88..bfe6dd2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -115,6 +115,7 @@ dependencies: fl_chart: ^0.70.0 flutter_webrtc: ^0.12.5+hotfix.1 slide_countdown: ^2.0.2 + video_compress: ^3.1.3 dev_dependencies: flutter_test: