Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

Toolbar.android.tsx

38 lines1.4 KB

1import { NativeHeaderToolbar } from "../../native/NativeHeaderToolbar";
2import { NativeThemeHost } from "./NativeThemeHost.android";
3import { HorizontalFloatingToolbar, RNHostView } from "@expo/ui/jetpack-compose";
4import type { ToolbarProps } from "./Toolbar.types";
5​
6import { useControlTheme } from "./useControlTheme";
7​
8/** Native toolbar surface; hosted RN controls retain their existing menus and accessibility. */
9function ToolbarRoot(props: ToolbarProps) {
10 const { colors } = useControlTheme();
11 if (props.placement) return <NativeHeaderToolbar {...props} />;
12 return (
13 <NativeThemeHost
14 matchContents
15 ignoreSafeAreaKeyboardInsets
16 style={{ alignSelf: "center", maxWidth: "100%" }}
17 >
18 <HorizontalFloatingToolbar
19 colors={{
20 toolbarContainerColor: colors["--color-grouped-card"],
21 toolbarContentColor: colors["--color-foreground"],
22 }}
23 >
24 <RNHostView matchContents>{props.children}</RNHostView>
25 </HorizontalFloatingToolbar>
26 </NativeThemeHost>
27 );
29​
30export const Toolbar = Object.assign(ToolbarRoot, {
31 Button: NativeHeaderToolbar.Button,
32 Custom: NativeHeaderToolbar.Custom,
33 Label: NativeHeaderToolbar.Label,
34 Menu: NativeHeaderToolbar.Menu,
35 MenuAction: NativeHeaderToolbar.MenuAction,
36 SearchBarSlot: NativeHeaderToolbar.SearchBarSlot,
37 Spacer: NativeHeaderToolbar.Spacer,
38});