sumsub-theme-msdk

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sumsub — Mobile SDK theming (iOS & Android)

Sumsub — 移动SDK主题定制(iOS & Android)

Scan the host app's design system, derive a full palette, and write a theme the SDK picks up at launch — iOS: a
SumsubTheme: SNSTheme
subclass assigned as
sdk.theme = SumsubTheme()
; Android: a
sumsubTheme(context)
factory built with the
SNSTheme { … }
DSL and attached via
SNSMobileSDK.Builder(...).withTheme(...)
— so the KYC screens match the app instead of looking bolted on. Every SDK theme property is either mapped from the app or explicitly derived; nothing is left at the SDK default by accident.
This is the trunk (always-on). Detect the platform, then walk that track's four stages in order: Scan → Map → Generate → Report.
扫描宿主应用的设计系统,生成完整调色板,并编写SDK启动时会加载的主题——iOS端:创建
SumsubTheme: SNSTheme
子类,赋值为
sdk.theme = SumsubTheme()
Android端:使用
SNSTheme { … }
DSL构建
sumsubTheme(context)
工厂,通过
SNSMobileSDK.Builder(...).withTheme(...)
关联主题——这样KYC界面就能与应用风格匹配,而非显得格格不入。SDK的每个主题属性要么与应用映射,要么明确推导得出,不会意外保留SDK默认值。
这是核心功能(始终启用)。先检测平台,然后按顺序执行对应平台的四个阶段:扫描→映射→生成→报告。

Asking vs doing — keep approvals meaningful

