1/** 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 * 7 * @format 8 */ 9 10import type * as React from 'react'; 11import {Constructor} from '../../../types/private/Utilities'; 12import {NativeMethods} from '../../../types/public/ReactNativeTypes'; 13import {ColorValue} from '../../StyleSheet/StyleSheet'; 14import { 15 NativeSyntheticEvent, 16 NativeTouchEvent, 17} from '../../Types/CoreEventTypes'; 18import {ViewProps} from '../View/ViewPropTypes'; 19 20export interface DrawerSlideEvent 21 extends NativeSyntheticEvent<NativeTouchEvent> {} 22 23/** 24 * @see DrawerLayoutAndroid.android.js 25 */ 26export interface DrawerLayoutAndroidProps extends ViewProps { 27 /** 28 * Specifies the background color of the drawer. The default value 29 * is white. If you want to set the opacity of the drawer, use rgba. 30 * Example: 31 * return ( 32 * <DrawerLayoutAndroid drawerBackgroundColor="rgba(0,0,0,0.5)"> 33 * </DrawerLayoutAndroid> 34 *); 35 */ 36 drawerBackgroundColor?: ColorValue | undefined; 37 38 /** 39 * Specifies the lock mode of the drawer. The drawer can be locked 40 * in 3 states: 41 * 42 * - unlocked (default), meaning that the drawer will respond 43 * (open/close) to touch gestures. 44 * 45 * - locked-closed, meaning that the drawer will stay closed and not 46 * respond to gestures. 47 * 48 * - locked-open, meaning that the drawer will stay opened and 49 * not respond to gestures. The drawer may still be opened and 50 * closed programmatically (openDrawer/closeDrawer). 51 */ 52 drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open' | undefined; 53 54 /** 55 * Specifies the side of the screen from which the drawer will slide in. 56 * - 'left' (the default) 57 * - 'right' 58 */ 59 drawerPosition?: 'left' | 'right' | undefined; 60 61 /** 62 * Specifies the width of the drawer, more precisely the width of the 63 * view that be pulled in from the edge of the window. 64 */ 65 drawerWidth?: number | undefined; 66 67 /** 68 * Determines whether the keyboard gets dismissed in response to a drag. 69 * - 'none' (the default), drags do not dismiss the keyboard. 70 * - 'on-drag', the keyboard is dismissed when a drag begins. 71 */ 72 keyboardDismissMode?: 'none' | 'on-drag' | undefined; 73 74 /** 75 * Function called whenever the navigation view has been closed. 76 */ 77 onDrawerClose?: (() => void) | undefined; 78 79 /** 80 * Function called whenever the navigation view has been opened. 81 */ 82 onDrawerOpen?: (() => void) | undefined; 83 84 /** 85 * Function called whenever there is an interaction with the navigation view. 86 */ 87 onDrawerSlide?: ((event: DrawerSlideEvent) => void) | undefined; 88 89 /** 90 * Function called when the drawer state has changed. 91 * The drawer can be in 3 states: 92 * - idle, meaning there is no interaction with the navigation 93 * view happening at the time 94 * - dragging, meaning there is currently an interaction with the 95 * navigation view 96 * - settling, meaning that there was an interaction with the 97 * navigation view, and the navigation view is now finishing 98 * it's closing or opening animation 99 */ 100 onDrawerStateChanged?: 101 | ((event: 'Idle' | 'Dragging' | 'Settling') => void) 102 | undefined; 103 104 /** 105 * The navigation view that will be rendered to the side of the 106 * screen and can be pulled in. 107 */ 108 renderNavigationView: () => JSX.Element; 109 110 /** 111 * Make the drawer take the entire screen and draw the background of 112 * the status bar to allow it to open over the status bar. It will 113 * only have an effect on API 21+. 114 */ 115 statusBarBackgroundColor?: ColorValue | undefined; 116} 117 118interface DrawerPosition { 119 Left: number; 120 Right: number; 121} 122 123declare class DrawerLayoutAndroidComponent extends React.Component<DrawerLayoutAndroidProps> {} 124declare const DrawerLayoutAndroidBase: Constructor<NativeMethods> & 125 typeof DrawerLayoutAndroidComponent; 126export class DrawerLayoutAndroid extends DrawerLayoutAndroidBase { 127 /** 128 * drawer's positions. 129 */ 130 positions: DrawerPosition; 131 132 /** 133 * Opens the drawer. 134 */ 135 openDrawer(): void; 136 137 /** 138 * Closes the drawer. 139 */ 140 closeDrawer(): void; 141} 142