Rollback to old style attachment list

This commit is contained in:
LittleSheep 2025-01-21 12:12:21 +08:00
parent 19076f8136
commit bb7b731602
4 changed files with 135 additions and 127 deletions

View File

@ -108,7 +108,7 @@ class _AttachmentListState extends State<AttachmentList> {
if (widget.gridded) { if (widget.gridded) {
final fullOfImage = final fullOfImage =
widget.data.where((ele) => ele?.mediaType == SnMediaType.image).length == widget.data.length; widget.data.where((ele) => ele?.mediaType == SnMediaType.image).length == widget.data.length;
if(!fullOfImage) { if (!fullOfImage) {
return Container( return Container(
margin: widget.padding ?? EdgeInsets.zero, margin: widget.padding ?? EdgeInsets.zero,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -191,68 +191,72 @@ class _AttachmentListState extends State<AttachmentList> {
); );
} }
return Container( return AspectRatio(
constraints: BoxConstraints(maxHeight: constraints.maxHeight), aspectRatio: widget.data.isNotEmpty ? widget.data.first?.data['ratio']?.toDouble() ?? 1 : 1,
child: ScrollConfiguration( child: Container(
behavior: _AttachmentListScrollBehavior(), constraints: constraints,
child: ListView.separated( child: ScrollConfiguration(
padding: widget.padding, behavior: _AttachmentListScrollBehavior(),
shrinkWrap: true, child: ListView.separated(
itemCount: widget.data.length, padding: widget.padding,
itemBuilder: (context, idx) { shrinkWrap: true,
return Container( itemCount: widget.data.length,
constraints: constraints.copyWith(maxWidth: widget.maxWidth), itemBuilder: (context, idx) {
child: AspectRatio( return Container(
aspectRatio: (widget.data[idx]?.data['ratio'] ?? 1).toDouble(), constraints: constraints.copyWith(maxWidth: widget.maxWidth),
child: GestureDetector( child: AspectRatio(
onTap: () { aspectRatio: (widget.data[idx]?.data['ratio'] ?? 1).toDouble(),
if (widget.data[idx]?.mediaType != SnMediaType.image) return; child: GestureDetector(
context.pushTransparentRoute( onTap: () {
AttachmentZoomView( if (widget.data[idx]?.mediaType != SnMediaType.image) return;
data: widget.data.where((ele) => ele != null && ele.mediaType == SnMediaType.image).cast(), context.pushTransparentRoute(
initialIndex: idx, AttachmentZoomView(
heroTags: heroTags, data:
), widget.data.where((ele) => ele != null && ele.mediaType == SnMediaType.image).cast(),
backgroundColor: Colors.black.withOpacity(0.7), initialIndex: idx,
rootNavigator: true, heroTags: heroTags,
);
},
child: Stack(
fit: StackFit.expand,
children: [
Container(
decoration: BoxDecoration(
color: backgroundColor,
border: Border(
top: borderSide,
bottom: borderSide,
),
borderRadius: AttachmentList.kDefaultRadius,
), ),
child: ClipRRect( backgroundColor: Colors.black.withOpacity(0.7),
borderRadius: AttachmentList.kDefaultRadius, rootNavigator: true,
child: AttachmentItem( );
data: widget.data[idx], },
heroTag: heroTags[idx], child: Stack(
fit: StackFit.expand,
children: [
Container(
decoration: BoxDecoration(
color: backgroundColor,
border: Border(
top: borderSide,
bottom: borderSide,
),
borderRadius: AttachmentList.kDefaultRadius,
),
child: ClipRRect(
borderRadius: AttachmentList.kDefaultRadius,
child: AttachmentItem(
data: widget.data[idx],
heroTag: heroTags[idx],
),
), ),
), ),
), Positioned(
Positioned( right: 8,
right: 8, bottom: 8,
bottom: 8, child: Chip(
child: Chip( label: Text('${idx + 1}/${widget.data.length}'),
label: Text('${idx + 1}/${widget.data.length}'), ),
), ),
), ],
], ),
), ),
), ),
), );
); },
}, separatorBuilder: (context, index) => const Gap(8),
separatorBuilder: (context, index) => const Gap(8), physics: const BouncingScrollPhysics(),
physics: const BouncingScrollPhysics(), scrollDirection: Axis.horizontal,
scrollDirection: Axis.horizontal, ),
), ),
), ),
); );

View File

@ -415,77 +415,79 @@ class _AttachmentZoomDetailPopup extends StatelessWidget {
], ],
).padding(horizontal: 20, top: 16, bottom: 12), ).padding(horizontal: 20, top: 16, bottom: 12),
Expanded( Expanded(
child: Table( child: SingleChildScrollView(
columnWidths: { child: Table(
0: IntrinsicColumnWidth(), columnWidths: {
1: FlexColumnWidth(), 0: IntrinsicColumnWidth(),
}, 1: FlexColumnWidth(),
children: [ },
TableRow( children: [
children: [
TableCell(
child: Text('attachmentUploadBy').tr().padding(right: 16),
),
TableCell(
child: Row(
children: [
if (data.accountId > 0)
AccountImage(
content: account?.avatar,
radius: 8,
),
const Gap(8),
Text(data.accountId > 0 ? account?.nick ?? 'unknown'.tr() : 'unknown'.tr()),
const Gap(8),
Text('#${data.accountId}', style: GoogleFonts.robotoMono()).opacity(0.75),
],
),
),
],
),
tableGap,
TableRow(
children: [
TableCell(child: Text('Mimetype').padding(right: 16)),
TableCell(child: Text(data.mimetype)),
],
),
TableRow(
children: [
TableCell(child: Text('Size').padding(right: 16)),
TableCell(
child: Row(
children: [
Text(data.size.formatBytes()),
const Gap(12),
Text('${data.size} Bytes', style: GoogleFonts.robotoMono()).opacity(0.75),
],
)),
],
),
TableRow(
children: [
TableCell(child: Text('Name').padding(right: 16)),
TableCell(child: Text(data.name)),
],
),
if (data.hash.isNotEmpty)
TableRow( TableRow(
children: [ children: [
TableCell(child: Text('Hash').padding(right: 16)), TableCell(
TableCell(child: Text(data.hash, style: GoogleFonts.robotoMono(fontSize: 11)).opacity(0.9)), child: Text('attachmentUploadBy').tr().padding(right: 16),
),
TableCell(
child: Row(
children: [
if (data.accountId > 0)
AccountImage(
content: account?.avatar,
radius: 8,
),
const Gap(8),
Text(data.accountId > 0 ? account?.nick ?? 'unknown'.tr() : 'unknown'.tr()),
const Gap(8),
Text('#${data.accountId}', style: GoogleFonts.robotoMono()).opacity(0.75),
],
),
),
], ],
), ),
tableGap, tableGap,
...(data.metadata['exif']?.keys.map((k) => TableRow( TableRow(
children: [
TableCell(child: Text('Mimetype').padding(right: 16)),
TableCell(child: Text(data.mimetype)),
],
),
TableRow(
children: [
TableCell(child: Text('Size').padding(right: 16)),
TableCell(
child: Row(
children: [
Text(data.size.formatBytes()),
const Gap(12),
Text('${data.size} Bytes', style: GoogleFonts.robotoMono()).opacity(0.75),
],
)),
],
),
TableRow(
children: [
TableCell(child: Text('Name').padding(right: 16)),
TableCell(child: Text(data.name)),
],
),
if (data.hash.isNotEmpty)
TableRow(
children: [ children: [
TableCell(child: Text(k).padding(right: 16)), TableCell(child: Text('Hash').padding(right: 16)),
TableCell(child: Text(data.metadata['exif'][k].toString())), TableCell(child: Text(data.hash, style: GoogleFonts.robotoMono(fontSize: 11)).opacity(0.9)),
], ],
)) ?? ),
[]), tableGap,
], ...(data.metadata['exif']?.keys.map((k) => TableRow(
).padding(horizontal: 20, vertical: 8), children: [
TableCell(child: Text(k).padding(right: 16)),
TableCell(child: Text(data.metadata['exif'][k].toString())),
],
)) ??
[]),
],
).padding(horizontal: 20, vertical: 8),
),
), ),
], ],
), ),

