| 1 | import { requireNativeView } from "expo"; |
| 2 | import type { PropsWithChildren } from "react"; |
| 3 | import type { NativeSyntheticEvent, ViewProps } from "react-native"; |
| 4 | |
| 5 | import type { HardwareKeyboardCommand } from "../features/keyboard/hardwareKeyboardCommands"; |
| 6 | |
| 7 | interface NativeKeyboardCommandsProps extends ViewProps { |
| 8 | readonly enabledCommands: ReadonlyArray<HardwareKeyboardCommand>; |
| 9 | readonly onCommand: ( |
| 10 | event: NativeSyntheticEvent<{ readonly command: HardwareKeyboardCommand }>, |
| 11 | ) => void; |
| 12 | } |
| 13 | |
| 14 | const NativeKeyboardCommands = requireNativeView<NativeKeyboardCommandsProps>("T3KeyboardCommands"); |
| 15 | |
| 16 | export 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 | } |