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