View File

@ -94,11 +94,14 @@ class _LinkPreviewEntry extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
if (meta.icon?.isNotEmpty ?? false) if (meta.icon?.isNotEmpty ?? false)
StyledWidget( SizedBox(
meta.icon!.endsWith('.svg') width: 36,
? SvgPicture.network(meta.icon!) height: 36,
child: meta.icon!.endsWith('.svg')
? SvgPicture.network(meta.icon!, width: 36, height: 36)
: UniversalImage( : UniversalImage(
meta.icon!, meta.icon!,
noErrorWidget: true,
width: 36, width: 36,
height: 36, height: 36,
cacheHeight: 36, cacheHeight: 36,

View File

@ -256,9 +256,8 @@ class PostItem extends StatelessWidget {
AttachmentList( AttachmentList(
data: displayableAttachments!, data: displayableAttachments!,
bordered: true, bordered: true,
gridded: true,
maxHeight: showFullPost ? null : 480, maxHeight: showFullPost ? null : 480,
minWidth: 640, maxWidth: MediaQuery.of(context).size.width - 20,
fit: showFullPost ? BoxFit.cover : BoxFit.contain, fit: showFullPost ? BoxFit.cover : BoxFit.contain,
padding: const EdgeInsets.symmetric(horizontal: 12), padding: const EdgeInsets.symmetric(horizontal: 12),
), ),