diff --git a/lib/screens/feed.dart b/lib/screens/feed.dart index e557eda..e630778 100644 --- a/lib/screens/feed.dart +++ b/lib/screens/feed.dart @@ -100,15 +100,40 @@ class FeedCreationButton extends StatelessWidget { future: auth.isAuthorized, builder: (context, snapshot) { if (snapshot.hasData && snapshot.data == true) { - return IconButton( + return PopupMenuButton( icon: const Icon(Icons.add_circle), - onPressed: () { - AppRouter.instance.pushNamed('postPublishing').then((val) { - if (val != null && onCreated != null) { - onCreated!(); - } - }); - }, + itemBuilder: (BuildContext context) => [ + PopupMenuItem( + child: ListTile( + 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(); diff --git a/lib/translations.dart b/lib/translations.dart index a3ccbe9..a0be185 100644 --- a/lib/translations.dart +++ b/lib/translations.dart @@ -81,6 +81,9 @@ class SolianMessages extends Translations { 'notifyAllRead': 'Mark all as read', 'notifyEmpty': 'All notifications read', 'notifyEmptyCaption': 'It seems like nothing happened recently', + 'postCreate': 'Create new post', + 'articleCreate': 'Create new article', + 'draftBoxOpen': 'Open draft box', 'postNew': 'Create a new post', 'postNewInRealmHint': 'Add post in realm @realm', 'postAction': 'Post', @@ -322,6 +325,9 @@ class SolianMessages extends Translations { 'notifyAllRead': '已读所有通知', 'notifyEmpty': '通知箱为空', 'notifyEmptyCaption': '看起来最近没发生什么呢', + 'postCreate': '发表帖子', + 'articleCreate': '发表文章', + 'draftBoxOpen': '打开草稿箱', 'postNew': '创建新帖子', 'postNewInRealmHint': '在领域 @realm 里发表新帖子', 'postAction': '发表', diff --git a/lib/widgets/posts/feed_tags.dart b/lib/widgets/posts/feed_tags.dart index 225216c..304c584 100644 --- a/lib/widgets/posts/feed_tags.dart +++ b/lib/widgets/posts/feed_tags.dart @@ -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: () { diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index 4ca82ca..b42232a 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -111,17 +111,29 @@ class _PostItemState extends State { })); } + List 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 { 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 { ); }, ), - 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), ], ), )