🐛 Bug fixes and translation

This commit is contained in:
LittleSheep 2024-04-15 23:40:36 +08:00
parent 7e42d95904
commit d2ae4f3292
6 changed files with 37 additions and 30 deletions

View File

@ -13,6 +13,8 @@
"delete": "Delete", "delete": "Delete",
"action": "Action", "action": "Action",
"report": "Report", "report": "Report",
"reaction": "Reaction",
"reactVerb": "React",
"post": "Post", "post": "Post",
"postVerb": "Post", "postVerb": "Post",
"comment": "Comment", "comment": "Comment",
@ -23,5 +25,7 @@
"newComment": "Leave a comment", "newComment": "Leave a comment",
"postIdentityNotify": "You will create this post as", "postIdentityNotify": "You will create this post as",
"postContentPlaceholder": "What's happened?!", "postContentPlaceholder": "What's happened?!",
"postDeleteConfirm": "Are you sure you want to delete this post? This operation cannot be revert!" "postDeleteConfirm": "Are you sure you want to delete this post? This operation cannot be revert!",
"reactionAdded": "Your reaction has been added.",
"reactionRemoved": "Your reaction has been removed."
} }

View File

@ -13,6 +13,8 @@
"delete": "删除", "delete": "删除",
"action": "操作", "action": "操作",
"report": "举报", "report": "举报",
"reaction": "反应",
"reactVerb": "作出反应",
"post": "帖子", "post": "帖子",
"postVerb": "发表", "postVerb": "发表",
"comment": "评论", "comment": "评论",
@ -23,5 +25,7 @@
"newComment": "留下评论", "newComment": "留下评论",
"postIdentityNotify": "你将会以该身份发表本帖子", "postIdentityNotify": "你将会以该身份发表本帖子",
"postContentPlaceholder": "发生什么事了?!", "postContentPlaceholder": "发生什么事了?!",
"postDeleteConfirm": "你确定要删除这篇帖子吗?这意味着这个帖子将永远被我们丢弃在硬盘海中!该操作不可被反转!" "postDeleteConfirm": "你确定要删除这篇帖子吗?这意味着这个帖子将永远被我们丢弃在硬盘海中!该操作不可被反转!",
"reactionAdded": "你的反应已被添加。",
"reactionRemoved": "你的反应已被移除。"
} }

View File

@ -7,6 +7,7 @@ class ReactInfo {
final Map<String, ReactInfo> reactions = { final Map<String, ReactInfo> reactions = {
'thumb_up': ReactInfo(icon: '👍', attitude: 1), 'thumb_up': ReactInfo(icon: '👍', attitude: 1),
'thumb_down': ReactInfo(icon: '👎', attitude: -1), 'thumb_down': ReactInfo(icon: '👎', attitude: 2),
'just_okay': ReactInfo(icon: '😅', attitude: 0),
'clap': ReactInfo(icon: '👏', attitude: 1), 'clap': ReactInfo(icon: '👏', attitude: 1),
}; };

View File

@ -62,26 +62,22 @@ class _PostItemState extends State<PostItem> {
} }
Widget renderReactions() { Widget renderReactions() {
if (reactionList != null && reactionList!.isNotEmpty) { return Container(
return Container( height: 48,
height: 48, padding: const EdgeInsets.only(top: 8, left: 4, right: 4),
padding: const EdgeInsets.only(top: 8, left: 4, right: 4), child: ReactionList(
child: ReactionList( item: widget.item,
item: widget.item, reactionList: reactionList,
reactionList: reactionList, onReact: (symbol, changes) {
onReact: (symbol, changes) { setState(() {
setState(() { if (!reactionList!.containsKey(symbol)) {
if (!reactionList!.containsKey(symbol)) { reactionList![symbol] = 0;
reactionList![symbol] = 0; }
} reactionList![symbol] += changes;
reactionList![symbol] += changes; });
}); },
}, ),
), );
);
} else {
return Container();
}
} }
String getAuthorDescribe() => widget.item.author.description.isNotEmpty String getAuthorDescribe() => widget.item.author.description.isNotEmpty

View File

@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'package:solian/models/reaction.dart'; import 'package:solian/models/reaction.dart';
import 'package:solian/providers/auth.dart'; import 'package:solian/providers/auth.dart';
import 'package:solian/utils/service_url.dart'; import 'package:solian/utils/service_url.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Future<void> doReact( Future<void> doReact(
String dataset, String dataset,
@ -36,19 +37,19 @@ Future<void> doReact(
if (res.statusCode == 201) { if (res.statusCode == 201) {
onReact(symbol, 1); onReact(symbol, 1);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( SnackBar(
content: Text("Your reaction has been added onto this post."), content: Text(AppLocalizations.of(context)!.reactionAdded),
), ),
); );
} else if (res.statusCode == 204) { } else if (res.statusCode == 204) {
onReact(symbol, -1); onReact(symbol, -1);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( SnackBar(
content: Text("Your reaction has been removed from this post."), content: Text(AppLocalizations.of(context)!.reactionRemoved),
), ),
); );
} else { } else {
var message = utf8.decode(res.bodyBytes); final message = utf8.decode(res.bodyBytes);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Something went wrong... $message")), SnackBar(content: Text("Something went wrong... $message")),
); );
@ -112,7 +113,7 @@ class _ReactionActionPopupState extends State<ReactionActionPopup> {
vertical: 12, vertical: 12,
), ),
child: Text( child: Text(
'Add a reaction', AppLocalizations.of(context)!.reaction,
style: Theme.of(context).textTheme.headlineSmall, style: Theme.of(context).textTheme.headlineSmall,
), ),
), ),

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:solian/models/post.dart'; import 'package:solian/models/post.dart';
import 'package:solian/models/reaction.dart'; import 'package:solian/models/reaction.dart';
import 'package:solian/widgets/posts/reaction_action.dart'; import 'package:solian/widgets/posts/reaction_action.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class ReactionList extends StatefulWidget { class ReactionList extends StatefulWidget {
final Post item; final Post item;
@ -79,7 +80,7 @@ class _ReactionListState extends State<ReactionList> {
}), }),
ActionChip( ActionChip(
avatar: const Icon(Icons.add_reaction, color: Colors.teal), avatar: const Icon(Icons.add_reaction, color: Colors.teal),
label: const Text("React"), label: Text(AppLocalizations.of(context)!.reactVerb),
visualDensity: density, visualDensity: density,
onPressed: () => viewReactMenu(context), onPressed: () => viewReactMenu(context),
), ),