diff --git a/assets/translations/en.json b/assets/translations/en.json index 4bae1aa..0cd4d45 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -242,5 +242,30 @@ "dailyCheckIn": "Check In", "dailyCheckInNone": "You haven't checked in today", "dailyCheckAction": "Check in right now!", - "dailyCheckDetail": "Can't understand the talisman? Master, help me understand it!" + "dailyCheckDetail": "Can't understand the symbol? Master, help me understand it!", + "dailyCheckDetailTitle": "{}'s fortune details", + "dailyCheckPositiveHint1": "Making friends", + "dailyCheckPositiveHint1Description": "Friendship lasts forever", + "dailyCheckPositiveHint2": "Drinking", + "dailyCheckPositiveHint2Description": "Drinking under the moonlight with an imaginary companion", + "dailyCheckPositiveHint3": "Traveling", + "dailyCheckPositiveHint3Description": "A journey of a thousand miles begins with a single step", + "dailyCheckPositiveHint4": "Exercising", + "dailyCheckPositiveHint4Description": "Life lies in movement", + "dailyCheckPositiveHint5": "Learning", + "dailyCheckPositiveHint5Description": "Knowledge knows no bounds; progress every day", + "dailyCheckPositiveHint6": "Planting", + "dailyCheckPositiveHint6Description": "Sow hope, reap the future", + "dailyCheckNegativeHint1": "Eating", + "dailyCheckNegativeHint1Description": "Biting your tongue while eating", + "dailyCheckNegativeHint2": "Taking exams", + "dailyCheckNegativeHint2Description": "The exam covered what you didn't review", + "dailyCheckNegativeHint3": "Catching a bus", + "dailyCheckNegativeHint3Description": "Just missed the bus", + "dailyCheckNegativeHint4": "Shopping", + "dailyCheckNegativeHint4Description": "Bought clothes that don't fit", + "dailyCheckNegativeHint5": "Gaming", + "dailyCheckNegativeHint5Description": "Lost connection at a crucial moment", + "dailyCheckNegativeHint6": "Going out", + "dailyCheckNegativeHint6Description": "Forgot your umbrella and got caught in the rain" } diff --git a/assets/translations/zh.json b/assets/translations/zh.json index f899f95..742accb 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -242,5 +242,32 @@ "dailyCheckIn": "每日签到", "dailyCheckInNone": "今日尚未签到", "dailyCheckAction": "现在签到", - "dailyCheckDetail": "看不懂符?大师帮我解惑!" + "dailyCheckDetail": "看不懂符?大师帮我解惑!", + "dailyCheckDetailTitle": "{} 的运势详情", +"dailyCheckPositiveHint": "宜 {}", +"dailyCheckNegativeHint": "忌 {}", + "dailyCheckPositiveHint1": "交友", + "dailyCheckPositiveHint1Description": "友谊地久天长", + "dailyCheckPositiveHint2": "饮酒", + "dailyCheckPositiveHint2Description": "对影成三人", + "dailyCheckPositiveHint3": "旅行", + "dailyCheckPositiveHint3Description": "千里之行,始于足下", + "dailyCheckPositiveHint4": "运动", + "dailyCheckPositiveHint4Description": "生命在于运动", + "dailyCheckPositiveHint5": "学习", + "dailyCheckPositiveHint5Description": "学无止境,日有所进", + "dailyCheckPositiveHint6": "种植", + "dailyCheckPositiveHint6Description": "种下希望,收获未来", + "dailyCheckNegativeHint1": "吃饭", + "dailyCheckNegativeHint1Description": "吃饭咬到舌头", + "dailyCheckNegativeHint2": "考试", + "dailyCheckNegativeHint2Description": "考的东西刚好没复习", + "dailyCheckNegativeHint3": "坐公交", + "dailyCheckNegativeHint3Description": "赶车刚好错过一班", + "dailyCheckNegativeHint4": "购物", + "dailyCheckNegativeHint4Description": "买回来的衣服发现不合适", + "dailyCheckNegativeHint5": "打游戏", + "dailyCheckNegativeHint5Description": "关键时刻断网", + "dailyCheckNegativeHint6": "出门", + "dailyCheckNegativeHint6Description": "忘带伞遇上大雨" } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 5c9a7dc..8a29d09 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -1,5 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; +import 'package:gap/gap.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:material_symbols_icons/symbols.dart'; import 'package:provider/provider.dart'; @@ -90,6 +91,9 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { SnCheckInRecord? _todayRecord; + static const int kSuggestionPositiveHintCount = 6; + static const int kSuggestionNegativeHintCount = 6; + Future _pullCheckIn() async { setState(() => _isBusy = true); try { @@ -118,6 +122,64 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { } } + Widget _buildDetailChunk(int index, bool positive) { + final prefix = + positive ? 'dailyCheckPositiveHint' : 'dailyCheckNegativeHint'; + final mod = + positive ? kSuggestionPositiveHintCount : kSuggestionNegativeHintCount; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + prefix.tr(args: [ + '$prefix${_todayRecord!.resultModifiers[index] % mod}'.tr() + ]), + style: Theme.of(context) + .textTheme + .titleMedium! + .copyWith(fontWeight: FontWeight.bold), + ).tr(), + Text( + '$prefix${_todayRecord!.resultModifiers[index] % kSuggestionPositiveHintCount}Description', + style: Theme.of(context).textTheme.bodyMedium, + ).tr(), + ], + ); + } + + void _showCheckInDetail() { + showDialog( + useRootNavigator: true, + context: context, + builder: (context) { + return AlertDialog( + title: Text('dailyCheckDetailTitle'.tr(args: [ + DateFormat('MM/dd').format(DateTime.now().toUtc()), + ])), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + _buildDetailChunk(0, true), + const Gap(8), + _buildDetailChunk(1, true), + const Gap(8), + _buildDetailChunk(2, false), + const Gap(8), + _buildDetailChunk(3, false), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text('dialogDismiss').tr(), + ) + ], + ); + }, + ); + } + @override void initState() { super.initState(); @@ -169,7 +231,7 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { Text( '+${_todayRecord!.resultExperience} EXP', style: Theme.of(context).textTheme.bodyLarge, - ).tr(), + ), ], ), ), @@ -201,7 +263,7 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { key: UniqueKey(), tooltip: 'dailyCheckDetail'.tr(), icon: const Icon(Symbols.help), - onPressed: _isBusy ? null : _doCheckIn, + onPressed: _showCheckInDetail, ), ), ),