Skip to content

feat: add current time indicator.#127

Open
nkanf-dev wants to merge 4 commits intoBenderBlog:mainfrom
nkanf-dev:feat/current-time-indicator
Open

feat: add current time indicator.#127
nkanf-dev wants to merge 4 commits intoBenderBlog:mainfrom
nkanf-dev:feat/current-time-indicator

Conversation

@nkanf-dev
Copy link
Copy Markdown

@nkanf-dev nkanf-dev commented Apr 15, 2026

在课程表视图里添加了一个指示当前时间的指示条。

像这样(默认是关闭状态):
image

Copilot AI review requested due to automatic review settings April 15, 2026 06:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ClassTableView driven 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.

Comment thread lib/page/classtable/class_page/content_classtable_page.dart
Comment thread lib/page/classtable/class_table_view/class_table_view.dart Outdated
Comment on lines +213 to +216
Watch((context) {
final now = GlobalTimerController.i.currentTimeSignal.value;
if (classTableState.currentWeek != widget.index) {
return const SizedBox.shrink();
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

严禁在 lib/pages/classtable 组件下面用 watch 组件和任何 signal 相关的状态管理,去学 ChangeNotifier 和 InheritedWidget 如何管理状态

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenderBlog 您好,因为目前 GlobalTimerController 是基于 signal 的,不能直接接进去。请问我是自己在 ClassTableWidgetState 里面单独维护一个 Timer,还是去改 GlobalTimerController 让它支持 ChangeNotifier 好呢?

Copy link
Copy Markdown
Owner

@BenderBlog BenderBlog Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以在 ClassTableWidgetState 访问控制器的 Timer ,这个 State 专门用于接外面的控制器。接到了后,当其变化的时候,通知监听器,就是你那个当前时间指示器。这是一个大致思路。

Comment thread lib/page/classtable/class_table_view/class_table_view.dart Outdated
@BenderBlog
Copy link
Copy Markdown
Owner

最后再管合并冲突,俩翻译文件不是大问题。

@BenderBlog
Copy link
Copy Markdown
Owner

现在可以继续开发了,如果实在想不出来而且不想改了这里反馈,我合并了自己改。

@BenderBlog
Copy link
Copy Markdown
Owner

没问题,可以维护俩时钟

Co-authored-by: Copilot <copilot@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants