💄 Optimize tags

This commit is contained in:
2024-07-08 19:56:03 +08:00
parent b241956ce7
commit 10ed44d2e2
4 changed files with 63 additions and 37 deletions

View File

@ -12,29 +12,18 @@ class FeedTagsList extends StatelessWidget {
@override
Widget build(BuildContext context) {
const borderRadius = BorderRadius.all(
Radius.circular(8),
);
return Wrap(
alignment: WrapAlignment.start,
spacing: 6,
children: tags
.map(
(x) => GestureDetector(
child: Container(
decoration: BoxDecoration(
borderRadius: borderRadius,
color: Theme.of(context).colorScheme.primary,
),
padding:
const EdgeInsets.symmetric(horizontal: 10.0, vertical: 4.0),
child: Text(
'#${x.alias}',
style: const TextStyle(
color: Colors.white,
fontSize: 12,
),
(x) => InkWell(
child: Text(
'#${x.alias}',
style: TextStyle(
color:
Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
fontSize: 12,
),
),
onTap: () {

View File

@ -111,17 +111,29 @@ class _PostItemState extends State<PostItem> {
}));
}
List<Widget> widgets = List.empty(growable: true);
if (widget.item.tags?.isNotEmpty ?? false) {
widgets.add(FeedTagsList(tags: widget.item.tags!));
}
if (labels.isNotEmpty) {
return Text(
widgets.add(Text(
labels.join(' · '),
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
),
).paddingOnly(top: 2);
} else {
));
}
if (widgets.isEmpty) {
return const SizedBox();
} else {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets,
);
}
}
@ -210,10 +222,7 @@ class _PostItemState extends State<PostItem> {
top: 2,
bottom: hasAttachment ? 4 : 0,
),
buildFooter().paddingOnly(left: 16),
if (widget.item.tags?.isNotEmpty ?? false)
FeedTagsList(tags: widget.item.tags!)
.paddingOnly(left: 12, top: 6, bottom: 2),
buildFooter().paddingOnly(left: 16, top: 2),
AttachmentList(
parentId: widget.overrideAttachmentParent ?? widget.item.alias,
attachmentsId: item.attachments ?? List.empty(),
@ -275,10 +284,7 @@ class _PostItemState extends State<PostItem> {
);
},
),
buildFooter().paddingOnly(left: 12),
if (widget.item.tags?.isNotEmpty ?? false)
FeedTagsList(tags: widget.item.tags!)
.paddingOnly(left: 4, top: 6, bottom: 2),
buildFooter().paddingOnly(left: 12, top: 2),
],
),
)