Attachment gallery

This commit is contained in:
2024-05-21 00:02:39 +08:00
parent 2ec9cd814d
commit 158f189531
5 changed files with 74 additions and 14 deletions

View File

@ -5,16 +5,20 @@ import 'package:solian/services.dart';
class AttachmentItem extends StatelessWidget {
final Attachment item;
final bool showBadge;
final bool showHideButton;
final BoxFit fit;
final String? badge;
final bool show;
final Function onHide;
final Function? onHide;
const AttachmentItem({
super.key,
required this.item,
required this.onHide,
this.badge,
this.show = true,
this.fit = BoxFit.cover,
this.showBadge = true,
this.showHideButton = true,
this.onHide,
});
@override
@ -26,9 +30,9 @@ class AttachmentItem extends StatelessWidget {
children: [
Image.network(
'${ServiceFinder.services['paperclip']}/api/attachments/${item.id}',
fit: BoxFit.cover,
fit: fit,
),
if (show && badge != null)
if (showBadge && badge != null)
Positioned(
right: 12,
bottom: 8,
@ -37,7 +41,7 @@ class AttachmentItem extends StatelessWidget {
child: Chip(label: Text(badge!)),
),
),
if (show && item.isMature)
if (showHideButton && item.isMature)
Positioned(
top: 8,
left: 12,
@ -47,7 +51,9 @@ class AttachmentItem extends StatelessWidget {
visualDensity: const VisualDensity(vertical: -4, horizontal: -4),
avatar: Icon(Icons.visibility_off, color: Theme.of(context).colorScheme.onSurfaceVariant),
label: Text('hide'.tr),
onPressed: () => onHide(),
onPressed: () {
if (onHide != null) onHide!();
},
),
),
),