1import { requireNativeView } from "expo";
2import type { PropsWithChildren } from "react";
3import type { NativeSyntheticEvent, ViewProps } from "react-native";
4
5import type { HardwareKeyboardCommand } from "../features/keyboard/hardwareKeyboardCommands";
6
7interface NativeKeyboardCommandsProps extends ViewProps {
8 readonly enabledCommands: ReadonlyArray<HardwareKeyboardCommand>;
9 readonly onCommand: (
10 event: NativeSyntheticEvent<{ readonly command: HardwareKeyboardCommand }>,
11 ) => void;
12}
13
14const NativeKeyboardCommands = requireNativeView<NativeKeyboardCommandsProps>("T3KeyboardCommands");
15
16export function T3KeyboardCommands(
17 props: PropsWithChildren<{
18 readonly enabledCommands: ReadonlyArray<HardwareKeyboardCommand>;
19 readonly onCommand: (command: HardwareKeyboardCommand) => void;
20 }>,
21) {
22 return (
23 <NativeKeyboardCommands
24 onCommand={(event) => props.onCommand(event.nativeEvent.command)}
25 enabledCommands={props.enabledCommands}
26 style={{ flex: 1 }}
27 >
28 {props.children}
29 </NativeKeyboardCommands>
30 );
31}