Skip to content

Refine menu bar ticker settings#5

Open
1254455745 wants to merge 1 commit into
TNT-Likely:mainfrom
1254455745:split/menu-ticker-settings
Open

Refine menu bar ticker settings#5
1254455745 wants to merge 1 commit into
TNT-Likely:mainfrom
1254455745:split/menu-ticker-settings

Conversation

@1254455745
Copy link
Copy Markdown

@1254455745 1254455745 commented May 31, 2026

Summary by CodeRabbit

发行说明

  • 新功能
    • 菜单栏Ticker显示内容可自定义:新增切换开关,支持独立控制应用图标、股票代码和股票名称的显示
    • 设置面板新增"显示内容"配置区域
    • 提升版本兼容性,确保旧版设置平稳升级

@pullfrog
Copy link
Copy Markdown

pullfrog Bot commented May 31, 2026

Review mode finished without calling create_pull_request_review after 3 retry attempts

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using DeepSeek Flash𝕏

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 80f66175-e7b3-485c-a968-70d4945ad37a

📥 Commits

Reviewing files that changed from the base of the PR and between e3f1083 and 97d12bb.

📒 Files selected for processing (11)
  • PanBar/Data/Persistence/Repositories/SettingsRepository.swift
  • PanBar/Infrastructure/TickerPreferences.swift
  • PanBar/MenuBar/CarouselTickerView.swift
  • PanBar/MenuBar/CompactTickerView.swift
  • PanBar/MenuBar/MenuBarTickerView.swift
  • PanBar/MenuBar/MinimalTickerView.swift
  • PanBar/MenuBar/StatusItemController.swift
  • PanBar/MenuBar/TickerRenderer.swift
  • PanBar/MenuBar/TickerView.swift
  • PanBar/Resources/Localizable.xcstrings
  • PanBar/Settings/Panes/TickerPane.swift
✅ Files skipped from review due to trivial changes (1)
  • PanBar/Resources/Localizable.xcstrings

📝 Walkthrough

Walkthrough

本PR为Ticker菜单栏显示内容实现可配置化:新增持久化配置key与业务模型属性,通过协议要求与视图实现支持动态图标显示,并在内容渲染与用户设置界面中完整集成这些选项。

Changes

Ticker显示项配置与视图适配

Layer / File(s) Summary
持久化配置与TickerPreferences模型
PanBar/Data/Persistence/Repositories/SettingsRepository.swift, PanBar/Infrastructure/TickerPreferences.swift
SettingsRepository新增3个ticker显示项配置key(图标/代码/名称),TickerPreferences添加对应的@published属性并在didSet时持久化;初始化时处理旧版scrollNoCode模式的规范化,为TickerDisplayMode枚举添加scrollNoCode分支与allCases支持。
MenuBar Ticker协议与TickerView基础实现
PanBar/MenuBar/MenuBarTickerView.swift, PanBar/MenuBar/TickerView.swift
MenuBarTickerView协议增加showsIcon可读写属性,TickerView重构totalWidth与leadingTextX计算逻辑以根据showsIcon动态调整文本起始偏移,条件绘制图标并按新的leadingTextX定位文本矩形。
Carousel、Compact、Minimal视图布局适配
PanBar/MenuBar/CarouselTickerView.swift, PanBar/MenuBar/CompactTickerView.swift, PanBar/MenuBar/MinimalTickerView.swift
三个视图类分别添加showsIcon属性,改造totalWidth计算基于showsIcon切换的leadingTextX,draw()方法条件绘制图标并按leadingTextX计算文本起点,隐私遮蔽时省略号位置也依赖新的leadingTextX偏移。
TickerRenderer显示开关与行情内容渲染
PanBar/MenuBar/TickerRenderer.swift
新增showsQuoteCode与showsQuoteName两个显示控制开关(默认true),piece(for:Quote)方法改为有条件地拼接股票代码与名称。
StatusItemController配置应用与模式处理
PanBar/MenuBar/StatusItemController.swift
applyPrefs()在构建TickerRenderer时传入显示开关偏好,makeView()与render()将.scrollNoCode与.scroll合并至同一分支。
设置界面与本地化资源
PanBar/Resources/Localizable.xcstrings, PanBar/Settings/Panes/TickerPane.swift
TickerPane新增ticker.contentSection分组展示showAppIcon开关,showQuoteCode/showQuoteName显示条件绑定到showsQuoteContentControls(包含.scrollNoCode),Localizable.xcstrings新增4个显示内容相关的本地化字符串。

Sequence Diagram(s)

无。本PR采用属性驱动的声明式设计,不涉及多组件的顺序交互流程。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

