/** * @public * @category UI * @name ColorPreference * @description * 현재 기기의 색상 모드를 나타내는 타입이에요. 라이트모드, 다크모드를 나타내는 문자열이에요 * * @typedef {'light' | 'dark'} ColorPreference */ export type ColorPreference = 'light' | 'dark'; /** * @name NetworkStatus * @description * 네트워크 상태를 나타내는 타입이에요. * * @typedef {'WIFI' | '2G' | '3G' | '4G' | '5G' | 'UNKNOWN' | 'OFFLINE'} NetworkStatus */ type NetworkStatus = 'WIFI' | '2G' | '3G' | '4G' | '5G' | 'UNKNOWN' | 'OFFLINE'; /** * @category Types * @name BaseInitialProps * @description * 기본 초기 속성을 나타내는 인터페이스이에요 * * @interface * @property {'ios' | 'android'} platform - 플랫폼 종류 * @property {string} appVersion - 앱 버전 * @property {ColorPreference} initialColorPreference - 최초 색상 * @property {NetworkStatus} networkStatus - 네트워크 상태 * @property {number} loadingStartTs - ReactNativeView 를 네이티브에서 그리기 시작한 시간 (timestamp) * @property {string} [scheme] - 실행된 스킴 */ type BaseInitialProps = { platform: 'ios' | 'android'; appVersion: string; initialColorPreference: ColorPreference; networkStatus: NetworkStatus; loadingStartTs: number; scheme?: string; }; /** * @category Types * @name AndroidInitialProps * @description * Android 에서 React Native 에 전달하는 값이에요. * * @interface * @augments BaseInitialProps * @property {'android'} platform - 플랫폼 이름(Android) * @property {string} initialFontScale - 디바이스에 설정된 폰트 스케일 * @property {string} distributionGroup - 배포 그룹 */ export type AndroidInitialProps = BaseInitialProps & { platform: 'android'; initialFontScale: string; distributionGroup: string; }; /** * @category Types * @name IOSInitialProps * @description * iOS 초기 속성을 나타내는 인터페이스이에요 * * @interface * @augments BaseInitialProps * @property {'ios'} platform - 플랫폼 (iOS) * @property {IOSFontSizeType} initialFontSize - 초기 폰트 크기 * @property {boolean} isVisible - 가시성 여부 */ export type IOSInitialProps = BaseInitialProps & { platform: 'ios'; initialFontSize: IOSFontSizeType; isVisible: boolean; }; /** * @category Types * @name IOSFontSizeType * @description * iOS 폰트 크기 타입을 나타내는 타입이에요 * * @typedef {'xSmall' | 'Small' | 'Medium' | 'Large' | 'xLarge' | 'xxLarge' | 'xxxLarge' | 'A11y_Medium' | 'A11y_Large' | 'A11y_xLarge' | 'A11y_xxLarge' | 'A11y_xxxLarge'} IOSFontSizeType */ type IOSFontSizeType = 'xSmall' | 'Small' | 'Medium' | 'Large' | 'xLarge' | 'xxLarge' | 'xxxLarge' | 'A11y_Medium' | 'A11y_Large' | 'A11y_xLarge' | 'A11y_xxLarge' | 'A11y_xxxLarge'; /** * @public * @category 코어 * @name InitialProps * @description * React Native 앱에서 사용자가 특정 화면에 진입할 때, * 네이티브 플랫폼(Android/iOS)이 앱으로 전달하는 초기 데이터 타입을 제공해요. * 초기 데이터는 화면 초기화에 사용되는 중요한 정보를 포함하고 있고, 네이티브 플랫폼별로 필요한 데이터 타입이 달라요. * * Android에서 제공하는 데이터 타입은 `AndroidInitialProps`이고, iOS에서 제공하는 데이터 타입은 `IOSInitialProps` 이에요. * * @property {'ios' | 'android'} platform - 현재 앱이 실행 중인 플랫폼이에요. `ios` 또는 `android` 값을 가져요. * @property {ColorPreference} initialColorPreference - 초기 컬러 테마예요. 사용자가 설정한 컬러 테마를 나타내요. * @property {NetworkStatus} networkStatus - 현재 기기의 네트워크 연결 상태와 연결된 네트워크예요. * @property {string} [scheme] - 현재 화면에 진입하는 데 사용한 URL 스킴이에요. * @property {`xSmall` | `Small` | `Medium` | `Large` | `xLarge` | `xxLarge` | `xxxLarge` | `A11y_Medium` | `A11y_Large` | `A11y_xLarge` | `A11y_xxLarge` | `A11y_xxxLarge`} initialFontSize (iOS only) iOS 시스템 폰트 크기예요. 각 값은 특정한 폰트 크기를 나타내요. 기본 값은 `Large`이에요. * @property {boolean} isVisible (iOS only) iOS에서 화면이 현재 보이는 상태인지 여부입니다. 초기값으로 `true`가 전달돼요. * @property {string} initialFontScale (Android only) Android 시스템 폰트 스케일이에요. 사용자가 Android 기기의 접근성 설정에서 조정한 폰트 크기 스케일이에요. 이 값은 기본 폰트 크기에 곱해져서 최종 폰트 크기를 결정해요. * * @example * * ### `InitialProps`를 사용하는 예제 * * ::: code-group * ```tsx [_app.tsx] * import { PropsWithChildren } from 'react'; * import { Bedrock, InitialProps } from 'react-native-bedrock'; * import { context } from '../require.context'; * * const APP_NAME = 'my-app-name'; * * function AppContainer({ children, ...initialProps }: PropsWithChildren) { * console.log({ initialProps }); * return <>{children}; * } * * export default Bedrock.registerApp(AppContainer, { * appName: APP_NAME, * context, * }); * ::: * ``` */ export type InitialProps = AndroidInitialProps | IOSInitialProps; export {};