Open History to see the last commit
1import { RNHostView, TopAppBar } from "@expo/ui/jetpack-compose";
2import { fillMaxWidth, height } from "@expo/ui/jetpack-compose/modifiers";
3import type { ReactElement } from "react";
4import { NativeThemeHost } from "./NativeThemeHost.android";
5import { useControlTheme } from "./useControlTheme";
6import { useToolbarLayout } from "./useToolbarLayout";
7
8/** Internal renderer. The surrounding screen owns status-bar and sheet insets. */
9export function NativeAppBar(props: {
10 readonly title: ReactElement;
11 readonly navigationIcon?: ReactElement;
12 readonly actions?: ReactElement;
13}) {
14 const { colors } = useControlTheme();
15 const layout = useToolbarLayout();
16 return (
17 <NativeThemeHost matchContents={{ vertical: true }} style={{ width: "100%" }}>
18 <TopAppBar
19 applyWindowInsets={false}
20 modifiers={[fillMaxWidth(), height(Math.max(64, layout.height))]}
21 colors={{
22 containerColor: colors["--color-header"],
23 titleContentColor: colors["--color-header-foreground"],
24 navigationIconContentColor: colors["--color-header-foreground"],
25 actionIconContentColor: colors["--color-header-foreground"],
26 }}
27 >
28 <TopAppBar.Title>{props.title}</TopAppBar.Title>
29 {props.navigationIcon ? (
30 <TopAppBar.NavigationIcon>
31 <RNHostView matchContents>{props.navigationIcon}</RNHostView>
32 </TopAppBar.NavigationIcon>
33 ) : null}
34 {props.actions ? (
35 <TopAppBar.Actions>
36 <RNHostView matchContents>{props.actions}</RNHostView>
37 </TopAppBar.Actions>
38 ) : null}
39 </TopAppBar>
40 </NativeThemeHost>
41 );
42}