Open History to see the last commit
1import Constants from "expo-constants";
2import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
3import { Platform, View } from "react-native";
4
5import { AppText as Text } from "./AppText";
6import { T3Wordmark } from "./T3Wordmark";
7import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics";
8import { resolveMobileStageLabel } from "../lib/mobileBranding";
9import { useAndroidControlSizing } from "./useAndroidControlSizing";
10
11/**
12 * Horizontal correction applied to content rendered in the brand title slot,
13 * shared with the connection-status swap so both align identically.
14 */
15export function brandTitleOffset(): number {
16 if (Platform.OS !== "ios") return 0;
17 return Platform.isPad ? IPAD_HOME_TITLE_OFFSET : 0;
18}
19
20/**
21 * Compact brand lockup sized for native navigation bars.
22 */
23export function CompactBrandTitle(
24 props: {
25 readonly allowFontScaling?: boolean;
26 } = {},
27) {
28 const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
29 const titleOffset = brandTitleOffset();
30 const { scale } = useAndroidControlSizing();
31
32 return (
33 <View
34 aria-level={1}
35 accessibilityLabel="T3 Code, Threads"
36 accessible
37 role="heading"
38 className="flex-row items-center gap-1.5"
39 style={[{ marginLeft: titleOffset }, Platform.OS === "android" && { gap: 5.25 * scale }]}
40 >
41 <T3Wordmark colorClassName="accent-icon" height={Math.round(15 * scale)} />
42 <Text
43 allowFontScaling={props.allowFontScaling}
44 className="font-t3-medium text-foreground-muted"
45 style={{ fontSize: 21 * scale, letterSpacing: -0.5 * scale }}
46 >
47 Code
48 </Text>
49 <View
50 className="rounded-full bg-subtle px-1.5 py-0.5"
51 style={
52 Platform.OS === "android"
53 ? { paddingHorizontal: 5.25 * scale, paddingVertical: 1.75 * scale }
54 : undefined
55 }
56 >
57 <Text
58 allowFontScaling={props.allowFontScaling}
59 className="font-t3-bold text-foreground-muted uppercase"
60 style={{ fontSize: 9 * scale, letterSpacing: 0.9 * scale }}
61 >
62 {stageLabel}
63 </Text>
64 </View>
65 </View>
66 );
67}
68
69export function renderCompactBrandTitle() {
70 return <CompactBrandTitle allowFontScaling={Platform.OS === "ios"} />;
71}
72
73export function getCompactBrandHeaderOptions(
74 fallbackTitleStyle?: NativeStackNavigationOptions["headerTitleStyle"],
75): NativeStackNavigationOptions {
76 return {
77 headerTitle: renderCompactBrandTitle,
78 headerTitleStyle: fallbackTitleStyle,
79 title: "Threads",
80 unstable_headerLeftItems: undefined,
81 };
82}