💄 Optimize attachment list
This commit is contained in:
parent
e4582b7d25
commit
462e818078
@ -26,6 +26,11 @@ class AttachmentList extends StatelessWidget {
|
|||||||
final borderSide = (bordered ?? false)
|
final borderSide = (bordered ?? false)
|
||||||
? BorderSide(width: 1, color: Theme.of(context).dividerColor)
|
? BorderSide(width: 1, color: Theme.of(context).dividerColor)
|
||||||
: BorderSide.none;
|
: BorderSide.none;
|
||||||
|
final backgroundColor = Theme.of(context).colorScheme.surfaceContainer;
|
||||||
|
final constraints = BoxConstraints(
|
||||||
|
minWidth: 80,
|
||||||
|
maxHeight: maxHeight ?? double.infinity,
|
||||||
|
);
|
||||||
|
|
||||||
if (data.isEmpty) return const SizedBox.shrink();
|
if (data.isEmpty) return const SizedBox.shrink();
|
||||||
if (data.length == 1) {
|
if (data.length == 1) {
|
||||||
@ -34,11 +39,9 @@ class AttachmentList extends StatelessWidget {
|
|||||||
// Single child list-like displaying
|
// Single child list-like displaying
|
||||||
padding: listPadding ?? EdgeInsets.zero,
|
padding: listPadding ?? EdgeInsets.zero,
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: BoxConstraints(
|
constraints: constraints,
|
||||||
minWidth: 80,
|
|
||||||
maxHeight: maxHeight ?? double.infinity,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
color: backgroundColor,
|
||||||
border: Border(top: borderSide, bottom: borderSide),
|
border: Border(top: borderSide, bottom: borderSide),
|
||||||
borderRadius: kDefaultRadius,
|
borderRadius: kDefaultRadius,
|
||||||
),
|
),
|
||||||
@ -55,6 +58,7 @@ class AttachmentList extends StatelessWidget {
|
|||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
color: backgroundColor,
|
||||||
border: Border(top: borderSide, bottom: borderSide),
|
border: Border(top: borderSide, bottom: borderSide),
|
||||||
),
|
),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
@ -72,22 +76,32 @@ class AttachmentList extends StatelessWidget {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: data.length,
|
itemCount: data.length,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return Container(
|
return Stack(
|
||||||
constraints: BoxConstraints(
|
children: [
|
||||||
minWidth: 80,
|
Container(
|
||||||
maxHeight: maxHeight ?? double.infinity,
|
constraints: constraints,
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: backgroundColor,
|
||||||
border: Border(top: borderSide, bottom: borderSide),
|
border: Border(top: borderSide, bottom: borderSide),
|
||||||
borderRadius: kDefaultRadius,
|
borderRadius: kDefaultRadius,
|
||||||
),
|
),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: data[idx].metadata['ratio']?.toDouble() ?? 1,
|
aspectRatio: data[idx].metadata['ratio']?.toDouble() ?? 1,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: kDefaultRadius,
|
borderRadius: kDefaultRadius,
|
||||||
child: AttachmentItem(data: data[idx], isExpandable: true),
|
child:
|
||||||
|
AttachmentItem(data: data[idx], isExpandable: true),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned(
|
||||||
|
right: 12,
|
||||||
|
bottom: 12,
|
||||||
|
child: Chip(
|
||||||
|
label: Text('${idx + 1}/${data.length}'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) => const Gap(8),
|
separatorBuilder: (context, index) => const Gap(8),
|
||||||
|
Loading…
Reference in New Issue
Block a user