@@ -31,6 +31,10 @@ import {
3131 readImportedWallets ,
3232 subscribeImportedWallets ,
3333} from "../wallet/importedWalletsStore" ;
34+ import {
35+ compactNavStickAfterPx ,
36+ shouldStickCompactFirstHeaderRow ,
37+ } from "../wallet/headerRowFit" ;
3438import { useTonConnectSession } from "../ton/TonConnectProvider" ;
3539import { AuthenticatedHomeLeftNavStrip } from "../components/AuthenticatedHomeLeftNavStrip" ;
3640import { AuthenticatedHomeFeedPanel } from "../components/AuthenticatedHomeFeedPanel" ;
@@ -673,6 +677,17 @@ function HomeAuthenticatedScreenMain() {
673677 layout . authenticatedHome . headerDividerHeight ,
674678 ) ;
675679 const [ compactChromeHeightPx , setCompactChromeHeightPx ] = useState ( 0 ) ;
680+ const [ webSafeAreaInsetTopPx , setWebSafeAreaInsetTopPx ] = useState ( 0 ) ;
681+ useEffect ( ( ) => {
682+ if ( Platform . OS !== "web" || typeof document === "undefined" ) return ;
683+ const probe = document . createElement ( "div" ) ;
684+ probe . style . cssText =
685+ "position:absolute;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top, 0px)" ;
686+ document . body . appendChild ( probe ) ;
687+ const px = Number . parseFloat ( window . getComputedStyle ( probe ) . paddingTop || "0" ) || 0 ;
688+ probe . remove ( ) ;
689+ setWebSafeAreaInsetTopPx ( px ) ;
690+ } , [ ] ) ;
676691 const handleHomeLeftScrollPositionChange = useCallback (
677692 ( metrics : { scrollY : number ; layoutH : number ; contentH : number } ) => {
678693 setCompactHeaderScrollY ( metrics . scrollY ) ;
@@ -701,6 +716,7 @@ function HomeAuthenticatedScreenMain() {
701716 debug,
702717 applyServerWalletAfterRegister,
703718 browserSessionChecked,
719+ safeAreaInsetTop,
704720 } = useTelegram ( ) ;
705721 const pathname = useResolvedPathname ( ) ;
706722 const { width : windowWidth } = useWindowDimensions ( ) ;
@@ -720,6 +736,14 @@ function HomeAuthenticatedScreenMain() {
720736 ? Math . min ( splitLayoutMetrics . effectiveSplitWidthPx , fallbackLayoutWidthPx )
721737 : fallbackLayoutWidthPx ;
722738 const isWideHome = isAuthenticatedHomeWideLayoutWidthPx ( liveLayoutWidthPx ) ;
739+ const stickCompactFirstHeaderRow =
740+ ! isWideHome &&
741+ shouldStickCompactFirstHeaderRow ( Math . max ( safeAreaInsetTop , webSafeAreaInsetTopPx ) ) ;
742+ const compactNavLockAfterPx = compactNavStickAfterPx ( {
743+ stickFirstRow : stickCompactFirstHeaderRow ,
744+ firstRowHeightPx : compactStickyHeightPx ,
745+ collapsibleHeightPx : compactCollapsibleHeightPx ,
746+ } ) ;
723747 const compactHeaderCollapsePx = ! isWideHome
724748 ? Math . min ( Math . max ( 0 , compactHeaderScrollY ) , Math . max ( 0 , compactCollapsibleHeightPx ) )
725749 : 0 ;
@@ -1786,9 +1810,16 @@ function HomeAuthenticatedScreenMain() {
17861810 compactCollapsePx = { compactHeaderCollapsePx }
17871811 onCompactCollapsibleLayout = { setCompactCollapsibleHeightPx }
17881812 onCompactStickyLayout = { setCompactStickyHeightPx }
1789- compactStickyTopInsetPx = { layout . authenticatedHome . contentInsetTop }
1790- compactScrollYPx = { isWideHome ? 0 : compactHeaderScrollY }
1791- compactStickyScrollBridge = { compactStickyScrollBridge }
1813+ compactStickyTopInsetPx = {
1814+ stickCompactFirstHeaderRow ? layout . authenticatedHome . contentInsetTop : 0
1815+ }
1816+ compactScrollYPx = {
1817+ ! isWideHome && stickCompactFirstHeaderRow ? compactHeaderScrollY : 0
1818+ }
1819+ compactStickFirstRow = { stickCompactFirstHeaderRow }
1820+ compactStickyScrollBridge = {
1821+ stickCompactFirstHeaderRow ? compactStickyScrollBridge : undefined
1822+ }
17921823 activeHeaderMenuKey = {
17931824 messagesChatOpen
17941825 ? null
@@ -1875,14 +1906,11 @@ function HomeAuthenticatedScreenMain() {
18751906 style = { {
18761907 zIndex : 3 ,
18771908 width : "100%" ,
1878- backgroundColor : colors . background ,
1909+ backgroundColor : colors . undercover ,
18791910 overflow : "visible" ,
18801911 transform : [
18811912 {
1882- translateY : Math . max (
1883- 0 ,
1884- compactHeaderScrollY - compactCollapsibleHeightPx ,
1885- ) ,
1913+ translateY : Math . max ( 0 , compactHeaderScrollY - compactNavLockAfterPx ) ,
18861914 } ,
18871915 ] ,
18881916 ...( Platform . OS === "web"
@@ -1901,6 +1929,7 @@ function HomeAuthenticatedScreenMain() {
19011929 feedUnreadCount = { feedUnreadCount }
19021930 marginTopPx = { 0 }
19031931 passVerticalScroll
1932+ tone = "undercover"
19041933 />
19051934 </ View >
19061935 </ View >
0 commit comments