diff --git a/assets/translations/en.json b/assets/translations/en.json index 9d9a7e5..aae381b 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -244,6 +244,8 @@ "dailyCheckAction": "Check in right now!", "dailyCheckDetail": "Can't understand the symbol? Master, help me understand it!", "dailyCheckDetailTitle": "{}'s fortune details", + "dailyCheckPositiveHint": "Good for {}", + "dailyCheckNegativeHint": "Bad for {}", "dailyCheckPositiveHint1": "Making friends", "dailyCheckPositiveHint1Description": "Friendship lasts forever", "dailyCheckPositiveHint2": "Drinking", diff --git a/assets/translations/zh.json b/assets/translations/zh.json index c5fe4b7..1c91e49 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -168,7 +168,7 @@ "fieldChatBelongToRealm": "所属领域", "fieldChatBelongToRealmUnset": "未设置频道所属领域", "channelEditingNotice": "您正在编辑频道 {}", - "channelDeleted": "聊天频道 {} 已被删除" , + "channelDeleted": "聊天频道 {} 已被删除", "channelDelete": "删除聊天频道 {}", "channelDeleteDescription": "你确定要删除这个聊天频道吗?该操作不可撤销,其频道内的所有消息将被永久删除。", "fieldRealmAlias": "领域别名", @@ -176,7 +176,7 @@ "fieldRealmName": "名称", "fieldRealmDescription": "描述", "realmEditingNotice": "您正在编辑领域 {}", - "realmDeleted": "领域 {} 已被删除" , + "realmDeleted": "领域 {} 已被删除", "realmDelete": "删除领域 {}", "realmDeleteDescription": "你确定要删除这个领域吗?该操作不可撤销,其隶属于该领域的所有资源(帖子、聊天频道、发布者、制品等)都将被永久删除。三思而后行!", "fieldChatMessage": "在 {} 中发消息", @@ -194,7 +194,7 @@ }, "addAttachmentFromAlbum": "从相册中添加附件", "addAttachmentFromClipboard": "粘贴附件", - "attachmentPastedImage" : "粘贴的图片", + "attachmentPastedImage": "粘贴的图片", "notificationUnread": "未读", "notificationRead": "已读", "notificationMarkAllRead": "已读所有通知", @@ -244,8 +244,8 @@ "dailyCheckAction": "现在签到", "dailyCheckDetail": "看不懂符?大师帮我解惑!", "dailyCheckDetailTitle": "{} 的运势详情", -"dailyCheckPositiveHint": "宜 {}", -"dailyCheckNegativeHint": "忌 {}", + "dailyCheckPositiveHint": "宜 {}", + "dailyCheckNegativeHint": "忌 {}", "dailyCheckPositiveHint1": "交友", "dailyCheckPositiveHint1Description": "友谊地久天长", "dailyCheckPositiveHint2": "饮酒", diff --git a/lib/screens/home.dart b/lib/screens/home.dart index c80ee22..9d2e6f1 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -1,3 +1,5 @@ +import 'dart:math' as math; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:gap/gap.dart'; @@ -140,9 +142,6 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { final sn = context.read(); final resp = await sn.client.get('/cgi/id/check-in/today'); _todayRecord = SnCheckInRecord.fromJson(resp.data); - } catch (err) { - if (!mounted) return; - context.showErrorDialog(err); } finally { setState(() => _isBusy = false); } @@ -167,20 +166,19 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { positive ? 'dailyCheckPositiveHint' : 'dailyCheckNegativeHint'; final mod = positive ? kSuggestionPositiveHintCount : kSuggestionNegativeHintCount; + final pos = math.max(1, _todayRecord!.resultModifiers[index] % mod); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - prefix.tr(args: [ - '$prefix${_todayRecord!.resultModifiers[index] % mod}'.tr() - ]), + prefix.tr(args: ['$prefix$pos'.tr()]), style: Theme.of(context) .textTheme .titleMedium! .copyWith(fontWeight: FontWeight.bold), ).tr(), Text( - '$prefix${_todayRecord!.resultModifiers[index] % kSuggestionPositiveHintCount}Description', + '$prefix${pos}Description', style: Theme.of(context).textTheme.bodyMedium, ).tr(), ],