feat(client): Phase 0.4 codegen 补主题无关 chrome 色(AppChrome)
外壳要用的状态栏/品牌/遮罩/Toast 色在 tokens.css :root,固定不随 A/B/C 主题切换, 原先没进 Dart token。扩展 gen_tokens.mjs 从 :root 生成 AppChrome 常量类 (statusbar-* / brand-* / scrim / hero-glass / toast-bg),外壳直接引用、禁硬编码。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TSKEiHsvauyxYUW2itzUXX
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// GENERATED by tool/gen_tokens.mjs — DO NOT EDIT.
|
||||
// 源:lib/core/theme/token_source/tokens.css(:root 共享块的主题无关颜色)。改色请改源后重跑脚本。
|
||||
// 外壳 chrome 色:状态栏/品牌/遮罩/Toast,固定不随 A/B/C 主题切换。
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppChrome {
|
||||
AppChrome._();
|
||||
static const Color statusbarBg = Color(0xFF37423D);
|
||||
static const Color statusbarFg = Color(0xd1FFFFFF);
|
||||
static const Color statusbarMuted = Color(0x75FFFFFF);
|
||||
static const Color statusbarStrong = Color(0xFFFFFFFF);
|
||||
static const Color statusbarDiv = Color(0x21FFFFFF);
|
||||
static const Color statusbarOk = Color(0xFF7BC49A);
|
||||
static const Color brandDeep = Color(0xFF0F3057);
|
||||
static const Color brandMid = Color(0xFF1B4F8E);
|
||||
static const Color brandWine = Color(0xFF8B2331);
|
||||
static const Color scrim = Color(0x6b0F141E);
|
||||
static const Color heroGlass = Color(0x29FFFFFF);
|
||||
static const Color heroGlassStrong = Color(0x3dFFFFFF);
|
||||
static const Color toastBg = Color(0xFF1F2330);
|
||||
}
|
||||
@@ -119,3 +119,37 @@ ${emitDims()}
|
||||
`;
|
||||
fs.writeFileSync(path.join(ROOT, 'lib/core/theme/app_dims.g.dart'), dimsBody);
|
||||
console.log('generated app_dims.g.dart');
|
||||
|
||||
// ── 主题无关「chrome 色」::root 里固定不随主题切换的颜色 → AppChrome 常量类 ──
|
||||
// 底部状态栏(深石板灰绿条)、品牌标识色(logo/字标)、遮罩/玻璃叠加、Toast 深底。
|
||||
// 外壳(状态栏/品牌)要用,但不属任何主题,故不进 per-theme AppTokens。
|
||||
const CHROME = {
|
||||
// 状态栏(底部 chrome 条)
|
||||
'statusbar-bg':'statusbarBg','statusbar-fg':'statusbarFg','statusbar-muted':'statusbarMuted',
|
||||
'statusbar-strong':'statusbarStrong','statusbar-div':'statusbarDiv','statusbar-ok':'statusbarOk',
|
||||
// 品牌标识色(固定不随主题)
|
||||
'brand-deep':'brandDeep','brand-mid':'brandMid','brand-wine':'brandWine',
|
||||
// 遮罩 / 玻璃叠加
|
||||
'scrim':'scrim','hero-glass':'heroGlass','hero-glass-strong':'heroGlassStrong',
|
||||
// Toast 深底
|
||||
'toast-bg':'toastBg',
|
||||
};
|
||||
function emitChrome(){
|
||||
const r = rootBlock();
|
||||
return Object.entries(CHROME).map(([css,dart])=>{
|
||||
if(r[css]===undefined) throw new Error(`:root missing --${css}`);
|
||||
return ` static const Color ${dart} = ${toColor(r[css])};`;
|
||||
}).join('\n');
|
||||
}
|
||||
const chromeBody = `// GENERATED by tool/gen_tokens.mjs — DO NOT EDIT.
|
||||
// 源:lib/core/theme/token_source/tokens.css(:root 共享块的主题无关颜色)。改色请改源后重跑脚本。
|
||||
// 外壳 chrome 色:状态栏/品牌/遮罩/Toast,固定不随 A/B/C 主题切换。
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppChrome {
|
||||
AppChrome._();
|
||||
${emitChrome()}
|
||||
}
|
||||
`;
|
||||
fs.writeFileSync(path.join(ROOT, 'lib/core/theme/app_chrome.g.dart'), chromeBody);
|
||||
console.log('generated app_chrome.g.dart');
|
||||
|
||||
Reference in New Issue
Block a user