💄 Better displaying of thumbnail on pending list

This commit is contained in:
LittleSheep 2024-12-26 23:21:33 +08:00
parent 00fd58fb97
commit 2851780dda
5 changed files with 68 additions and 47 deletions

View File

@ -255,18 +255,13 @@ class _PostEditorScreenState extends State<PostEditorScreen> {
if (_writeController.replyingPost != null) if (_writeController.replyingPost != null)
Column( Column(
children: [ children: [
Theme( ExpansionTile(
data: Theme.of(context).copyWith( minTileHeight: 48,
dividerColor: Colors.transparent, leading: const Icon(Symbols.reply).padding(left: 4),
), title: Text('postReplyingNotice')
child: ExpansionTile( .fontSize(15)
minTileHeight: 48, .tr(args: ['@${_writeController.replyingPost!.publisher.name}']),
leading: const Icon(Symbols.reply).padding(left: 4), children: <Widget>[PostItem(data: _writeController.replyingPost!)],
title: Text('postReplyingNotice')
.fontSize(15)
.tr(args: ['@${_writeController.replyingPost!.publisher.name}']),
children: <Widget>[PostItem(data: _writeController.replyingPost!)],
),
), ),
const Divider(height: 1), const Divider(height: 1),
], ],
@ -275,22 +270,17 @@ class _PostEditorScreenState extends State<PostEditorScreen> {
if (_writeController.repostingPost != null) if (_writeController.repostingPost != null)
Column( Column(
children: [ children: [
Theme( ExpansionTile(
data: Theme.of(context).copyWith( minTileHeight: 48,
dividerColor: Colors.transparent, leading: const Icon(Symbols.forward).padding(left: 4),
), title: Text('postRepostingNotice')
child: ExpansionTile( .fontSize(15)
minTileHeight: 48, .tr(args: ['@${_writeController.repostingPost!.publisher.name}']),
leading: const Icon(Symbols.forward).padding(left: 4), children: <Widget>[
title: Text('postRepostingNotice') PostItem(
.fontSize(15) data: _writeController.repostingPost!,
.tr(args: ['@${_writeController.repostingPost!.publisher.name}']), )
children: <Widget>[ ],
PostItem(
data: _writeController.repostingPost!,
)
],
),
), ),
const Divider(height: 1), const Divider(height: 1),
], ],
@ -299,18 +289,13 @@ class _PostEditorScreenState extends State<PostEditorScreen> {
if (_writeController.editingPost != null) if (_writeController.editingPost != null)
Column( Column(
children: [ children: [
Theme( ExpansionTile(
data: Theme.of(context).copyWith( minTileHeight: 48,
dividerColor: Colors.transparent, leading: const Icon(Symbols.edit_note).padding(left: 4),
), title: Text('postEditingNotice')
child: ExpansionTile( .fontSize(15)
minTileHeight: 48, .tr(args: ['@${_writeController.editingPost!.publisher.name}']),
leading: const Icon(Symbols.edit_note).padding(left: 4), children: <Widget>[PostItem(data: _writeController.editingPost!)],
title: Text('postEditingNotice')
.fontSize(15)
.tr(args: ['@${_writeController.editingPost!.publisher.name}']),
children: <Widget>[PostItem(data: _writeController.editingPost!)],
),
), ),
const Divider(height: 1), const Divider(height: 1),
], ],

View File

@ -136,10 +136,7 @@ class PostMediaPendingList extends StatelessWidget {
onSelected: () { onSelected: () {
onUpload!(idx); onUpload!(idx);
}), }),
if (media.attachment != null && if (media.attachment != null && media.type == SnMediaType.image && onPostSetThumbnail != null && idx != -1)
media.type == SnMediaType.image &&
onPostSetThumbnail != null &&
idx != -1)
MenuItem( MenuItem(
label: 'attachmentSetAsPostThumbnail'.tr(), label: 'attachmentSetAsPostThumbnail'.tr(),
icon: Symbols.gallery_thumbnail, icon: Symbols.gallery_thumbnail,
@ -293,10 +290,38 @@ class _PostMediaPendingItem extends StatelessWidget {
), ),
SnMediaType.video => Container( SnMediaType.video => Container(
color: Theme.of(context).colorScheme.surfaceContainer, color: Theme.of(context).colorScheme.surfaceContainer,
child: media.attachment?.metadata['thumbnail'] != null child: Stack(
? AutoResizeUniversalImage(sn.getAttachmentUrl(media.attachment?.metadata['thumbnail'])) fit: StackFit.expand,
: const Icon(Symbols.videocam).center(), 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( _ => Container(
color: Theme.of(context).colorScheme.surfaceContainer, color: Theme.of(context).colorScheme.surfaceContainer,
child: const Icon(Symbols.docs).center(), child: const Icon(Symbols.docs).center(),

View File

@ -28,6 +28,7 @@ import share_plus
import shared_preferences_foundation import shared_preferences_foundation
import sqflite_darwin import sqflite_darwin
import url_launcher_macos import url_launcher_macos
import video_compress
import wakelock_plus import wakelock_plus
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
@ -54,5 +55,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
VideoCompressPlugin.register(with: registry.registrar(forPlugin: "VideoCompressPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
} }

View File

@ -2047,6 +2047,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.9.0" 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: vm_service:
dependency: transitive dependency: transitive
description: description:

View File

@ -115,6 +115,7 @@ dependencies:
fl_chart: ^0.70.0 fl_chart: ^0.70.0
flutter_webrtc: ^0.12.5+hotfix.1 flutter_webrtc: ^0.12.5+hotfix.1
slide_countdown: ^2.0.2 slide_countdown: ^2.0.2
video_compress: ^3.1.3
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: