fix(mobile): merge TabScreenProps ios and other platform
- Added optional `identifier` property to `TabScreenProps` interface for better tab management. - Updated import statements in `TabRoot` and `TabScreen` components to reference the new types file. - Refactored `TabScreen` component to utilize the new `identifier` property in state management. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
20be007d0c
commit
2a290360d1
|
|
@ -8,8 +8,8 @@ import { StyleSheet } from "react-native"
|
|||
|
||||
import type { BottomTabContextType } from "./BottomTabContext"
|
||||
import { BottomTabContext } from "./BottomTabContext"
|
||||
import type { TabScreenProps } from "./TabScreen.ios"
|
||||
import { TabScreen } from "./TabScreen.ios"
|
||||
import type { TabScreenProps } from "./types"
|
||||
|
||||
interface TabRootProps {
|
||||
initialTabIndex?: number
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import { StyleSheet, View } from "react-native"
|
|||
|
||||
import type { BottomTabContextType } from "./BottomTabContext"
|
||||
import { BottomTabContext } from "./BottomTabContext"
|
||||
import type { TabScreenProps } from "./TabScreen"
|
||||
import { TabScreen } from "./TabScreen"
|
||||
import type { TabScreenProps } from "./types"
|
||||
|
||||
interface TabRootProps {
|
||||
initialTabIndex?: number
|
||||
|
|
|
|||
|
|
@ -10,16 +10,10 @@ import { BottomTabContext } from "./BottomTabContext"
|
|||
import { LifecycleEvents, ScreenNameRegister } from "./shared"
|
||||
import type { TabScreenContextType } from "./TabScreenContext"
|
||||
import { TabScreenContext } from "./TabScreenContext"
|
||||
import type { TabbarIconProps, TabScreenComponent } from "./types"
|
||||
import type { TabScreenComponent, TabScreenProps } from "./types"
|
||||
|
||||
const TabScreenNative = requireNativeView<ViewProps>("TabScreen")
|
||||
|
||||
export interface TabScreenProps {
|
||||
title: string
|
||||
tabScreenIndex: number
|
||||
renderIcon?: (props: TabbarIconProps) => React.ReactNode
|
||||
lazy?: boolean
|
||||
}
|
||||
export const TabScreen: FC<PropsWithChildren<Omit<TabScreenProps, "tabScreenIndex">>> = ({
|
||||
children,
|
||||
...props
|
||||
|
|
@ -47,6 +41,9 @@ export const TabScreen: FC<PropsWithChildren<Omit<TabScreenProps, "tabScreenInde
|
|||
if ("lazy" in childType) {
|
||||
propsFromChildren.lazy = childType.lazy
|
||||
}
|
||||
if ("identifier" in childType && typeof childType.identifier === "string") {
|
||||
propsFromChildren.identifier = childType.identifier
|
||||
}
|
||||
}
|
||||
return {
|
||||
...propsFromChildren,
|
||||
|
|
@ -91,10 +88,10 @@ export const TabScreen: FC<PropsWithChildren<Omit<TabScreenProps, "tabScreenInde
|
|||
const ctxValue = useMemo<TabScreenContextType>(
|
||||
() => ({
|
||||
tabScreenIndex,
|
||||
|
||||
identifierAtom: atom(props.identifier ?? ""),
|
||||
titleAtom: atom(props.title),
|
||||
}),
|
||||
[tabScreenIndex, props.title],
|
||||
[tabScreenIndex, props.title, props.identifier],
|
||||
)
|
||||
const shouldLoadReact = mergedProps.lazy ? isSelected || isLoadedBefore : true
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,8 @@ import { BottomTabContext } from "./BottomTabContext"
|
|||
import { LifecycleEvents, ScreenNameRegister, TabScreenIdentifierRegister } from "./shared"
|
||||
import type { TabScreenContextType } from "./TabScreenContext"
|
||||
import { TabScreenContext } from "./TabScreenContext"
|
||||
import type { TabbarIconProps, TabScreenComponent } from "./types"
|
||||
import type { TabScreenComponent, TabScreenProps } from "./types"
|
||||
|
||||
export interface TabScreenProps {
|
||||
title: string
|
||||
tabScreenIndex: number
|
||||
identifier: string
|
||||
renderIcon?: (props: TabbarIconProps) => React.ReactNode
|
||||
}
|
||||
export const TabScreen: FC<PropsWithChildren<Omit<TabScreenProps, "tabScreenIndex">>> = ({
|
||||
children,
|
||||
identifier,
|
||||
|
|
@ -85,7 +79,7 @@ export const TabScreen: FC<PropsWithChildren<Omit<TabScreenProps, "tabScreenInde
|
|||
() => ({
|
||||
tabScreenIndex,
|
||||
titleAtom: atom(props.title),
|
||||
identifierAtom: atom(identifier),
|
||||
identifierAtom: atom(identifier ?? ""),
|
||||
}),
|
||||
[tabScreenIndex, props.title, identifier],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,3 +11,10 @@ export type TabScreenComponent = FC & {
|
|||
|
||||
lazy?: boolean
|
||||
}
|
||||
export interface TabScreenProps {
|
||||
title: string
|
||||
tabScreenIndex: number
|
||||
renderIcon?: (props: TabbarIconProps) => React.ReactNode
|
||||
lazy?: boolean
|
||||
identifier?: string
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue