MaterialKolor:Compose 多平台 Material 配色生成库
MaterialKolor 在 Compose Multiplatform 中由单个种子色生成 Material 配色方案,支持 Material 3、Compose Unstyled 与 Compose Fluent。
MaterialKolor 在 Compose Multiplatform 中由单个种子色生成 Material 配色方案,将 Google 的 material-color-utilities 运行于 Android、iOS、macOS、桌面 JVM、JS 和 Wasm。提供 Material 3、Compose Unstyled、Compose Fluent 的适配器,核心模块可用于自建主题。按 UI 工具包选择 artifact:`material-kolor-material3`、`material-kolor-unstyled`、`material-kolor-fluent`、`material-kolor-core`、`material-kolor-palette`(用 kmpalette 从图片取种子色)、`material-color-utilities`(不含 Compose 的颜色引擎)。Material 3 下 `DynamicMaterialTheme` 包裹 `MaterialTheme` 并由种子生成配色,也可用 `rememberDynamicColorScheme` 或 `dynamicColorScheme`;参数包括 `style`(PaletteStyle,如默认 TonalSpot、Vibrant、Expressive、Monochrome)、`primary` 等固定某条色板、`contrastLevel`(-1.0 到 1.0)、`isAmoled`、`specVersion`(默认 SPEC_2025,可传 SPEC_2021 得到 6.0 之前的颜色)。Material 3 Expressive 用 `DynamicMaterialExpressiveTheme`,默认 Expressive 并接受 `motionScheme`。核心模块不依赖 Material 3,`rememberDynamicScheme` 生成方案,`MaterialKolors` 读取角色为 Compose 颜色;方案还携带六条色调色板,可读取 0 到 100 的任意色调,`onTone` 默认按 WCAG AA 给出可读内容色,`rememberTonalPalette` 可从任意颜色构建色板并向种子色相偏移。另有 Compose Unstyled 与 Fluent 适配器、图片取色、`com.materialkolor.ktx` 颜色扩展。`samples` 用四种 UI 栈各构建一个小型待办应用。引擎由 Google 上游 Kotlin 源在指定 revision 生成,经源码转换器适配 Kotlin Multiplatform 与本库 API,`docs/upstream-psi.md` 记录改动与上游更新审查方式。MaterialKolor 为 MIT 许可,生成的 material-color-utilities 代码为 Google Apache 2.0 许可。