Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): align Android native splash with JS branding (#310)
qsoyq178e196149e2
diff --git a/apps/mobile/app.json b/apps/mobile/app.jsonindex 05adfdc99d..283c9192cc 100644--- a/apps/mobile/app.json+++ b/apps/mobile/app.json@@ -42,9 +42,7 @@"monochromeImage": "./assets/android-icon-monochrome.png"},"predictiveBackGestureEnabled": false,- "permissions": [- "android.permission.MODIFY_AUDIO_SETTINGS"- ]+ "permissions": ["android.permission.MODIFY_AUDIO_SETTINGS"]},"web": {"favicon": "./assets/favicon.png"@@ -53,7 +51,6 @@"./plugins/with-third-party-notices","./plugins/with-google-signin-modular-headers","./plugins/with-wechat-opensdk-modulemap",- "./plugins/with-android-splash-no-icon",["expo-build-properties",{@@ -68,6 +65,15 @@"backgroundColor": "#DF0C27","dark": {"backgroundColor": "#DF0C27"+ },+ "android": {+ "backgroundColor": "#DF0C27",+ "image": "./assets/login/[email protected]",+ "imageWidth": 128,+ "dark": {+ "backgroundColor": "#DF0C27",+ "image": "./assets/login/[email protected]"+ }}}],diff --git a/apps/mobile/plugins/with-android-splash-no-icon.js b/apps/mobile/plugins/with-android-splash-no-icon.jsdeleted file mode 100644index 8f77334b57..0000000000--- a/apps/mobile/plugins/with-android-splash-no-icon.js+++ /dev/null@@ -1,44 +0,0 @@-const { withAndroidStyles } = require("@expo/config-plugins");--// expo-splash-screen 的 Android 插件无条件往 styles.xml 的 Theme.App.SplashScreen-// 写死 `windowSplashScreenAnimatedIcon = @drawable/splashscreen_logo`,但只有当 splash-// 配置里带了 image/drawable 时才会真正生成该 drawable。Cindy 的 splash 配置只给了-// backgroundColor(原生启动屏只要品牌红、logo 交给 JS StartupSplashOverlay),没有 image,-// 于是 styles.xml 引用了一个不存在的 drawable → Android 资源链接(processReleaseResources)-// 报 `resource drawable/splashscreen_logo not found`,所有 Android 构建都会失败。-//-// 本插件从 Theme.App.SplashScreen 里剥掉这条悬空的 windowSplashScreenAnimatedIcon。-// 去掉后 Android 12+ 会回退到 app 启动图标,背景色仍由 windowSplashScreenBackground 保持-// #DF0C27,native→JS 交接的红色连续性不变。iOS 无此机制,不受影响。-//-// ⚠️ 排序:Expo 的 withAndroidStyles mod 执行顺序与 app.json plugins 数组**相反**-// (后注册的先跑、被先注册的覆盖)。因此本插件必须排在 expo-splash-screen **之前**,-// 才能在 expo-splash-screen 写入 styles.xml 之后再剥掉该 item(已实测:排在其后无效)。-const SPLASH_STYLE_NAME = "Theme.App.SplashScreen";-const DANGLING_ICON_ITEM = "windowSplashScreenAnimatedIcon";--function stripSplashAnimatedIcon(styles) {- const stylesList = styles?.resources?.style;- if (!Array.isArray(stylesList)) {- return styles;- }- for (const style of stylesList) {- if (style?.$?.name !== SPLASH_STYLE_NAME || !Array.isArray(style.item)) {- continue;- }- style.item = style.item.filter(- (item) => item?.$?.name !== DANGLING_ICON_ITEM,- );- }- return styles;-}--function withAndroidSplashNoIcon(config) {- return withAndroidStyles(config, (androidConfig) => {- androidConfig.modResults = stripSplashAnimatedIcon(androidConfig.modResults);- return androidConfig;- });-}--module.exports = withAndroidSplashNoIcon;-module.exports.stripSplashAnimatedIcon = stripSplashAnimatedIcon;diff --git a/apps/mobile/src/__tests__/androidSplashNoIconPlugin.test.ts b/apps/mobile/src/__tests__/androidSplashNoIconPlugin.test.tsdeleted file mode 100644index 490152b8cf..0000000000--- a/apps/mobile/src/__tests__/androidSplashNoIconPlugin.test.ts+++ /dev/null@@ -1,74 +0,0 @@-import { createRequire } from "node:module";--import { describe, expect, it } from "vitest";--const require = createRequire(import.meta.url);-const { stripSplashAnimatedIcon } =- require("../../plugins/with-android-splash-no-icon.js") as {- stripSplashAnimatedIcon: (styles: unknown) => {- resources?: {- style?: Array<{- $?: { name?: string; parent?: string };- item?: Array<{ $?: { name?: string }; _?: string }>;- }>;- };- };- };--// styles.xml AST 形态复刻 expo-splash-screen 生成的 Theme.App.SplashScreen(只给-// backgroundColor、没给 image 时会写死悬空的 windowSplashScreenAnimatedIcon)。-function splashStylesFixture() {- return {- resources: {- style: [- {- $: { name: "AppTheme", parent: "Theme.AppCompat.DayNight.NoActionBar" },- item: [{ $: { name: "colorPrimary" }, _: "@color/colorPrimary" }],- },- {- $: { name: "Theme.App.SplashScreen", parent: "Theme.SplashScreen" },- item: [- {- $: { name: "windowSplashScreenBackground" },- _: "@color/splashscreen_background",- },- {- $: { name: "windowSplashScreenAnimatedIcon" },- _: "@drawable/splashscreen_logo",- },- { $: { name: "postSplashScreenTheme" }, _: "@style/AppTheme" },- ],- },- ],- },- };-}--describe("with-android-splash-no-icon config plugin", () => {- it("removes the dangling windowSplashScreenAnimatedIcon reference", () => {- const result = stripSplashAnimatedIcon(splashStylesFixture());- const splash = result.resources?.style?.find(- (s) => s.$?.name === "Theme.App.SplashScreen",- );- const itemNames = (splash?.item ?? []).map((i) => i.$?.name);- expect(itemNames).not.toContain("windowSplashScreenAnimatedIcon");- // 背景色与其它条目必须保留(红色连续性由 windowSplashScreenBackground 维持)。- expect(itemNames).toContain("windowSplashScreenBackground");- expect(itemNames).toContain("postSplashScreenTheme");- });-- it("leaves unrelated styles untouched", () => {- const result = stripSplashAnimatedIcon(splashStylesFixture());- const appTheme = result.resources?.style?.find(- (s) => s.$?.name === "AppTheme",- );- expect((appTheme?.item ?? []).map((i) => i.$?.name)).toEqual([- "colorPrimary",- ]);- });-- it("is a no-op when styles have no style array", () => {- expect(() => stripSplashAnimatedIcon({})).not.toThrow();- expect(() => stripSplashAnimatedIcon({ resources: {} })).not.toThrow();- });-});diff --git a/apps/mobile/src/__tests__/startupSplashOverlay.test.ts b/apps/mobile/src/__tests__/startupSplashOverlay.test.tsindex ffd048057a..f4af260c19 100644--- a/apps/mobile/src/__tests__/startupSplashOverlay.test.ts+++ b/apps/mobile/src/__tests__/startupSplashOverlay.test.ts@@ -1,64 +1,181 @@-import { readFileSync } from 'node:fs';-import { resolve } from 'node:path';-import { describe, expect, it } from 'vitest';+import { createHash } from "node:crypto";+import { execFileSync } from "node:child_process";+import { readFileSync } from "node:fs";+import { createRequire } from "node:module";+import { resolve } from "node:path";+import { describe, expect, it } from "vitest";++import { darkColors, lightColors, motionDuration } from "@/theme/tokens";/*** 启动 splash 覆盖层契约:启动闸门链全程共用根部一个常驻 splash 实例。* 回归背景:此前每道闸门(端点清单/canary 渠道/OTA 门/auth 恢复)各自渲染独立的* splash,交接 remount 会露出 surface 底色,产生"红→白→红"闪帧(2026-07 用户实报)。*/-describe('startup splash overlay', () => {+describe("startup splash overlay", () => {// Windows 检出(core.autocrlf)下源文件是 CRLF,归一化行尾让含 \n 的断言跨平台成立。- const read = (rel: string) => readFileSync(resolve(process.cwd(), rel), 'utf8').replace(/\r\n/g, '\n');+ const read = (rel: string) =>+ readFileSync(resolve(process.cwd(), rel), "utf8").replace(/\r\n/g, "\n");- it('root layout mounts a single persistent splash overlay above the gate chain', () => {- const layout = read('app/_layout.tsx');+ it("root layout mounts a single persistent splash overlay above the gate chain", () => {+ const layout = read("app/_layout.tsx");expect(layout).toContain("from '@/components/StartupSplashOverlay'");- expect(layout).toContain('<StartupSplashOverlay hidden={endpointGate.status === \'error\'}>');+ expect(layout).toContain(+ "<StartupSplashOverlay hidden={endpointGate.status === 'error'}>",+ );// 闸门链各关不许再各自渲染 splash 实例(splash-preview 路由是唯一例外)。expect(layout).not.toContain('variant="splash"');});- it('gates render null while pending instead of their own splash instance', () => {- const layout = read('app/_layout.tsx');- const index = read('app/index.tsx');+ it("gates render null while pending instead of their own splash instance", () => {+ const layout = read("app/_layout.tsx");+ const index = read("app/index.tsx");- expect(layout).toContain('if (!otaReady) {\n return null;\n }');+ expect(layout).toContain("if (!otaReady) {\n return null;\n }");expect(layout).toContain("if (!channel.ready) return null;");- expect(index).toContain('if (!auth.initialized) return null;');+ expect(index).toContain("if (!auth.initialized) return null;");expect(index).not.toContain('variant="splash"');});- it('releases the overlay on auth.initialized so deep-link cold starts also release', () => {- const layout = read('app/_layout.tsx');+ it("releases the overlay on auth.initialized so deep-link cold starts also release", () => {+ const layout = read("app/_layout.tsx");- expect(layout).toContain('if (auth.initialized) releaseSplash();');+ expect(layout).toContain("if (auth.initialized) releaseSplash();");});- it('fades out with a one-shot compositor-only opacity animation', () => {- const overlay = read('src/components/StartupSplashOverlay.tsx');+ it("fades the Android native-frame bridge before releasing the outer overlay", () => {+ const overlay = read("src/components/StartupSplashOverlay.tsx");- expect(overlay).toContain('useNativeDriver: true');- expect(overlay).toContain('StyleSheet.absoluteFill');- expect(overlay).toContain('<CenteredScreen title="Cindy" variant="splash" />');+ expect(overlay).toContain("useNativeDriver: true");+ expect(overlay).toContain("StyleSheet.absoluteFill");+ expect(overlay).toContain("<CenteredScreen");+ expect(overlay).toContain('variant="splash"');+ expect(overlay).toContain("nativeSplashHeroAsset");+ expect(overlay).toContain("colors.brandSplashBackground");+ expect(overlay).toContain("height: 128");+ expect(overlay).toContain("width: 128");+ expect(overlay).toContain("duration: motionDuration.fast");+ expect(motionDuration.fast).toBe(150);+ expect(overlay).toContain(+ "if (releaseRequested && !nativeBridgeMounted) setReleased(true);",+ );+ expect(overlay).toContain("handoffContext?.state.reducedMotion");});- it('keeps the native launch screen on the same brand red as the JS splash (both platforms)', () => {- // ios/android 目录是 prebuild 产物(gitignored),native 启动屏颜色的权威来源是- // app.json 的 expo-splash-screen 插件配置;#DF0C27 = brandSplashBackground- // (src/theme/tokens.ts),native→JS 交接不许有色差,深浅外观同色。- const appConfig = JSON.parse(read('app.json')) as {+ it("keeps iOS unchanged while Android uses a theme-independent brand anchor", () => {+ // ios/android 目录是 prebuild 产物(gitignored),app.json 是原生启动页的权威来源。+ // iOS 保留旧的红底无图配置;Android light/night 使用同一品牌红与同源 hero,+ // 不在原生 starting window 阶段猜测 JS 才能读取的「是否首启」状态。+ const appConfig = JSON.parse(read("app.json")) as {expo: { plugins: (string | [string, Record<string, unknown>])[] };};const splashPlugin = appConfig.expo.plugins.find(- (p): p is [string, Record<string, unknown>] => Array.isArray(p) && p[0] === 'expo-splash-screen',+ (p): p is [string, Record<string, unknown>] =>+ Array.isArray(p) && p[0] === "expo-splash-screen",);expect(splashPlugin).toBeDefined();- expect(splashPlugin?.[1]).toEqual({- backgroundColor: '#DF0C27',- dark: { backgroundColor: '#DF0C27' },+ const splashConfig = splashPlugin?.[1] as {+ backgroundColor?: string;+ image?: string;+ dark?: { backgroundColor?: string; image?: string };+ android?: {+ backgroundColor?: string;+ image?: string;+ imageWidth?: number;+ dark?: { backgroundColor?: string; image?: string };+ };+ };++ expect(splashConfig).not.toHaveProperty("image");+ expect(splashConfig.backgroundColor).toBe(+ lightColors.brandSplashBackground,+ );+ expect(splashConfig.dark).toEqual({+ backgroundColor: darkColors.brandSplashBackground,});+ expect(splashConfig.android).toEqual({+ backgroundColor: lightColors.brandSplashBackground,+ image: "./assets/login/[email protected]",+ imageWidth: 128,+ dark: {+ backgroundColor: darkColors.brandSplashBackground,+ image: "./assets/login/[email protected]",+ },+ });++ // Android 12 无 icon background 的安全圆直径是 192dp。prebuild 后对 288dp+ // splashscreen_logo 做 alpha 像素扫描,这份 hero 在 imageWidth=128 时的最远不透明+ // 像素半径为 53.6dp(<96dp)。锁住资产字节,后续换图必须重新做安全圆验证并更新契约。+ const heroSha256 = (file: string) =>+ createHash("sha256")+ .update(readFileSync(resolve(process.cwd(), file)))+ .digest("hex");+ expect(heroSha256("assets/login/[email protected]")).toBe(+ "4e0ce24b482ac28e1160ded2166a29a0054f497c5f63a21b7211805e9aa3ff01",+ );+ // JS bridge 的无倍率 require 在高密度设备会选 @3x,亦需锁住同构资产。+ expect(heroSha256("assets/login/[email protected]")).toBe(+ "d3cb03089d71e8f6cb6402ebce78009e5a72555380f81eaf932b74d96be0e8da",+ );+ });++ it("generates a dedicated Android splash icon and the same light/night brand background", () => {+ const nodeRequire = createRequire(import.meta.url);+ const expoCli = nodeRequire.resolve("expo/bin/cli");+ const introspected = JSON.parse(+ execFileSync(+ process.execPath,+ [expoCli, "config", "--type", "introspect", "--json"],+ {+ cwd: process.cwd(),+ encoding: "utf8",+ env: { ...process.env, NODE_ENV: "development" },+ },+ ),+ ) as {+ _internal: {+ modResults: {+ android: {+ colors: { resources: { color: AndroidResource[] } };+ colorsNight: { resources: { color: AndroidResource[] } };+ styles: { resources: { style: AndroidStyle[] } };+ };+ };+ };+ };+ const android = introspected._internal.modResults.android;+ const splashStyle = android.styles.resources.style.find(+ (style) => style.$.name === "Theme.App.SplashScreen",+ );+ const splashItems = Object.fromEntries(+ (splashStyle?.item ?? []).map((item) => [item.$.name, item._]),+ );+ const colorValue = (resources: AndroidResource[]) =>+ resources.find((color) => color.$.name === "splashscreen_background")?._;++ expect(splashItems.windowSplashScreenAnimatedIcon).toBe(+ "@drawable/splashscreen_logo",+ );+ expect(splashItems.windowSplashScreenBackground).toBe(+ "@color/splashscreen_background",+ );+ expect(colorValue(android.colors.resources.color)).toBe(+ lightColors.brandSplashBackground,+ );+ expect(colorValue(android.colorsNight.resources.color)).toBe(+ darkColors.brandSplashBackground,+ );});});++interface AndroidResource {+ _: string;+ $: { name: string };+}++interface AndroidStyle {+ $: { name: string };+ item?: AndroidResource[];+}diff --git a/apps/mobile/src/auth/__tests__/loginFirstLaunchGate.test.ts b/apps/mobile/src/auth/__tests__/loginFirstLaunchGate.test.tsindex c5e550a4cb..9525df04a2 100644--- a/apps/mobile/src/auth/__tests__/loginFirstLaunchGate.test.ts+++ b/apps/mobile/src/auth/__tests__/loginFirstLaunchGate.test.ts@@ -80,7 +80,7 @@ describe('MobileLoginHandoffStage 消费 pending(源码结构断言,仓内无 reresolve(process.cwd(), 'src/components/MobileLoginHandoffStage.tsx'),'utf8',);- const pendingReturn = source.indexOf("=== 'pending') return null");+ const pendingReturn = source.indexOf('if (handoff.targetTheme == null)');const overrideProvider = source.indexOf('<ThemeOverrideProvider');expect(pendingReturn, 'pending 早退存在').toBeGreaterThan(-1);expect(overrideProvider, 'ThemeOverrideProvider 渲染存在').toBeGreaterThan(-1);diff --git a/apps/mobile/src/auth/__tests__/startupSplashContinuity.test.ts b/apps/mobile/src/auth/__tests__/startupSplashContinuity.test.tsnew file mode 100644index 0000000000..0cd981c0af--- /dev/null+++ b/apps/mobile/src/auth/__tests__/startupSplashContinuity.test.ts@@ -0,0 +1,30 @@+import { describe, expect, it } from 'vitest';++import { resolveStartupSplashHandoff } from '../startupSplashContinuity';++describe('startup splash continuity', () => {+ it.each([+ ['light', 'light', 'light'],+ ['light', 'dark', 'light'],+ ['passthrough', 'light', 'light'],+ ['passthrough', 'dark', 'dark'],+ ] as const)(+ '首启门 %s + 系统 %s → JS 舞台 %s',+ (gate, systemTheme, targetTheme) => {+ expect(resolveStartupSplashHandoff(gate, systemTheme)).toEqual({+ showNativeBridge: false,+ targetTheme,+ });+ },+ );++ it.each(['light', 'dark'] as const)(+ '首启门 pending + 系统 %s 时保留原生品牌帧且不猜主题',+ (systemTheme) => {+ expect(resolveStartupSplashHandoff('pending', systemTheme)).toEqual({+ showNativeBridge: true,+ targetTheme: null,+ });+ },+ );+});diff --git a/apps/mobile/src/auth/startupSplashContinuity.ts b/apps/mobile/src/auth/startupSplashContinuity.tsnew file mode 100644index 0000000000..6716273866--- /dev/null+++ b/apps/mobile/src/auth/startupSplashContinuity.ts@@ -0,0 +1,29 @@+import type { LoginFirstLaunchGateState } from './loginFirstLaunchGate';++export type StartupSystemTheme = 'light' | 'dark';++export interface StartupSplashHandoffDecision {+ /** Android 原生品牌帧是否继续盖住 JS 主题舞台。 */+ showNativeBridge: boolean;+ /** 判定完成后的 JS 舞台主题;pending 时不允许提前猜测。 */+ targetTheme: StartupSystemTheme | null;+}++/**+ * #222 / #235 的交接契约:+ * - 原生品牌帧在首启门未决时保持不动,避免先画错主题;+ * - 真首启固定亮色;+ * - 老用户恢复系统主题。+ */+export function resolveStartupSplashHandoff(+ gate: LoginFirstLaunchGateState,+ systemTheme: StartupSystemTheme,+): StartupSplashHandoffDecision {+ if (gate === 'pending') {+ return { showNativeBridge: true, targetTheme: null };+ }+ return {+ showNativeBridge: false,+ targetTheme: gate === 'light' ? 'light' : systemTheme,+ };+}diff --git a/apps/mobile/src/components/CenteredScreen.tsx b/apps/mobile/src/components/CenteredScreen.tsxindex 519ea7700f..407ac9a1e1 100644--- a/apps/mobile/src/components/CenteredScreen.tsx+++ b/apps/mobile/src/components/CenteredScreen.tsx@@ -1,7 +1,12 @@import { ActivityIndicator, StyleSheet, View } from 'react-native';import { Text } from '@/components/AppText';import { MobileLoginHandoffStage } from '@/components/MobileLoginHandoffStage';-import { fontWeight, useTheme, useThemedStyles, type ThemeColors } from '@/theme';+import {+ fontWeight,+ useTheme,+ useThemedStyles,+ type ThemeColors,+} from '@/theme';import { spacing, typeScale } from '@/theme/tokens';/**diff --git a/apps/mobile/src/components/MobileLoginHandoffStage.tsx b/apps/mobile/src/components/MobileLoginHandoffStage.tsxindex 0d7cc8e2d8..3ef3dd8a5e 100644--- a/apps/mobile/src/components/MobileLoginHandoffStage.tsx+++ b/apps/mobile/src/components/MobileLoginHandoffStage.tsx@@ -25,6 +25,7 @@ import {} from '@/auth/loginHandoff';import { useLoginHandoffOptional } from '@/auth/MobileLoginHandoffContext';import { useLoginFirstLaunchLight } from '@/auth/loginFirstLaunchGate';+import { resolveStartupSplashHandoff } from '@/auth/startupSplashContinuity';import { ThemeOverrideProvider, useTheme } from '@/theme';/**@@ -153,12 +154,12 @@ export function MobileLoginHandoffStage(props: {// 首启亮色门在品牌宿主层消费(DESIGN.md §16.5 主题跟随):splash/闸门/登录// 共享同一覆盖,首启不出现「舞台暗 → 登录亮」闪变;覆盖仅限本宿主子树。const firstLaunchGate = useLoginFirstLaunchLight();- // pending(AsyncStorage 未决,eager kick 下近零时长且宿主在 auth.initialized- // 后才挂载,实际几乎不会命中)时不渲染品牌内容:按任何主题渲染都可能产出- // 错误主题帧(真首启透传系统暗色 → 判定后切亮),等判定完成再上。- if (firstLaunchGate === 'pending') return null;+ const { mode: systemTheme } = useTheme();+ const handoff = resolveStartupSplashHandoff(firstLaunchGate, systemTheme);+ // pending 时由 Android 原生帧复刻层继续覆盖;本舞台不提前猜测主题。+ if (handoff.targetTheme == null) return null;return (- <ThemeOverrideProvider mode={firstLaunchGate === 'light' ? 'light' : null}>+ <ThemeOverrideProvider mode={handoff.targetTheme}><MobileLoginHandoffStageInner {...props} /></ThemeOverrideProvider>);diff --git a/apps/mobile/src/components/StartupSplashOverlay.tsx b/apps/mobile/src/components/StartupSplashOverlay.tsxindex 479dd1e729..8e8e308b0e 100644--- a/apps/mobile/src/components/StartupSplashOverlay.tsx+++ b/apps/mobile/src/components/StartupSplashOverlay.tsx@@ -8,11 +8,16 @@ import {useState,type ReactNode,} from 'react';-import { Animated, StyleSheet } from 'react-native';+import { Animated, Image, Platform, StyleSheet } from 'react-native';+import { useLoginHandoffOptional } from '@/auth/MobileLoginHandoffContext';+import { useLoginFirstLaunchLight } from '@/auth/loginFirstLaunchGate';+import { resolveStartupSplashHandoff } from '@/auth/startupSplashContinuity';import { CenteredScreen } from '@/components/CenteredScreen';+import { motionDuration, useTheme } from '@/theme';/** splash 释放后的淡出时长(ms):盖住底下首屏首帧的绘制间隙,避免红→白闪帧 */const SPLASH_FADE_OUT_MS = 220;+const nativeSplashHeroAsset = require('../../assets/login/login-hero.png');type StartupSplashContextValue = {/** 启动链最后一道门通过后调用:淡出并卸载常驻 splash(幂等,可重复调用) */@@ -50,10 +55,49 @@ export function StartupSplashOverlay({hidden?: boolean;children: ReactNode;}) {+ const { colors, mode } = useTheme();+ const handoffContext = useLoginHandoffOptional();+ const firstLaunchGate = useLoginFirstLaunchLight();+ const handoff = resolveStartupSplashHandoff(firstLaunchGate, mode);+ const nativeBridgeRequired = Platform.OS === 'android';+ const [nativeBridgeMounted, setNativeBridgeMounted] =+ useState(nativeBridgeRequired);+ const nativeBridgeOpacity = useRef(new Animated.Value(1)).current;+ const [releaseRequested, setReleaseRequested] = useState(false);const [released, setReleased] = useState(false);const [mounted, setMounted] = useState(true);const opacity = useRef(new Animated.Value(1)).current;- const releaseSplash = useCallback(() => setReleased(true), []);+ const releaseSplash = useCallback(() => setReleaseRequested(true), []);++ // Android JS 首帧复刻原生红底 + hero。首启门决议后只淡出这一层,+ // 露出已选定正确主题的 MobileLoginHandoffStage;iOS 不挂该层,行为不变。+ useEffect(() => {+ if (!nativeBridgeMounted || handoff.showNativeBridge) return;+ if (handoffContext?.state.reducedMotion) {+ nativeBridgeOpacity.setValue(0);+ setNativeBridgeMounted(false);+ return;+ }+ const animation = Animated.timing(nativeBridgeOpacity, {+ duration: motionDuration.fast,+ toValue: 0,+ useNativeDriver: true,+ });+ animation.start(({ finished }) => {+ if (finished) setNativeBridgeMounted(false);+ });+ return () => animation.stop();+ }, [+ handoff.showNativeBridge,+ handoffContext?.state.reducedMotion,+ nativeBridgeMounted,+ nativeBridgeOpacity,+ ]);++ // 即使 auth 很快完成,也要等原生复刻层交接完再释放整个覆盖层。+ useEffect(() => {+ if (releaseRequested && !nativeBridgeMounted) setReleased(true);+ }, [nativeBridgeMounted, releaseRequested]);useEffect(() => {if (!released) return;@@ -82,6 +126,26 @@ export function StartupSplashOverlay({style={[StyleSheet.absoluteFill, styles.overlay, { opacity }]}><CenteredScreen title="Cindy" variant="splash" />+ {nativeBridgeMounted ? (+ <Animated.View+ pointerEvents="none"+ style={[+ StyleSheet.absoluteFill,+ styles.nativeBridge,+ {+ backgroundColor: colors.brandSplashBackground,+ opacity: nativeBridgeOpacity,+ },+ ]}+ >+ <Image+ accessible={false}+ resizeMode="contain"+ source={nativeSplashHeroAsset}+ style={styles.nativeBridgeHero}+ />+ </Animated.View>+ ) : null}</Animated.View>) : null}</StartupSplashContext.Provider>@@ -94,4 +158,14 @@ const styles = StyleSheet.create({elevation: 1000,zIndex: 1000,},+ nativeBridge: {+ alignItems: 'center',+ justifyContent: 'center',+ },+ nativeBridgeHero: {+ // Expo Android 资源生成器把 imageWidth contain 到同宽方框,再居中放入+ // 288×288 drawable;这里保持同一 128×128 视口,避免 native → JS 缩放跳变。+ height: 128,+ width: 128,+ },});