MCPcopy Index your code
hub / github.com/callstack/react-native-paper / Appbar

Function Appbar

src/components/Appbar/Appbar.tsx:157–339  ·  view source on GitHub ↗
({
  children,
  dark,
  style,
  mode = 'small',
  elevated,
  safeAreaInsets,
  theme: themeOverrides,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

155 * ```
156 */
157const Appbar = ({
158 children,
159 dark,
160 style,
161 mode = 'small',
162 elevated,
163 safeAreaInsets,
164 theme: themeOverrides,
165 ...rest
166}: Props) => {
167 const theme = useInternalTheme(themeOverrides);
168 const { isV3 } = theme;
169 const flattenedStyle = StyleSheet.flatten(style);
170 const {
171 backgroundColor: customBackground,
172 elevation = isV3 ? (elevated ? 2 : 0) : 4,
173 ...restStyle
174 } = (flattenedStyle || {}) as Exclude<typeof flattenedStyle, number> & {
175 elevation?: number;
176 backgroundColor?: ColorValue;
177 };
178
179 const backgroundColor = getAppbarBackgroundColor(
180 theme,
181 elevation,
182 customBackground,
183 elevated
184 );
185
186 const isMode = (modeToCompare: AppbarModes) => {
187 return isV3 && mode === modeToCompare;
188 };
189
190 let isDark = false;
191
192 if (typeof dark === 'boolean') {
193 isDark = dark;
194 } else if (!isV3) {
195 isDark =
196 backgroundColor === 'transparent'
197 ? false
198 : typeof backgroundColor === 'string'
199 ? !color(backgroundColor).isLight()
200 : true;
201 }
202
203 const isV3CenterAlignedMode = isV3 && isMode('center-aligned');
204
205 let shouldCenterContent = false;
206 let shouldAddLeftSpacing = false;
207 let shouldAddRightSpacing = false;
208 if ((!isV3 && Platform.OS === 'ios') || isV3CenterAlignedMode) {
209 let hasAppbarContent = false;
210 let leftItemsCount = 0;
211 let rightItemsCount = 0;
212
213 React.Children.forEach(children, (child) => {
214 if (React.isValidElement<AppbarChildProps>(child)) {

Callers

nothing calls this directly

Calls 5

useInternalThemeFunction · 0.90
getAppbarBackgroundColorFunction · 0.90
renderAppbarContentFunction · 0.90
filterAppbarActionsFunction · 0.90
isModeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…