diff --git a/assets/translations/en.json b/assets/translations/en.json index 02d4e7d..c067a83 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -104,10 +104,20 @@ "postRepostingNotice": "You're about to repost a post that posted {}.", "postReact": "React", "postReactions": "Reactions of Post", - "postReactionPoints": { - "zero": "{} pt", - "one": "{} pt", - "other": "{} pts" + "postReactionUpvote": { + "zero": "0 upvote", + "one": "{} upvote", + "other": "{} upvotes" + }, + "postReactionDownvote": { + "zero": "0 downvote", + "one": "{} downvote", + "other": "{} downvotes" + }, + "postReactionSocialPoint": { + "zero": "0 point", + "one": "{} point", + "other": "{} points" }, "postReactCompleted": "Reaction has been added.", "postReactUncompleted": "Reaction has been removed.", diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 04c84fd..28bef5d 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -104,10 +104,20 @@ "postReact": "反应", "postPosted": "帖子已经发表。", "postReactions": "帖子的反应", - "postReactionPoints": { - "zero": "{} 点", - "one": "{} 点", - "other": "{} 点" + "postReactionUpvote": { + "zero": "0 个顶", + "one": "{} 个顶", + "other": "{} 个顶" + }, + "postReactionDownvote": { + "zero": "0 个踩", + "one": "{} 个踩", + "other": "{} 个踩" + }, + "postReactionSocialPoint": { + "zero": "无社会信用点变更", + "one": "{} 点社会信用点变更", + "other": "{} 点社会信用点变更" }, "postReactCompleted": "反应已被添加。", "postReactUncompleted": "反应已被移除。", diff --git a/lib/screens/chat/manage.dart b/lib/screens/chat/manage.dart index caebca0..0400752 100644 --- a/lib/screens/chat/manage.dart +++ b/lib/screens/chat/manage.dart @@ -130,7 +130,7 @@ class _ChatManageScreenState extends State { LoadingIndicator(isActive: _isBusy), if (_editingChannel != null) MaterialBanner( - leading: const Icon(Icons.edit), + leading: const Icon(Symbols.edit), leadingPadding: const EdgeInsets.only(left: 10, right: 20), dividerColor: Colors.transparent, content: Text( diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index 67b0af5..1c4d87e 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -173,7 +173,13 @@ class _ExploreScreenState extends State { onFetchData: _fetchPosts, itemBuilder: (context, idx) { return GestureDetector( - child: PostItem(data: _posts[idx], maxWidth: 640), + child: PostItem( + data: _posts[idx], + maxWidth: 640, + onChanged: (data) { + setState(() => _posts[idx] = data); + }, + ), onTap: () { GoRouter.of(context).pushNamed( 'postDetail', diff --git a/lib/screens/notification.dart b/lib/screens/notification.dart index 5e693a1..8f83ecb 100644 --- a/lib/screens/notification.dart +++ b/lib/screens/notification.dart @@ -135,7 +135,7 @@ class _NotificationScreenState extends State { title: Text('screenNotification').tr(), actions: [ IconButton( - icon: const Icon(Icons.checklist), + icon: const Icon(Symbols.checklist), onPressed: _isSubmitting ? null : _markAllAsRead, ), ], diff --git a/lib/screens/post/post_detail.dart b/lib/screens/post/post_detail.dart index 8f6d5e6..6c6dca6 100644 --- a/lib/screens/post/post_detail.dart +++ b/lib/screens/post/post_detail.dart @@ -113,6 +113,9 @@ class _PostDetailScreenState extends State { data: _data!, maxWidth: 640, showComments: false, + onChanged: (data) { + setState(() => _data = data); + }, ), ), const SliverToBoxAdapter(child: Divider(height: 1)), @@ -144,7 +147,6 @@ class _PostDetailScreenState extends State { child: PostMiniEditor( postReplyId: _data!.id, onPost: () { - _childListKey.currentState!.refresh(); setState(() { _data = _data!.copyWith( metric: _data!.metric.copyWith( @@ -152,6 +154,7 @@ class _PostDetailScreenState extends State { ), ); }); + _childListKey.currentState!.refresh(); }, ), ), diff --git a/lib/screens/post/post_editor.dart b/lib/screens/post/post_editor.dart index 9645023..5e13725 100644 --- a/lib/screens/post/post_editor.dart +++ b/lib/screens/post/post_editor.dart @@ -292,7 +292,8 @@ class _PostEditorScreenState extends State { ]), children: [ PostItem( - data: _writeController.repostingPost!) + data: _writeController.repostingPost!, + ) ], ), ), diff --git a/lib/screens/realm.dart b/lib/screens/realm.dart index cf0753c..e67de33 100644 --- a/lib/screens/realm.dart +++ b/lib/screens/realm.dart @@ -81,8 +81,8 @@ class _RealmScreenState extends State { actions: [ IconButton( icon: !_isCompactView - ? const Icon(Icons.view_list) - : const Icon(Icons.view_module), + ? const Icon(Symbols.view_list) + : const Icon(Symbols.view_module), onPressed: () { setState(() => _isCompactView = !_isCompactView); }, diff --git a/lib/screens/realm/manage.dart b/lib/screens/realm/manage.dart index 6594cfb..d6ce4a2 100644 --- a/lib/screens/realm/manage.dart +++ b/lib/screens/realm/manage.dart @@ -191,7 +191,7 @@ class _RealmManageScreenState extends State { LoadingIndicator(isActive: _isBusy), if (_editingRealm != null) MaterialBanner( - leading: const Icon(Icons.edit), + leading: const Icon(Symbols.edit), leadingPadding: const EdgeInsets.only(left: 10, right: 20), dividerColor: Colors.transparent, content: Text( diff --git a/lib/widgets/attachment/attachment_item.dart b/lib/widgets/attachment/attachment_item.dart index 4b7e934..367018c 100644 --- a/lib/widgets/attachment/attachment_item.dart +++ b/lib/widgets/attachment/attachment_item.dart @@ -232,7 +232,7 @@ class _AttachmentItemContentVideoState ) else const Center( - child: Icon(Icons.movie, size: 64), + child: Icon(Symbols.movie, size: 64), ), Align( alignment: Alignment.bottomCenter, @@ -397,7 +397,7 @@ class _AttachmentItemContentAudioState ) else const Center( - child: Icon(Icons.radio, size: 64), + child: Icon(Symbols.radio, size: 64), ), Align( alignment: Alignment.bottomCenter, @@ -485,7 +485,7 @@ class _AttachmentItemContentAudioState child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon(Icons.audio_file, size: 32), + const Icon(Symbols.audio_file, size: 32), const Gap(8), Text( widget.data.alt, @@ -554,8 +554,8 @@ class _AttachmentItemContentAudioState const Gap(16), IconButton.filled( icon: _isPlaying - ? const Icon(Icons.pause) - : const Icon(Icons.play_arrow), + ? const Icon(Symbols.pause) + : const Icon(Symbols.play_arrow), onPressed: () { _audioPlayer!.playOrPause(); }, diff --git a/lib/widgets/post/post_comment_list.dart b/lib/widgets/post/post_comment_list.dart index 8cb58a5..f74c451 100644 --- a/lib/widgets/post/post_comment_list.dart +++ b/lib/widgets/post/post_comment_list.dart @@ -98,6 +98,9 @@ class PostCommentSliverListState extends State { child: PostItem( data: _posts[idx], maxWidth: widget.maxWidth, + onChanged: (data) { + setState(() => _posts[idx] = data); + }, ), onTap: () { GoRouter.of(context).pushNamed( diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 47b155a..b41212f 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -106,9 +106,14 @@ class _PostBottomAction extends StatelessWidget { children: [ Icon(Symbols.add_reaction, size: 20, color: iconColor), const Gap(8), - if (data.totalDownvote > 0 || data.totalUpvote > 0) - Text('postReactionPoints').plural( - data.totalUpvote - data.totalDownvote, + if (data.totalUpvote > 0 && + data.totalUpvote >= data.totalDownvote) + Text('postReactionUpvote').plural( + data.totalUpvote, + ) + else if (data.totalDownvote > 0) + Text('postReactionDownvote').plural( + data.totalDownvote, ) else Text('postReact').tr(), @@ -119,12 +124,12 @@ class _PostBottomAction extends StatelessWidget { context: context, builder: (context) => PostReactionPopup( data: data, - onChanged: (value, isPositive, delta) { + onChanged: (value, attr, delta) { onChanged(data.copyWith( - totalUpvote: isPositive + totalUpvote: attr == 1 ? data.totalUpvote + delta : data.totalUpvote, - totalDownvote: !isPositive + totalDownvote: attr == 2 ? data.totalDownvote + delta : data.totalDownvote, metric: data.metric.copyWith(reactionList: value), diff --git a/lib/widgets/post/post_reaction.dart b/lib/widgets/post/post_reaction.dart index 232a34b..4910f0c 100644 --- a/lib/widgets/post/post_reaction.dart +++ b/lib/widgets/post/post_reaction.dart @@ -11,7 +11,7 @@ import 'package:surface/widgets/dialog.dart'; class PostReactionPopup extends StatefulWidget { final SnPost data; - final Function(Map value, bool isPositive, int delta)? onChanged; + final Function(Map value, int attr, int delta)? onChanged; const PostReactionPopup({super.key, required this.data, this.onChanged}); @override @@ -43,7 +43,7 @@ class _PostReactionPopupState extends State { if (widget.onChanged != null) { widget.onChanged!( _reactions, - kTemplateReactions[symbol]!.attitude == 1, + kTemplateReactions[symbol]!.attitude, 1, ); } @@ -54,7 +54,7 @@ class _PostReactionPopupState extends State { if (widget.onChanged != null) { widget.onChanged!( _reactions, - kTemplateReactions[symbol]!.attitude == 1, + kTemplateReactions[symbol]!.attitude, -1, ); } @@ -89,11 +89,36 @@ class _PostReactionPopupState extends State { .textStyle(Theme.of(context).textTheme.titleLarge!), ], ).padding(horizontal: 20, top: 16, bottom: 12), + Container( + color: Theme.of(context).colorScheme.surfaceContainer, + child: Row( + children: [ + const Icon(Symbols.thumb_up, size: 16), + const Gap(8), + Text('postReactionUpvote').plural(widget.data.totalUpvote), + const Gap(24), + const Icon(Symbols.thumb_down, size: 16), + const Gap(8), + Text('postReactionDownvote').plural(widget.data.totalDownvote), + const Gap(24), + Icon( + widget.data.totalUpvote >= widget.data.totalDownvote + ? Symbols.trending_up + : Symbols.trending_down, + size: 16, + ), + const Gap(8), + Text('postReactionSocialPoint').plural( + widget.data.totalUpvote - widget.data.totalDownvote, + ), + ], + ).padding(vertical: 8, horizontal: 24), + ), Expanded( - child: GridView.count( + child: GridView.extent( crossAxisSpacing: 4, mainAxisSpacing: 4, - crossAxisCount: 4, + maxCrossAxisExtent: 120, children: kTemplateReactions.entries.map((e) { return InkWell( onTap: () {