Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional “current time” horizontal indicator line to the classtable (schedule) view, gated behind a persisted user preference and exposed via the classtable popup menu.
Changes:
- Add a new boolean preference to enable/disable the current time indicator.
- Render a current-time indicator line in
ClassTableViewdriven by a global minute timer signal. - Add a popup menu toggle entry and new i18n strings (zh_CN/zh_TW/en_US) for the toggle label.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/repository/preference.dart |
Adds a persisted toggle flag for the current time indicator. |
lib/page/classtable/class_table_view/class_table_view.dart |
Draws the current-time indicator line and wires it to the preference + global timer signal. |
lib/page/classtable/class_table_view/class_organized_data.dart |
Exposes transferIndex(DateTime) for converting current time to a vertical position index. |
lib/page/classtable/class_page/content_classtable_page.dart |
Adds a popup menu item to toggle the indicator preference. |
assets/flutter_i18n/zh_TW.yaml |
Adds Traditional Chinese toggle labels. |
assets/flutter_i18n/zh_CN.yaml |
Adds Simplified Chinese toggle labels. |
assets/flutter_i18n/en_US.yaml |
Adds English toggle labels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Watch((context) { | ||
| final now = GlobalTimerController.i.currentTimeSignal.value; | ||
| if (classTableState.currentWeek != widget.index) { | ||
| return const SizedBox.shrink(); |
There was a problem hiding this comment.
now is read from currentTimeSignal before the early-returns, which means every ClassTableView page that gets built will subscribe to the global timer and rebuild every minute even when it immediately returns SizedBox.shrink() (e.g., non-current weeks or when the feature is disabled). Move the currentTimeSignal.value read to after the currentWeek / preference checks so only the current-week page subscribes and rebuilds.
There was a problem hiding this comment.
严禁在 lib/pages/classtable 组件下面用 watch 组件和任何 signal 相关的状态管理,去学 ChangeNotifier 和 InheritedWidget 如何管理状态
There was a problem hiding this comment.
@BenderBlog 您好,因为目前 GlobalTimerController 是基于 signal 的,不能直接接进去。请问我是自己在 ClassTableWidgetState 里面单独维护一个 Timer,还是去改 GlobalTimerController 让它支持 ChangeNotifier 好呢?
There was a problem hiding this comment.
可以在 ClassTableWidgetState 访问控制器的 Timer ,这个 State 专门用于接外面的控制器。接到了后,当其变化的时候,通知监听器,就是你那个当前时间指示器。这是一个大致思路。
|
最后再管合并冲突,俩翻译文件不是大问题。 |
|
现在可以继续开发了,如果实在想不出来而且不想改了这里反馈,我合并了自己改。 |
|
没问题,可以维护俩时钟 |
Co-authored-by: Copilot <copilot@github.com>
在课程表视图里添加了一个指示当前时间的指示条。
像这样(默认是关闭状态):
