Conversation
|
Too many files changed? Review this PR in Change Stack to see how the pieces fit before you dive in. 📝 WalkthroughWalkthroughThis PR introduces a ToastUtil wrapper around the fluttertoast library and systematically replaces Get.snackbar notifications across the application with toast-based feedback. The default timer mode is switched from random_break to pomodoro, and the settings page layout is reorganized to reflect this priority. ChangesToast Notification Refactor and Settings Reorganization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a unified ToastUtil wrapper using the fluttertoast package to replace Get.snackbar notifications across the app. It also changes the default timer mode to Pomodoro, reorders the home page mode chips, and reorganizes the settings page layout. Feedback is provided to improve the robustness of the backup path truncation logic and to enhance the user experience in settings validation by using error messages instead of silently overriding conflicting interval inputs.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // 原生 Toast 对超长无空格路径会截断,只展示外部存储根(/0/)之后的关键路径 | ||
| final shownPath = backupPath.split('/0/').last; |
There was a problem hiding this comment.
使用 split('/0/').last 来截断备份路径可能不够健壮。如果路径中包含其他带有 /0/ 的片段(例如 Android 应用私有存储路径 /data/user/0/... 或用户创建的名为 0 的文件夹),它会进行错误的分割,从而导致显示不完整或具有误导性的路径。
更健壮的方法是专门检查并移除标准的 Android 外部存储根路径前缀(/storage/emulated/0/)。
| // 原生 Toast 对超长无空格路径会截断,只展示外部存储根(/0/)之后的关键路径 | |
| final shownPath = backupPath.split('/0/').last; | |
| // 原生 Toast 对超长无空格路径会截断,只展示外部存储根(/storage/emulated/0/)之后的关键路径 | |
| final shownPath = backupPath.startsWith('/storage/emulated/0/') | |
| ? backupPath.replaceFirst('/storage/emulated/0/', '') | |
| : backupPath; |
| if (microBreakIntervalMinMinutes.value > microBreakIntervalMaxMinutes.value) { | ||
| microBreakIntervalMinMinutes.value = microBreakIntervalMaxMinutes.value; | ||
| microBreakIntervalMinController.text = microBreakIntervalMinMinutes.value.toString(); | ||
| Get.snackbar( | ||
| '设置已调整', | ||
| '最小间隔不能大于最大间隔,已调整为相同值', | ||
| snackPosition: SnackPosition.TOP, | ||
| barBlur: 100, | ||
| duration: Duration(seconds: 2), | ||
| ); | ||
| ToastUtil.show('设置已调整', '最小间隔不能大于最大间隔,已调整为相同值'); | ||
| } |
There was a problem hiding this comment.
在失去焦点时静默覆盖用户的输入并弹出 Toast 提示,可能会给用户带来非常挫败的体验。例如,当用户想要同时调大最小和最大间隔(例如在当前最大间隔为 5 的情况下,将最小间隔改为 10,最大间隔改为 15),一旦他们编辑完最小间隔并切换焦点到最大间隔输入框时,他们的输入就会被强制重置回 5。
相比于自动调整数值并弹出 Toast,更好的做法是设置一个验证错误信息(microBreakIntervalMinError)并将表单标记为无效(isValid = false)。这样可以允许用户在保存前自然地编辑这两个字段并解决冲突。
if (microBreakIntervalMinMinutes.value > microBreakIntervalMaxMinutes.value) {
microBreakIntervalMinError.value = '最小间隔不能大于最大间隔';
isValid = false;
}There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/utils/toast_util.dart (1)
14-24: ⚡ Quick winConsider handling edge cases for empty title or message.
The current logic concatenates
titleandmessagewith a newline whentitleis non-empty. If a caller provides a non-emptytitlebut an emptymessage, the toast will display with a trailing newline (e.g.,"Title\n"). While all current call sites provide both parameters, defensive handling would improve robustness.🛡️ Suggested defensive implementation
static void show( String title, String message, { Toast toastLength = Toast.LENGTH_SHORT, }) { + final displayMsg = title.isEmpty + ? message + : (message.isEmpty ? title : '$title\n$message'); Fluttertoast.showToast( - msg: title.isEmpty ? message : '$title\n$message', + msg: displayMsg, toastLength: toastLength, gravity: ToastGravity.TOP, ); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/utils/toast_util.dart` around lines 14 - 24, The show method concatenates title and message unconditionally when title is non-empty, which can produce a trailing newline if message is empty; update the ToastUtil.show implementation to build the toast text defensively: use title alone when message.isEmpty, use message alone when title.isEmpty, and use '$title\n$message' only when both are non-empty before calling Fluttertoast.showToast (reference the static show function and the Fluttertoast.showToast call and parameters toastLength and gravity).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/utils/toast_util.dart`:
- Around line 14-24: The show method concatenates title and message
unconditionally when title is non-empty, which can produce a trailing newline if
message is empty; update the ToastUtil.show implementation to build the toast
text defensively: use title alone when message.isEmpty, use message alone when
title.isEmpty, and use '$title\n$message' only when both are non-empty before
calling Fluttertoast.showToast (reference the static show function and the
Fluttertoast.showToast call and parameters toastLength and gravity).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 04acd83a-c814-4188-b61c-94fa91680ffa
⛔ Files ignored due to path filters (1)
pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (12)
lib/config/storage_keys.dartlib/page/home/view.dartlib/page/main/controller.dartlib/page/setting/controller.dartlib/page/setting/state.dartlib/page/setting/view.dartlib/page/setting/widgets/data_settings.dartlib/page/setting/widgets/developer_settings.dartlib/page/setting/widgets/permission_settings.dartlib/page/sound_settings/controller.dartlib/utils/toast_util.dartpubspec.yaml
主要改动
本次PR包含以下核心改进:
1. 统一Toast提示封装
涉及文件:
2. 优化设置页面布局
3. 调整默认计时模式
4. 依赖更新
变更统计
Summary by CodeRabbit
New Features
Changes
Chores