小兔翻山又越岭,🐰
菜单栏的装扮更灵动,
图标代码名字可隐显,
持久保存心意盛,
布局计算随心定。 ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了此次 PR 的主要目标:细化菜单栏 ticker 的配置选项,涵盖了新增的 showAppIcon、showQuoteCode、showQuoteName 等细粒度开关,以及相关的 UI 和逻辑调整。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@PanBar/Infrastructure/TickerPreferences.swift`:
- Around line 170-173: The migration maps storedDisplayMode == .scrollNoCode to
.scroll but only migrates/writes back when migratesMinimal is true; update the
migration in the initializer/where displayMode is set so that when
storedDisplayMode == .scrollNoCode you also call
repo.set(SettingsRepository.Keys.tickerDisplayMode,
TickerDisplayMode.scroll.rawValue) (similar to the migratesMinimal branch) to
persist the migrated value and prevent showQuoteCode from being repeatedly
reset; make the same persistence change in the corresponding mirror block around
the displayMode handling at the 177-181 region.

In `@PanBar/Settings/Panes/TickerPane.swift`:
- Around line 75-82: The UI currently shows the width Stepper for both .compact
and .minimal in TickerPane.swift even though StatusItemController.swift
explicitly ignores width in the .minimal branch (preferredTotalWidth = nil), so
hide the width control for .minimal: change the switch handling of .compact and
.minimal (or add an explicit if) so that Toggle(L(...), isOn:
$prefs.compactAutoWidth) can remain, but the Stepper(value:
$prefs.compactMenuBarWidth, ...) is only rendered when the mode is .compact
(i.e., show Stepper only when current mode == .compact), preventing users from
editing an option that StatusItemController ignores.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 019b8f13-943e-4d75-890a-25cbacd3c633

📥 Commits

Reviewing files that changed from the base of the PR and between b6c2792 and e3f1083.

📒 Files selected for processing (12)
  • PanBar/Data/Persistence/Repositories/SettingsRepository.swift
  • PanBar/Infrastructure/TickerPreferences.swift
  • PanBar/MenuBar/CarouselTickerView.swift
  • PanBar/MenuBar/CompactTickerView.swift
  • PanBar/MenuBar/MenuBarTickerView.swift
  • PanBar/MenuBar/MinimalTickerView.swift
  • PanBar/MenuBar/StatusItemController.swift
  • PanBar/MenuBar/TickerRenderer.swift
  • PanBar/MenuBar/TickerView.swift
  • PanBar/Popover/PopoverController.swift
  • PanBar/Resources/Localizable.xcstrings
  • PanBar/Settings/Panes/TickerPane.swift

Comment on lines +170 to +173
self.displayMode = storedDisplayMode == .scrollNoCode ? .scroll : (migratesMinimal ? .compact : storedDisplayMode)
if migratesMinimal {
try? repo.set(SettingsRepository.Keys.tickerDisplayMode, TickerDisplayMode.compact.rawValue)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

scrollNoCode 迁移未落库,showQuoteCode 会被反复重置

Line 170 把旧值映射成 .scroll,但只有 .minimal 分支在 Line 171-173 做了写回。当前实现会让 storedDisplayMode 长期停留在 .scrollNoCode,并在 Line 177 每次启动都强制 showQuoteCode = false,覆盖用户后续设置。建议在 scrollNoCode 分支同样做一次迁移写回。

🔧 建议修改
-        self.displayMode = storedDisplayMode == .scrollNoCode ? .scroll : (migratesMinimal ? .compact : storedDisplayMode)
+        let migratesScrollNoCode = storedDisplayMode == .scrollNoCode
+        self.displayMode = migratesScrollNoCode ? .scroll : (migratesMinimal ? .compact : storedDisplayMode)
+        if migratesScrollNoCode {
+            try? repo.set(SettingsRepository.Keys.tickerDisplayMode, TickerDisplayMode.scroll.rawValue)
+        }
         if migratesMinimal {
             try? repo.set(SettingsRepository.Keys.tickerDisplayMode, TickerDisplayMode.compact.rawValue)
         }

Also applies to: 177-181

🤖 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 `@PanBar/Infrastructure/TickerPreferences.swift` around lines 170 - 173, The
migration maps storedDisplayMode == .scrollNoCode to .scroll but only
migrates/writes back when migratesMinimal is true; update the migration in the
initializer/where displayMode is set so that when storedDisplayMode ==
.scrollNoCode you also call repo.set(SettingsRepository.Keys.tickerDisplayMode,
TickerDisplayMode.scroll.rawValue) (similar to the migratesMinimal branch) to
persist the migrated value and prevent showQuoteCode from being repeatedly
reset; make the same persistence change in the corresponding mirror block around
the displayMode handling at the 177-181 region.

Comment thread PanBar/Settings/Panes/TickerPane.swift Outdated
Comment on lines +75 to +82
case .compact, .minimal:
Toggle(L("ticker.autoMenuBarWidth", comment: ""), isOn: $prefs.compactAutoWidth)
if !prefs.compactAutoWidth {
Stepper(value: $prefs.compactMenuBarWidth, in: 60...360, step: 20) {
Text(String(format: L("ticker.menuBarWidth", comment: ""), prefs.compactMenuBarWidth))
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

.minimal 下的宽度设置当前是无效控件

这里把 .compact.minimal 绑定到同一组宽度控件,但下游 PanBar/MenuBar/StatusItemController.swift.minimal 分支固定不应用宽度(preferredTotalWidth = nil)。这会让用户在 minimal 模式下改设置却看不到效果。

🔧 建议修改(先避免暴露无效控件)
-                case .compact, .minimal:
+                case .compact:
                     Toggle(L("ticker.autoMenuBarWidth", comment: ""), isOn: $prefs.compactAutoWidth)
                     if !prefs.compactAutoWidth {
                         Stepper(value: $prefs.compactMenuBarWidth, in: 60...360, step: 20) {
                             Text(String(format: L("ticker.menuBarWidth", comment: ""), prefs.compactMenuBarWidth))
                         }
                     }
+                case .minimal:
+                    EmptyView()
                 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case .compact, .minimal:
Toggle(L("ticker.autoMenuBarWidth", comment: ""), isOn: $prefs.compactAutoWidth)
if !prefs.compactAutoWidth {
Stepper(value: $prefs.compactMenuBarWidth, in: 60...360, step: 20) {
Text(String(format: L("ticker.menuBarWidth", comment: ""), prefs.compactMenuBarWidth))
}
}
}
case .compact:
Toggle(L("ticker.autoMenuBarWidth", comment: ""), isOn: $prefs.compactAutoWidth)
if !prefs.compactAutoWidth {
Stepper(value: $prefs.compactMenuBarWidth, in: 60...360, step: 20) {
Text(String(format: L("ticker.menuBarWidth", comment: ""), prefs.compactMenuBarWidth))
}
}
case .minimal:
EmptyView()
}
🤖 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 `@PanBar/Settings/Panes/TickerPane.swift` around lines 75 - 82, The UI
currently shows the width Stepper for both .compact and .minimal in
TickerPane.swift even though StatusItemController.swift explicitly ignores width
in the .minimal branch (preferredTotalWidth = nil), so hide the width control
for .minimal: change the switch handling of .compact and .minimal (or add an
explicit if) so that Toggle(L(...), isOn: $prefs.compactAutoWidth) can remain,
but the Stepper(value: $prefs.compactMenuBarWidth, ...) is only rendered when
the mode is .compact (i.e., show Stepper only when current mode == .compact),
preventing users from editing an option that StatusItemController ignores.

@TNT-Likely
Copy link
Copy Markdown
Owner

@1254455745 原来的极简风格不要删除

@1254455745
Copy link
Copy Markdown
Author

ScreenShot_2026-06-01_170814_618 我看那个极简和固定区别不大,就多安排了几个按钮,可以手动调整出来 你看看需不需要吧

@TNT-Likely
Copy link
Copy Markdown
Owner

@1254455745 可以拆一下 比如那个自动宽度 我认为还是可以的 几个几个开关也是 你拆的越细越好

@1254455745 1254455745 force-pushed the split/menu-ticker-settings branch from e3f1083 to 97d12bb Compare June 2, 2026 16:44
Copy link
Copy Markdown

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — the single-commit incremental delta adds three menu bar content display toggles (app icon, stock code, stock name) with migration from the legacy scrollNoCode display mode to the new showQuoteCode-based model.

  • Add showAppIcon, showQuoteCode, showQuoteName toggles — new SettingsRepository keys, TickerPreferences properties with auto-persist, and corresponding UI in the Ticker settings pane
  • Deprecate scrollNoCode display mode — migration maps the old .scrollNoCode case to .scroll on init, using the displayMode didSet observer to persist the migrated value; initial showQuoteCode defaults to false for users coming from .scrollNoCode
  • Add showsIcon to MenuBarTickerView protocol — all four ticker view types (TickerView, CarouselTickerView, CompactTickerView, MinimalTickerView) adopt it, and StatusItemController.applyPrefs() sets it from prefs.showAppIcon
  • Add showsQuoteCode/showsQuoteName to TickerRenderer — conditional rendering of stock code and name in the quote-attributed string
  • Conditional settings UIshowsQuoteContentControls computed property guards the stock code/name toggles, showing them only for .scroll/.carousel modes
  • Update localization strings — English and Simplified Chinese entries for the three new toggles and the "Display Content" section header

Pullfrog  | View workflow run | Using DeepSeek Flash𝕏

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.

2 participants