2024-08-19 14:13:25 +00:00
|
|
|
import 'dart:math' as math;
|
2024-05-18 14:23:36 +00:00
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:carousel_slider/carousel_slider.dart';
|
2024-07-26 16:20:11 +00:00
|
|
|
import 'package:dismissible_page/dismissible_page.dart';
|
2024-08-07 11:21:01 +00:00
|
|
|
import 'package:flutter/material.dart' hide CarouselController;
|
2024-07-29 09:56:36 +00:00
|
|
|
import 'package:flutter_animate/flutter_animate.dart';
|
2024-09-07 09:45:44 +00:00
|
|
|
import 'package:gap/gap.dart';
|
2024-05-18 14:23:36 +00:00
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:solian/models/attachment.dart';
|
2024-05-22 15:18:01 +00:00
|
|
|
import 'package:solian/widgets/attachments/attachment_item.dart';
|
|
|
|
import 'package:solian/providers/content/attachment.dart';
|
2024-08-01 08:45:18 +00:00
|
|
|
import 'package:solian/widgets/attachments/attachment_fullscreen.dart';
|
2024-08-06 11:39:07 +00:00
|
|
|
import 'package:solian/widgets/sized_container.dart';
|
2024-05-18 14:23:36 +00:00
|
|
|
|
|
|
|
class AttachmentList extends StatefulWidget {
|
2024-05-25 16:11:00 +00:00
|
|
|
final String parentId;
|
2024-10-10 14:52:05 +00:00
|
|
|
final List<String>? attachmentIds;
|
|
|
|
final List<Attachment>? attachments;
|
2024-07-25 17:16:32 +00:00
|
|
|
final bool isGrid;
|
2024-08-19 14:13:25 +00:00
|
|
|
final bool isColumn;
|
2024-07-26 06:21:00 +00:00
|
|
|
final bool isForceGrid;
|
2024-08-16 13:06:50 +00:00
|
|
|
final bool autoload;
|
2024-07-26 08:53:05 +00:00
|
|
|
final double flatMaxHeight;
|
2024-08-19 14:13:25 +00:00
|
|
|
final double columnMaxWidth;
|
2024-06-23 12:18:55 +00:00
|
|
|
|
|
|
|
final double? width;
|
|
|
|
final double? viewport;
|
2024-05-18 14:23:36 +00:00
|
|
|
|
2024-06-22 17:52:05 +00:00
|
|
|
const AttachmentList({
|
|
|
|
super.key,
|
|
|
|
required this.parentId,
|
2024-10-10 14:52:05 +00:00
|
|
|
this.attachmentIds,
|
|
|
|
this.attachments,
|
2024-07-25 17:16:32 +00:00
|
|
|
this.isGrid = false,
|
2024-08-19 14:13:25 +00:00
|
|
|
this.isColumn = false,
|
2024-07-26 06:21:00 +00:00
|
|
|
this.isForceGrid = false,
|
2024-08-16 13:06:50 +00:00
|
|
|
this.autoload = false,
|
2024-07-26 08:53:05 +00:00
|
|
|
this.flatMaxHeight = 720,
|
2024-08-19 14:13:25 +00:00
|
|
|
this.columnMaxWidth = 480,
|
2024-06-23 12:18:55 +00:00
|
|
|
this.width,
|
|
|
|
this.viewport,
|
2024-06-22 17:52:05 +00:00
|
|
|
});
|
2024-05-18 14:23:36 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<AttachmentList> createState() => _AttachmentListState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AttachmentListState extends State<AttachmentList> {
|
|
|
|
bool _isLoading = true;
|
|
|
|
bool _showMature = false;
|
|
|
|
|
|
|
|
double _aspectRatio = 1;
|
|
|
|
|
2024-10-10 14:52:05 +00:00
|
|
|
List<Attachment?> _attachments = List.empty();
|
2024-05-18 14:23:36 +00:00
|
|
|
|
2024-07-29 09:56:36 +00:00
|
|
|
void _getMetadataList() {
|
2024-08-02 14:46:48 +00:00
|
|
|
final AttachmentProvider attach = Get.find();
|
2024-05-18 14:23:36 +00:00
|
|
|
|
2024-10-10 14:52:05 +00:00
|
|
|
if (widget.attachmentIds?.isEmpty ?? false) {
|
2024-05-18 14:23:36 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2024-10-10 14:52:05 +00:00
|
|
|
_attachments = List.filled(widget.attachmentIds!.length, null);
|
2024-05-18 14:23:36 +00:00
|
|
|
}
|
|
|
|
|
2024-10-10 14:52:05 +00:00
|
|
|
attach.listMetadata(widget.attachmentIds!).then((result) {
|
2024-08-17 10:44:20 +00:00
|
|
|
if (mounted) {
|
|
|
|
setState(() {
|
2024-10-10 14:52:05 +00:00
|
|
|
_attachments = result;
|
2024-08-17 10:44:20 +00:00
|
|
|
_isLoading = false;
|
|
|
|
});
|
|
|
|
}
|
2024-08-02 14:54:56 +00:00
|
|
|
_calculateAspectRatio();
|
2024-08-02 14:46:48 +00:00
|
|
|
});
|
2024-05-18 14:23:36 +00:00
|
|
|
}
|
|
|
|
|
2024-08-02 14:46:48 +00:00
|
|
|
void _calculateAspectRatio() {
|
2024-05-20 15:11:26 +00:00
|
|
|
bool isConsistent = true;
|
|
|
|
double? consistentValue;
|
2024-05-18 14:23:36 +00:00
|
|
|
int portrait = 0, square = 0, landscape = 0;
|
2024-10-10 14:52:05 +00:00
|
|
|
for (var entry in _attachments) {
|
2024-08-19 01:19:29 +00:00
|
|
|
if (entry == null) continue;
|
2024-08-19 11:36:01 +00:00
|
|
|
if (entry.metadata?['ratio'] != null) {
|
2024-05-27 15:07:01 +00:00
|
|
|
if (entry.metadata?['ratio'] is int) {
|
|
|
|
consistentValue ??= entry.metadata?['ratio'].toDouble();
|
|
|
|
} else {
|
|
|
|
consistentValue ??= entry.metadata?['ratio'];
|
|
|
|
}
|
2024-05-20 15:11:26 +00:00
|
|
|
if (isConsistent && entry.metadata?['ratio'] != consistentValue) {
|
|
|
|
isConsistent = false;
|
|
|
|
}
|
2024-05-18 14:23:36 +00:00
|
|
|
if (entry.metadata!['ratio'] > 1) {
|
|
|
|
landscape++;
|
|
|
|
} else if (entry.metadata!['ratio'] == 1) {
|
|
|
|
square++;
|
|
|
|
} else {
|
|
|
|
portrait++;
|
|
|
|
}
|
2024-09-08 14:43:01 +00:00
|
|
|
} else if (entry.mimetype.split('/').firstOrNull == 'audio') {
|
|
|
|
landscape++;
|
2024-05-18 14:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-20 15:11:26 +00:00
|
|
|
if (isConsistent && consistentValue != null) {
|
|
|
|
_aspectRatio = consistentValue;
|
2024-05-18 14:23:36 +00:00
|
|
|
} else {
|
2024-05-20 15:11:26 +00:00
|
|
|
if (portrait > square && portrait > landscape) {
|
|
|
|
_aspectRatio = 9 / 16;
|
|
|
|
}
|
|
|
|
if (landscape > square && landscape > portrait) {
|
|
|
|
_aspectRatio = 16 / 9;
|
|
|
|
} else {
|
|
|
|
_aspectRatio = 1;
|
|
|
|
}
|
2024-05-18 14:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-19 14:13:25 +00:00
|
|
|
Widget _buildEntry(Attachment? element, int idx, {double? width}) {
|
2024-07-26 09:35:54 +00:00
|
|
|
return AttachmentListEntry(
|
|
|
|
item: element,
|
|
|
|
parentId: widget.parentId,
|
2024-08-19 14:13:25 +00:00
|
|
|
width: width ?? widget.width,
|
2024-10-10 14:52:05 +00:00
|
|
|
badgeContent: '${idx + 1}/${_attachments.length}',
|
|
|
|
showBadge: _attachments.length > 1 && !widget.isGrid && !widget.isColumn,
|
|
|
|
showBorder: _attachments.length > 1,
|
2024-07-26 09:35:54 +00:00
|
|
|
showMature: _showMature,
|
2024-08-17 10:44:20 +00:00
|
|
|
autoload: widget.autoload,
|
2024-07-26 09:35:54 +00:00
|
|
|
onReveal: (value) {
|
|
|
|
setState(() => _showMature = value);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
2024-10-10 14:52:05 +00:00
|
|
|
assert(widget.attachmentIds != null || widget.attachments != null);
|
|
|
|
if (widget.attachments == null) {
|
|
|
|
_getMetadataList();
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
_attachments = widget.attachments!;
|
|
|
|
_isLoading = false;
|
|
|
|
});
|
|
|
|
_calculateAspectRatio();
|
|
|
|
}
|
2024-07-26 09:35:54 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 03:47:40 +00:00
|
|
|
Color get _unFocusColor =>
|
|
|
|
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
|
|
|
|
2024-07-26 09:35:54 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-10-10 14:52:05 +00:00
|
|
|
if (widget.attachmentIds?.isEmpty ?? widget.attachments!.isEmpty) {
|
2024-09-07 09:48:07 +00:00
|
|
|
return const SizedBox.shrink();
|
2024-07-26 09:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_isLoading) {
|
2024-08-24 03:47:40 +00:00
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
Icons.file_copy,
|
|
|
|
size: 12,
|
|
|
|
color: _unFocusColor,
|
|
|
|
).paddingOnly(right: 5),
|
|
|
|
Text(
|
|
|
|
'attachmentHint'.trParams(
|
2024-10-10 14:52:05 +00:00
|
|
|
{'count': _attachments.toString()},
|
2024-08-24 03:47:40 +00:00
|
|
|
),
|
|
|
|
style: TextStyle(color: _unFocusColor, fontSize: 12),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.paddingSymmetric(horizontal: 8)
|
|
|
|
.animate(onPlay: (c) => c.repeat(reverse: true))
|
|
|
|
.fadeIn(duration: 1250.ms);
|
2024-07-26 09:35:54 +00:00
|
|
|
}
|
|
|
|
|
2024-08-19 14:13:25 +00:00
|
|
|
if (widget.isColumn) {
|
|
|
|
var idx = 0;
|
|
|
|
const radius = BorderRadius.all(Radius.circular(8));
|
|
|
|
return Wrap(
|
|
|
|
spacing: 8,
|
|
|
|
runSpacing: 8,
|
2024-10-10 14:52:05 +00:00
|
|
|
children: _attachments.map((x) {
|
|
|
|
final element = _attachments[idx];
|
2024-08-19 14:13:25 +00:00
|
|
|
idx++;
|
2024-09-07 09:48:07 +00:00
|
|
|
if (element == null) return const SizedBox.shrink();
|
2024-08-21 05:14:40 +00:00
|
|
|
double ratio = element.metadata?['ratio']?.toDouble() ?? 16 / 9;
|
2024-08-19 14:13:25 +00:00
|
|
|
return Container(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
maxWidth: widget.columnMaxWidth,
|
|
|
|
maxHeight: 640,
|
|
|
|
),
|
|
|
|
child: AspectRatio(
|
|
|
|
aspectRatio: ratio,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
width: 1,
|
|
|
|
),
|
|
|
|
borderRadius: radius,
|
|
|
|
),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: radius,
|
|
|
|
child: _buildEntry(element, idx),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-10-10 14:52:05 +00:00
|
|
|
final isNotPureImage = _attachments.any(
|
2024-08-17 10:44:20 +00:00
|
|
|
(x) => x?.mimetype.split('/').firstOrNull != 'image',
|
|
|
|
);
|
2024-07-26 09:35:54 +00:00
|
|
|
if (widget.isGrid && (widget.isForceGrid || !isNotPureImage)) {
|
|
|
|
const radius = BorderRadius.all(Radius.circular(8));
|
|
|
|
return GridView.builder(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
primary: false,
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
2024-10-10 14:52:05 +00:00
|
|
|
crossAxisCount: math.min(3, _attachments.length),
|
2024-07-26 09:35:54 +00:00
|
|
|
mainAxisSpacing: 8.0,
|
|
|
|
crossAxisSpacing: 8.0,
|
|
|
|
),
|
2024-10-10 14:52:05 +00:00
|
|
|
itemCount: _attachments.length,
|
2024-07-26 09:35:54 +00:00
|
|
|
itemBuilder: (context, idx) {
|
2024-10-10 14:52:05 +00:00
|
|
|
final element = _attachments[idx];
|
2024-07-26 09:35:54 +00:00
|
|
|
return Container(
|
|
|
|
decoration: BoxDecoration(
|
2024-08-24 03:47:40 +00:00
|
|
|
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
2024-08-17 10:44:20 +00:00
|
|
|
border: Border.all(
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
width: 1,
|
|
|
|
),
|
2024-07-26 09:35:54 +00:00
|
|
|
borderRadius: radius,
|
|
|
|
),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: radius,
|
|
|
|
child: _buildEntry(element, idx),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
).paddingSymmetric(horizontal: 24);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
maxHeight: widget.flatMaxHeight,
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
2024-10-06 11:54:32 +00:00
|
|
|
color: Colors.transparent,
|
2024-07-26 09:35:54 +00:00
|
|
|
border: Border.symmetric(
|
|
|
|
horizontal: BorderSide(
|
|
|
|
width: 0.3,
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: CarouselSlider.builder(
|
|
|
|
options: CarouselOptions(
|
2024-10-06 11:54:32 +00:00
|
|
|
animateToClosest: true,
|
2024-07-26 09:35:54 +00:00
|
|
|
aspectRatio: _aspectRatio,
|
|
|
|
viewportFraction:
|
2024-10-10 14:52:05 +00:00
|
|
|
widget.viewport ?? (_attachments.length > 1 ? 0.95 : 1),
|
2024-07-26 09:35:54 +00:00
|
|
|
enableInfiniteScroll: false,
|
|
|
|
),
|
2024-10-10 14:52:05 +00:00
|
|
|
itemCount: _attachments.length,
|
2024-07-26 09:35:54 +00:00
|
|
|
itemBuilder: (context, idx, _) {
|
2024-10-10 14:52:05 +00:00
|
|
|
final element = _attachments[idx];
|
2024-07-26 09:35:54 +00:00
|
|
|
return _buildEntry(element, idx);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AttachmentListEntry extends StatelessWidget {
|
|
|
|
final String parentId;
|
|
|
|
final Attachment? item;
|
|
|
|
final String? badgeContent;
|
|
|
|
final double? width;
|
2024-08-19 14:13:25 +00:00
|
|
|
final double? height;
|
2024-07-26 09:35:54 +00:00
|
|
|
final bool showBorder;
|
|
|
|
final bool showBadge;
|
|
|
|
final bool showMature;
|
2024-07-27 12:27:29 +00:00
|
|
|
final bool isDense;
|
2024-08-16 13:06:50 +00:00
|
|
|
final bool autoload;
|
2024-07-26 09:35:54 +00:00
|
|
|
final Function(bool) onReveal;
|
|
|
|
|
|
|
|
const AttachmentListEntry({
|
|
|
|
super.key,
|
|
|
|
required this.parentId,
|
|
|
|
required this.onReveal,
|
|
|
|
this.item,
|
|
|
|
this.badgeContent,
|
|
|
|
this.width,
|
2024-08-19 14:13:25 +00:00
|
|
|
this.height,
|
2024-07-26 09:35:54 +00:00
|
|
|
this.showBorder = false,
|
|
|
|
this.showBadge = false,
|
|
|
|
this.showMature = false,
|
2024-07-27 12:27:29 +00:00
|
|
|
this.isDense = false,
|
2024-08-16 13:06:50 +00:00
|
|
|
this.autoload = false,
|
2024-07-26 09:35:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (item == null) {
|
2024-07-25 17:16:32 +00:00
|
|
|
return Center(
|
2024-07-29 09:56:36 +00:00
|
|
|
child: Icon(
|
|
|
|
Icons.close,
|
|
|
|
size: 32,
|
|
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
|
|
)
|
|
|
|
.animate(onPlay: (e) => e.repeat(reverse: true))
|
|
|
|
.fade(duration: 500.ms),
|
2024-07-25 17:16:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-11 16:44:57 +00:00
|
|
|
return GestureDetector(
|
|
|
|
child: Container(
|
2024-07-26 09:35:54 +00:00
|
|
|
width: width ?? MediaQuery.of(context).size.width,
|
2024-08-19 14:13:25 +00:00
|
|
|
height: height,
|
2024-07-11 16:44:57 +00:00
|
|
|
decoration: BoxDecoration(
|
2024-10-06 11:41:44 +00:00
|
|
|
color: Colors.transparent,
|
2024-07-26 09:35:54 +00:00
|
|
|
border: showBorder
|
2024-07-25 17:16:32 +00:00
|
|
|
? Border.symmetric(
|
|
|
|
vertical: BorderSide(
|
|
|
|
width: 0.3,
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
2024-07-11 16:44:57 +00:00
|
|
|
),
|
|
|
|
child: Stack(
|
|
|
|
fit: StackFit.expand,
|
|
|
|
children: [
|
|
|
|
AttachmentItem(
|
2024-07-26 09:35:54 +00:00
|
|
|
parentId: parentId,
|
|
|
|
key: Key('a${item!.uuid}'),
|
|
|
|
item: item!,
|
|
|
|
badge: showBadge ? badgeContent : null,
|
|
|
|
showHideButton: !item!.isMature || showMature,
|
2024-08-16 13:06:50 +00:00
|
|
|
autoload: autoload,
|
2024-09-22 14:56:28 +00:00
|
|
|
isDense: isDense,
|
2024-07-11 16:44:57 +00:00
|
|
|
onHide: () {
|
2024-07-26 09:35:54 +00:00
|
|
|
onReveal(false);
|
2024-07-11 16:44:57 +00:00
|
|
|
},
|
|
|
|
),
|
2024-07-26 09:35:54 +00:00
|
|
|
if (item!.isMature && !showMature)
|
2024-07-11 16:44:57 +00:00
|
|
|
BackdropFilter(
|
|
|
|
filter: ImageFilter.blur(sigmaX: 100, sigmaY: 100),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.black.withOpacity(0.5),
|
2024-06-22 17:52:05 +00:00
|
|
|
),
|
|
|
|
),
|
2024-07-11 16:44:57 +00:00
|
|
|
),
|
2024-07-26 09:35:54 +00:00
|
|
|
if (item!.isMature && !showMature)
|
2024-08-06 11:39:07 +00:00
|
|
|
CenteredContainer(
|
|
|
|
maxWidth: 280,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
const Icon(
|
|
|
|
Icons.visibility_off,
|
|
|
|
color: Colors.white,
|
|
|
|
size: 32,
|
|
|
|
),
|
2024-09-07 09:45:44 +00:00
|
|
|
if (!isDense) const Gap(8),
|
2024-08-06 11:39:07 +00:00
|
|
|
if (!isDense)
|
|
|
|
Text(
|
|
|
|
'matureContent'.tr,
|
|
|
|
style: const TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 16,
|
2024-07-25 17:16:32 +00:00
|
|
|
),
|
2024-08-06 11:39:07 +00:00
|
|
|
),
|
|
|
|
if (!isDense)
|
|
|
|
Text(
|
|
|
|
'matureContentCaption'.tr,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
2024-06-22 17:52:05 +00:00
|
|
|
),
|
|
|
|
),
|
2024-07-11 16:44:57 +00:00
|
|
|
],
|
|
|
|
),
|
2024-07-05 15:37:54 +00:00
|
|
|
),
|
2024-07-11 16:44:57 +00:00
|
|
|
onTap: () {
|
2024-07-26 09:35:54 +00:00
|
|
|
if (!showMature && item!.isMature) {
|
|
|
|
onReveal(true);
|
|
|
|
} else if (['image'].contains(item!.mimetype.split('/').first)) {
|
2024-07-26 16:20:11 +00:00
|
|
|
context.pushTransparentRoute(
|
2024-08-01 08:45:18 +00:00
|
|
|
AttachmentFullScreen(
|
2024-07-26 16:20:11 +00:00
|
|
|
parentId: parentId,
|
2024-07-31 18:10:57 +00:00
|
|
|
item: item!,
|
2024-07-11 16:44:57 +00:00
|
|
|
),
|
2024-07-26 16:20:11 +00:00
|
|
|
rootNavigator: true,
|
2024-07-11 16:44:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2024-06-22 17:52:05 +00:00
|
|
|
);
|
|
|
|
}
|
2024-05-18 14:23:36 +00:00
|
|
|
}
|
2024-08-06 08:24:47 +00:00
|
|
|
|
|
|
|
class AttachmentSelfContainedEntry extends StatefulWidget {
|
2024-08-18 14:51:52 +00:00
|
|
|
final String rid;
|
2024-08-06 08:24:47 +00:00
|
|
|
final String parentId;
|
|
|
|
final bool isDense;
|
|
|
|
|
|
|
|
const AttachmentSelfContainedEntry({
|
|
|
|
super.key,
|
2024-08-18 14:51:52 +00:00
|
|
|
required this.rid,
|
2024-08-06 08:24:47 +00:00
|
|
|
required this.parentId,
|
|
|
|
this.isDense = false,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<AttachmentSelfContainedEntry> createState() =>
|
|
|
|
_AttachmentSelfContainedEntryState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AttachmentSelfContainedEntryState
|
|
|
|
extends State<AttachmentSelfContainedEntry> {
|
|
|
|
bool _showMature = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final AttachmentProvider attachments = Get.find();
|
|
|
|
|
|
|
|
return FutureBuilder(
|
2024-08-18 14:51:52 +00:00
|
|
|
future: attachments.getMetadata(widget.rid),
|
2024-08-06 08:24:47 +00:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (!snapshot.hasData) {
|
2024-08-18 14:51:52 +00:00
|
|
|
return const Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
2024-08-06 08:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return AttachmentListEntry(
|
|
|
|
item: snapshot.data,
|
|
|
|
isDense: widget.isDense,
|
|
|
|
parentId: widget.parentId,
|
|
|
|
showMature: _showMature,
|
|
|
|
onReveal: (value) {
|
|
|
|
setState(() => _showMature = value);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|