Repository navigation
refactor(theme): 明 / 暗判定收进 AppPalette.isDark - #11
Merged
Merged
Conversation
「按 background 亮度 < 0.5 判暗」这条在仓里抄了 9 份:toDesktopTokens 里一份 取反、about_dialog 一份、查询页 / 对象面板 / 六个设计器各一份。about_dialog 的注释还写着「判据跟查询页 / 对象面板一致」——那是靠人记的约定,不是约束。 收成一个 getter,并补用例钉住「跟底色走、不跟 ThemeMode 走」:主题定制能把 「明亮」调成深底,走 Theme.of(brightness) 的实现会当场判错。
SpringHgui
force-pushed
the
refactor/theme-is-dark
branch
from
October 29, 2026 06:32
0fab6d1 to
3772cfd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
纯重构,不改任何观感:把「按
background亮度 < 0.5 判暗」这条口径收进AppPalette.isDark。原来它抄了 9 份:
app_theme.dart→toDesktopTokens()background.computeLuminance() > 0.5(取反)about_dialog.dartfinal dark = t.background.computeLuminance() < 0.5query_page/object_panel/ 六个设计器页final isDark = t.background.computeLuminance() < 0.5about_dialog的注释里原本写着「判据跟查询页 / 对象面板一致」——那是靠人记的约定,不是约束,改阈值或换判据时必然漏。改动
AppPalette.isDarkgetter(阈值与判据逐字不变,仍是background.computeLuminance() < 0.5)toDesktopTokens()里变成final light = !isDark;,面色分支与判定强制同源test/theme_palette_test.dart补一组用例:内置两套色板各归一边;判据跟底色走、不跟ThemeMode走(主题定制能把「明亮」调成深底,走Theme.of(brightness)的实现会判错);toDesktopTokens().buttonFaceColor与isDark同向Test plan
flutter analyze无 issue、flutter test全绿与 #10 的关系
两个 PR 都会碰
query_page等文件的同一区域,后合的那个需要 rebase:#10新增的lib/theme/sql_highlight.dart里也写了一遍同样的判据(palette.background.computeLuminance() < 0.5),届时改成palette.isDark。建议先合 #10(功能),再让本分支 rebase 后收掉那一处。