@@ -6,12 +6,12 @@ import {
66 useSyncExternalStore ,
77 type ReactNode ,
88} from "react" ;
9- import { View } from "react-native" ;
9+ import { Platform , View } from "react-native" ;
1010import { ThreadDetailScreen , type ThreadDetailScreenProps } from "./ThreadDetailScreen" ;
1111
1212type ThreadScreenContent =
1313 | { readonly props : ThreadDetailScreenProps }
14- | { readonly fallback : ReactNode } ;
14+ | { readonly fallback : ReactNode ; readonly header ?: ReactNode } ;
1515
1616function createThreadScreenStore ( ) {
1717 let current : ThreadScreenContent | null = null ;
@@ -36,13 +36,16 @@ function ThreadScreenOutlet() {
3636 const store = useContext ( ThreadScreenContext ) ! ;
3737 const content = useSyncExternalStore ( store . subscribe , store . getSnapshot ) ;
3838 if ( content === null ) return null ;
39- return "props" in content ? (
39+ const body = "props" in content ? < ThreadDetailScreen { ...content . props } /> : content . fallback ;
40+ return (
4041 < >
41- { content . props . header }
42- < ThreadDetailScreen { ...content . props } />
42+ { "props" in content ? content . props . header : content . header }
43+ { Platform . OS === "android" ? (
44+ < View className = "flex-1 overflow-hidden rounded-t-[28px] bg-thread-canvas" > { body } </ View >
45+ ) : (
46+ body
47+ ) }
4348 </ >
44- ) : (
45- content . fallback
4649 ) ;
4750}
4851
@@ -53,7 +56,7 @@ export function ThreadScreenHost({ children }: { readonly children: ReactNode })
5356 return (
5457 < ThreadScreenContext . Provider value = { store } >
5558 { children }
56- < View className = "flex-1 bg-screen android:overflow-hidden android:rounded-t-[28px] android: bg-thread-canvas " >
59+ < View className = "flex-1 bg-screen android:bg-header " >
5760 < ThreadScreenOutlet />
5861 </ View >
5962 </ ThreadScreenContext . Provider >
@@ -68,10 +71,16 @@ export function ThreadScreenBinding(props: ThreadDetailScreenProps) {
6871 return null ;
6972}
7073
71- export function ThreadScreenFallback ( { children } : { readonly children : ReactNode } ) {
74+ export function ThreadScreenFallback ( {
75+ children,
76+ header,
77+ } : {
78+ readonly children : ReactNode ;
79+ readonly header ?: ReactNode ;
80+ } ) {
7281 const store = useContext ( ThreadScreenContext ) ! ;
7382 useLayoutEffect ( ( ) => {
74- store . publish ( { fallback : children } ) ;
83+ store . publish ( { fallback : children , header } ) ;
7584 } ) ;
7685 return null ;
7786}
0 commit comments