MCPcopy
hub / github.com/callstack/react-native-paper / AppbarHeader

Function AppbarHeader

src/components/Appbar/AppbarHeader.tsx:95–161  ·  view source on GitHub ↗
({
  // Don't use default props since we check it to know whether we should use SafeAreaView
  statusBarHeight,
  style,
  dark,
  mode = Platform.OS === 'ios' ? 'center-aligned' : 'small',
  elevated = false,
  theme: themeOverrides,
  testID = 'appbar-header',
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

93 * ```
94 */
95const AppbarHeader = ({
96 // Don't use default props since we check it to know whether we should use SafeAreaView
97 statusBarHeight,
98 style,
99 dark,
100 mode = Platform.OS === 'ios' ? 'center-aligned' : 'small',
101 elevated = false,
102 theme: themeOverrides,
103 testID = 'appbar-header',
104 ...rest
105}: Props) => {
106 const theme = useInternalTheme(themeOverrides);
107 const { isV3 } = theme;
108
109 const flattenedStyle = StyleSheet.flatten(style);
110 const {
111 height = isV3 ? modeAppbarHeight[mode] : DEFAULT_APPBAR_HEIGHT,
112 elevation = isV3 ? (elevated ? 2 : 0) : 4,
113 backgroundColor: customBackground,
114 zIndex = isV3 && elevated ? 1 : 0,
115 ...restStyle
116 } = (flattenedStyle || {}) as Exclude<typeof flattenedStyle, number> & {
117 height?: number;
118 elevation?: number;
119 backgroundColor?: ColorValue;
120 zIndex?: number;
121 };
122
123 const borderRadius = getAppbarBorders(restStyle);
124
125 const backgroundColor = getAppbarBackgroundColor(
126 theme,
127 elevation,
128 customBackground,
129 elevated
130 );
131
132 const { top, left, right } = useSafeAreaInsets();
133
134 return (
135 <View
136 testID={`${testID}-root-layer`}
137 style={[
138 {
139 backgroundColor,
140 zIndex,
141 elevation,
142 paddingTop: statusBarHeight ?? top,
143 paddingHorizontal: Math.max(left, right),
144 },
145 borderRadius,
146 shadow(elevation) as ViewStyle,
147 ]}
148 >
149 <Appbar
150 testID={testID}
151 style={[{ height, backgroundColor }, styles.appbar, restStyle]}
152 dark={dark}

Callers

nothing calls this directly

Calls 4

useInternalThemeFunction · 0.90
getAppbarBordersFunction · 0.90
getAppbarBackgroundColorFunction · 0.90
shadowFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…