💄 Optimize tags

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

View File

@ -100,15 +100,40 @@ class FeedCreationButton extends StatelessWidget {
future: auth.isAuthorized, future: auth.isAuthorized,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData && snapshot.data == true) { if (snapshot.hasData && snapshot.data == true) {
return IconButton( return PopupMenuButton(
icon: const Icon(Icons.add_circle), icon: const Icon(Icons.add_circle),
onPressed: () { itemBuilder: (BuildContext context) => [
AppRouter.instance.pushNamed('postPublishing').then((val) { PopupMenuItem(
if (val != null && onCreated != null) { child: ListTile(
onCreated!(); title: Text('postCreate'.tr),
} leading: const Icon(Icons.article),
}); contentPadding: const EdgeInsets.symmetric(horizontal: 8),
}, ),
onTap: () {
AppRouter.instance.pushNamed('postPublishing').then((val) {
if (val != null && onCreated != null) {
onCreated!();
}
});
},
),
PopupMenuItem(
child: ListTile(
title: Text('articleCreate'.tr),
leading: const Icon(Icons.newspaper),
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
),
onTap: () {},
),
PopupMenuItem(
child: ListTile(
title: Text('draftBoxOpen'.tr),
leading: const Icon(Icons.drafts),
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
),
onTap: () {},
),
],
); );
} }
return const SizedBox(); return const SizedBox();

View File

@ -81,6 +81,9 @@ class SolianMessages extends Translations {
'notifyAllRead': 'Mark all as read', 'notifyAllRead': 'Mark all as read',
'notifyEmpty': 'All notifications read', 'notifyEmpty': 'All notifications read',
'notifyEmptyCaption': 'It seems like nothing happened recently', 'notifyEmptyCaption': 'It seems like nothing happened recently',
'postCreate': 'Create new post',
'articleCreate': 'Create new article',
'draftBoxOpen': 'Open draft box',
'postNew': 'Create a new post', 'postNew': 'Create a new post',
'postNewInRealmHint': 'Add post in realm @realm', 'postNewInRealmHint': 'Add post in realm @realm',
'postAction': 'Post', 'postAction': 'Post',
@ -322,6 +325,9 @@ class SolianMessages extends Translations {
'notifyAllRead': '已读所有通知', 'notifyAllRead': '已读所有通知',
'notifyEmpty': '通知箱为空', 'notifyEmpty': '通知箱为空',
'notifyEmptyCaption': '看起来最近没发生什么呢', 'notifyEmptyCaption': '看起来最近没发生什么呢',
'postCreate': '发表帖子',
'articleCreate': '发表文章',
'draftBoxOpen': '打开草稿箱',
'postNew': '创建新帖子', 'postNew': '创建新帖子',
'postNewInRealmHint': '在领域 @realm 里发表新帖子', 'postNewInRealmHint': '在领域 @realm 里发表新帖子',
'postAction': '发表', 'postAction': '发表',

View File

@ -12,29 +12,18 @@ class FeedTagsList extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const borderRadius = BorderRadius.all(
Radius.circular(8),
);
return Wrap( return Wrap(
alignment: WrapAlignment.start, alignment: WrapAlignment.start,
spacing: 6, spacing: 6,
children: tags children: tags
.map( .map(
(x) => GestureDetector( (x) => InkWell(
child: Container( child: Text(
decoration: BoxDecoration( '#${x.alias}',
borderRadius: borderRadius, style: TextStyle(
color: Theme.of(context).colorScheme.primary, color:
), Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
padding: fontSize: 12,
const EdgeInsets.symmetric(horizontal: 10.0, vertical: 4.0),
child: Text(
'#${x.alias}',
style: const TextStyle(
color: Colors.white,
fontSize: 12,
),
), ),
), ),
onTap: () { 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) { if (labels.isNotEmpty) {
return Text( widgets.add(Text(
labels.join(' · '), labels.join(' · '),
textAlign: TextAlign.left, textAlign: TextAlign.left,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75), color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
), ),
).paddingOnly(top: 2); ));
} else { }
if (widgets.isEmpty) {
return const SizedBox(); return const SizedBox();
} else {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets,
);
} }
} }
@ -210,10 +222,7 @@ class _PostItemState extends State<PostItem> {
top: 2, top: 2,
bottom: hasAttachment ? 4 : 0, bottom: hasAttachment ? 4 : 0,
), ),
buildFooter().paddingOnly(left: 16), buildFooter().paddingOnly(left: 16, top: 2),
if (widget.item.tags?.isNotEmpty ?? false)
FeedTagsList(tags: widget.item.tags!)
.paddingOnly(left: 12, top: 6, bottom: 2),
AttachmentList( AttachmentList(
parentId: widget.overrideAttachmentParent ?? widget.item.alias, parentId: widget.overrideAttachmentParent ?? widget.item.alias,
attachmentsId: item.attachments ?? List.empty(), attachmentsId: item.attachments ?? List.empty(),
@ -275,10 +284,7 @@ class _PostItemState extends State<PostItem> {
); );
}, },
), ),
buildFooter().paddingOnly(left: 12), buildFooter().paddingOnly(left: 12, top: 2),
if (widget.item.tags?.isNotEmpty ?? false)
FeedTagsList(tags: widget.item.tags!)
.paddingOnly(left: 4, top: 6, bottom: 2),
], ],
), ),
) )