请求与执行——让审批更有意义

  • Read-only is free — scan / grep / read the project's colors, fonts and build settings without asking.
  • Batch mutations into one approval, not one per item ("I'll write
    SumsubTheme.swift
    here + insert this
    sdk.theme = …
    line [diff] — apply?").
  • Ask explicitly only for: the target file path, genuinely ambiguous brand / legibility / font choices, and editing existing app code (the single theme-attachment line — the skill adds it itself, never punts it to the user).
  • 只读操作无需审批——无需询问即可扫描/查找/读取项目的颜色、字体和构建设置。
  • 批量变更只需一次审批,而非逐项审批(比如“我将在此处编写
    SumsubTheme.swift
    并插入这行
    sdk.theme = …
    代码[差异对比]——是否应用?”)。
  • 仅在以下情况明确询问用户:目标文件路径、存在歧义的品牌/可读性/字体选择,以及编辑现有应用代码(仅需添加关联主题的单行代码——该功能会自行添加,不会推给用户操作)。

Detect the platform (do this before opening any stage file)

检测平台(在打开任何阶段文件前执行)

Decide whether this is an iOS or Android project — the token sources, the theme API, and the generated language all differ. Read-only.
bash
undefined
判断项目属于iOS还是Android——设计令牌来源、主题API和生成的语言均不同。此操作为只读。
bash
undefined

iOS markers

iOS标识

find . -maxdepth 3 ( -name '.xcodeproj' -o -name '.xcworkspace' -o -name 'Podfile' -o -name 'Package.swift' ) 2>/dev/null
find . -maxdepth 3 ( -name '.xcodeproj' -o -name '.xcworkspace' -o -name 'Podfile' -o -name 'Package.swift' ) 2>/dev/null

Android markers

Android标识

find . -maxdepth 3 ( -name 'build.gradle' -o -name 'build.gradle.kts' -o -name 'settings.gradle*' -o -name 'AndroidManifest.xml' ) 2>/dev/null

- **iOS only** → iOS track. **Android only** → Android track.
- **Both present** → report both and **ask which platform to theme.** One platform per run.
  (React Native / Flutter wrappers are out of scope — this skill themes the native SDKs.)
- **Neither** → ask the user to point at the app's source root.
find . -maxdepth 3 ( -name 'build.gradle' -o -name 'build.gradle.kts' -o -name 'settings.gradle*' -o -name 'AndroidManifest.xml' ) 2>/dev/null

- **仅存在iOS标识**→执行iOS流程。**仅存在Android标识**→执行Android流程。
- **两者都存在**→告知用户并询问**要为哪个平台定制主题**。每次仅处理一个平台。(React Native/Flutter封装不在此功能范围内——此功能仅针对原生SDK定制主题。)
- **两者都不存在**→请用户指明应用的源码根目录。

How to navigate this skill

如何使用此功能

A strictly linear flow per track — walk the four stages in order; each is self-contained and ends with a Next pointer.
每个平台都有严格的线性流程——按顺序执行四个阶段;每个阶段都是独立的,结束时会有“下一步”指引。

iOS track

iOS流程

  1. ios/stages/1-scan.md
    — scan the host app's design system (read-only).
  2. ios/stages/2-map.md
    — map tokens onto the SDK theme (after resolving open decisions).
  3. ios/stages/3-generate.md
    — write
    SumsubTheme.swift
    (after the path is confirmed).
  4. ios/stages/4-report.md
    — present the coverage report.
  1. ios/stages/1-scan.md
    — 扫描宿主应用的设计系统(只读)。
  2. ios/stages/2-map.md
    — 将设计令牌映射到SDK主题(解决未决问题后执行)。
  3. ios/stages/3-generate.md
    — 编写
    SumsubTheme.swift
    (确认路径后执行)。
  4. ios/stages/4-report.md
    — 展示覆盖范围报告。

Android track

Android流程

  1. android/stages/1-scan.md
    — scan the host app's design system (read-only).
  2. android/stages/2-map.md
    — map tokens onto the SDK theme (after resolving open decisions).
  3. android/stages/3-generate.md
    — write
    SumsubTheme.kt
    (after the path is confirmed).
  4. android/stages/4-report.md
    — present the coverage report.
Fallback (last resort only). This skill and its stage files are the primary source — don't reach for external docs by default. Only if you hit a genuine blocker they don't resolve, consult the Sumsub theme docs: iOS · Android.
When the stages are walked, return here for Guardrails and Handoff.
  1. android/stages/1-scan.md
    — 扫描宿主应用的设计系统(只读)。
  2. android/stages/2-map.md
    — 将设计令牌映射到SDK主题(解决未决问题后执行)。
  3. android/stages/3-generate.md
    — 编写
    SumsubTheme.kt
    (确认路径后执行)。
  4. android/stages/4-report.md
    — 展示覆盖范围报告。
备用方案(仅万不得已时使用)。此功能及其阶段文件是主要参考来源——默认情况下不要查阅外部文档。只有遇到无法解决的真正障碍时,才参考Sumsub主题文档: iOS · Android
完成所有阶段后,回到此处查看约束规则交付总结

Guardrails — what this skill must never do

约束规则——此功能绝对不能执行的操作

  • Never write the file without confirming the path with the user.
  • Never leave a property at SDK default without noting it in the report.
  • Never hard-code arbitrary values — colors come from the app palette or the documented alpha-derivation.
  • Always show the hex (or asset / resource name) when reporting or asking; add a plain-word description in parentheses, never instead of the hex.
  • Never silently guess a genuinely ambiguous choice — offer plain-word options + a recommendation; but don't over-ask where a safe default exists.
  • Never theme the host app itself — only the Sumsub SDK screens.
  • Never change SDK integration logic (install / init / present / launch). The skill's one edit to existing code is attaching the theme at the launch site — it makes that edit itself, with approval.
  • (iOS) Never emit unsafe color/font code — no flat
    UIColor
    literals for dual-appearance apps (use named assets or
    UIColor { traits in … }
    ); no
    UIFont(name:size:)
    without a
    ?? .systemFont(…)
    fallback; no decorative/app colors in the success/warning/critical slots.
  • (iOS) Never override
    images.*
    for verification-flow icons
    — Sumsub-specific, not derivable from the host.
  • (Android) Never emit single-appearance colors for a dual-appearance app — resolve both variants and use the two-argument
    SNSThemeColor(light, dark)
    ; no
    ResourcesCompat.getFont
    result without a
    ?: Typeface.…
    fallback.
  • (Android) Never override the SDK's
    sns_*
    resources
    (colors / strings / drawables in the host's
    res/
    ) — theme through the Theme API only; resource overrides fight the theme and break on SDK updates.
  • (Android) Attach the theme on the builder
    .withTheme(...)
    before
    .build()
    ; never try to restyle after
    launch()
    .
  • 未经用户确认路径,绝对不能写入文件
  • 绝对不能保留SDK默认属性而不在报告中注明
  • 绝对不能硬编码任意值——颜色必须来自应用调色板或文档规定的透明度推导方式。
  • 报告或询问时必须显示十六进制值(或资源名称);可在括号中添加文字说明,但不能替代十六进制值。
  • 绝对不能默默猜测存在歧义的选择——提供清晰的选项及建议;但在有安全默认值的情况下不要过度询问。
  • 绝对不能定制宿主应用本身的主题——仅定制Sumsub SDK界面。
  • 绝对不能修改SDK集成逻辑(安装/初始化/展示/启动)。此功能对现有代码的唯一修改是在启动位置关联主题——该修改会自行完成,并需获得用户审批。
  • (iOS) 绝对不能生成不安全的颜色/字体代码——双外观应用不能使用扁平的
    UIColor
    字面量(请使用命名资源或
    UIColor { traits in … }
    );
    UIFont(name:size:)
    必须带有
    ?? .systemFont(…)
    回退;成功/警告/严重状态不能使用装饰性/应用颜色。
  • (iOS) 绝对不能覆盖验证流程图标的
    images.*
    属性
    ——这些是Sumsub专属属性,无法从宿主应用推导。
  • (Android) 绝对不能为双外观应用生成单外观颜色——需解析两种变体并使用双参数
    SNSThemeColor(light, dark)
    ResourcesCompat.getFont
    结果必须带有
    ?: Typeface.…
    回退。
  • (Android) 绝对不能覆盖SDK的
    sns_*
    资源
    (宿主应用
    res/
    目录下的颜色/字符串/可绘制资源)——仅通过Theme API定制主题;资源覆盖会与主题冲突,并在SDK更新时失效。
  • (Android) 必须在构建器上关联主题——在
    .build()
    前调用
    .withTheme(...)
    ;绝对不能在
    launch()
    后尝试重新样式化。

Handoff

交付总结

After the file is generated and wired, summarise:
  1. File created
    SumsubTheme.swift
    /
    SumsubTheme.kt
    and where it lives (iOS: confirm it's a target member; Android: any location under a source set compiles).
  2. Coverage — the Stage 4 report (mapped / derived / left at default), plus any contrast fix or choice the user made.
  3. Wiring done — the exact launch site (file:line) where the theme is attached (iOS:
    sdk.theme = SumsubTheme()
    or
    SumsubTheme.make()
    ; Android:
    .withTheme(sumsubTheme(activity))
    on the builder). If no integration code was found (SDK not wired up yet), say so and point to
    sumsub-integrate-msdk
    — the theme is ready to attach once it is.
生成并关联主题文件后,总结以下内容:
  1. 已创建文件——
    SumsubTheme.swift
    /
    SumsubTheme.kt
    及其存放位置(iOS:确认它是目标成员;Android:源码集下的任何位置均可编译)。
  2. 覆盖范围——第4阶段的报告(已映射/已推导/保留默认值),加上用户做出的任何对比度调整或选择。
  3. 已完成关联——主题关联的确切启动位置(文件:行号)(iOS:
    sdk.theme = SumsubTheme()
    SumsubTheme.make()
    ;Android:构建器上的
    .withTheme(sumsubTheme(activity))
    )。如果未找到集成代码(SDK尚未关联),请告知用户并指向
    sumsub-integrate-msdk
    ——主题已准备好,待SDK集成完成后即可关联。