11import Constants from "expo-constants" ;
2+ import type {
3+ NativeStackHeaderItem ,
4+ NativeStackNavigationOptions ,
5+ } from "@react-navigation/native-stack" ;
26import { Platform , View } from "react-native" ;
37
48import { AppText as Text } from "./AppText" ;
59import { T3Wordmark } from "./T3Wordmark" ;
610import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics" ;
711import { resolveMobileStageLabel } from "../lib/mobileBranding" ;
812import { useThemeColor } from "../lib/useThemeColor" ;
13+ import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../native/native-glass" ;
14+
15+ // Native leading items inherit different UIKit margins than title views.
16+ const IOS_NATIVE_LEADING_TITLE_OFFSET = - 6 ;
17+ const IPAD_NATIVE_LEADING_TITLE_OFFSET = 7 ;
918
1019/**
1120 * Compact brand lockup sized for native navigation bars.
1221 */
13- export function CompactBrandTitle ( ) {
22+ export function CompactBrandTitle (
23+ props : {
24+ readonly nativeLeadingItem ?: boolean ;
25+ } = { } ,
26+ ) {
1427 const iconColor = useThemeColor ( "--color-icon" ) ;
1528 const mutedColor = useThemeColor ( "--color-foreground-muted" ) ;
1629 const subtleColor = useThemeColor ( "--color-subtle" ) ;
1730 const stageLabel = resolveMobileStageLabel ( Constants . expoConfig ?. extra ?. appVariant ) ;
31+ const titleOffset =
32+ Platform . OS !== "ios"
33+ ? 0
34+ : props . nativeLeadingItem
35+ ? Platform . isPad
36+ ? IPAD_NATIVE_LEADING_TITLE_OFFSET
37+ : IOS_NATIVE_LEADING_TITLE_OFFSET
38+ : Platform . isPad
39+ ? IPAD_HOME_TITLE_OFFSET
40+ : 0 ;
1841
1942 return (
2043 < View
@@ -26,7 +49,7 @@ export function CompactBrandTitle() {
2649 alignItems : "center" ,
2750 flexDirection : "row" ,
2851 gap : 6 ,
29- marginLeft : Platform . OS === "ios" && Platform . isPad ? IPAD_HOME_TITLE_OFFSET : 0 ,
52+ marginLeft : titleOffset ,
3053 } }
3154 >
3255 < T3Wordmark color = { iconColor } height = { 15 } />
@@ -67,3 +90,32 @@ export function CompactBrandTitle() {
6790export function renderCompactBrandTitle ( ) {
6891 return < CompactBrandTitle /> ;
6992}
93+
94+ export function renderCompactBrandHeaderItems ( ) : NativeStackHeaderItem [ ] {
95+ return [
96+ {
97+ element : < CompactBrandTitle nativeLeadingItem /> ,
98+ hidesSharedBackground : true ,
99+ type : "custom" ,
100+ } ,
101+ ] ;
102+ }
103+
104+ export function getCompactBrandHeaderOptions (
105+ fallbackTitleStyle ?: NativeStackNavigationOptions [ "headerTitleStyle" ] ,
106+ ) : NativeStackNavigationOptions {
107+ if ( Platform . OS === "ios" && NATIVE_LIQUID_GLASS_SUPPORTED ) {
108+ return {
109+ headerTitle : "Threads" ,
110+ headerTitleStyle : { color : "transparent" , fontSize : 18 , fontWeight : "800" } ,
111+ title : "Threads" ,
112+ unstable_headerLeftItems : renderCompactBrandHeaderItems ,
113+ } ;
114+ }
115+
116+ return {
117+ headerTitle : renderCompactBrandTitle ,
118+ headerTitleStyle : fallbackTitleStyle ,
119+ title : "Threads" ,
120+ } ;
121+ }
0 commit comments