From ad5c3af1b14c16627b45d8944a9d99a7cee51f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Sun, 22 Nov 2020 00:45:54 +0100 Subject: [PATCH] [workbench] Add missing DrawerLayoutAndroid implementation --- .../DrawerLayoutAndroid.android.js.flow | 146 ++++++++++++++++++ .../DrawerLayoutAndroid.ios.js.flow | 2 + .../Utilities/differ/sizesDiffer.js.flow | 6 +- .../DrawerAndroid/DrawerLayoutAndroid.d.ts | 144 +++++++++++++++++ .../Utilities/differ/sizesDiffer.d.ts | 6 +- .../DrawerAndroid/DrawerLayoutAndroid.d.ts | 4 + .../Utilities/differ/sizesDiffer.d.ts | 6 +- 7 files changed, 308 insertions(+), 6 deletions(-) create mode 100644 workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js.flow create mode 100644 workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js.flow create mode 100644 workbench/outputs/android/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts create mode 100644 workbench/outputs/ios/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts diff --git a/workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js.flow b/workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js.flow new file mode 100644 index 00000000..b14d5d9e --- /dev/null +++ b/workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js.flow @@ -0,0 +1,146 @@ +/** + * TODO: Figure out why these are not included in the Flow dump + */ + +import * as React from "react" + +import type { ColorValue, ViewStyleProp } from "../../StyleSheet/StyleSheet" +import type { DirectEventHandler } from "../../Types/CodegenTypes" + +type DrawerStates = "Idle" | "Dragging" | "Settling" + +type DrawerSlideEvent = $ReadOnly<{| + offset: number, +|}> + +type Props = $ReadOnly<{| + /** + * Determines whether the keyboard gets dismissed in response to a drag. + * - 'none' (the default), drags do not dismiss the keyboard. + * - 'on-drag', the keyboard is dismissed when a drag begins. + */ + keyboardDismissMode?: ?("none" | "on-drag"), + + /** + * Specifies the background color of the drawer. The default value is white. + * If you want to set the opacity of the drawer, use rgba. Example: + * + * ``` + * return ( + * + * + * ); + * ``` + */ + drawerBackgroundColor: ColorValue, + + /** + * Specifies the side of the screen from which the drawer will slide in. + */ + drawerPosition: ?("left" | "right"), + + /** + * Specifies the width of the drawer, more precisely the width of the view that be pulled in + * from the edge of the window. + */ + drawerWidth?: ?number, + + /** + * Specifies the lock mode of the drawer. The drawer can be locked in 3 states: + * - unlocked (default), meaning that the drawer will respond (open/close) to touch gestures. + * - locked-closed, meaning that the drawer will stay closed and not respond to gestures. + * - locked-open, meaning that the drawer will stay opened and not respond to gestures. + * The drawer may still be opened and closed programmatically (`openDrawer`/`closeDrawer`). + */ + drawerLockMode?: ?("unlocked" | "locked-closed" | "locked-open"), + + /** + * Function called whenever there is an interaction with the navigation view. + */ + onDrawerSlide?: ?DirectEventHandler, + + /** + * Function called when the drawer state has changed. The drawer can be in 3 states: + * - Idle, meaning there is no interaction with the navigation view happening at the time + * - Dragging, meaning there is currently an interaction with the navigation view + * - Settling, meaning that there was an interaction with the navigation view, and the + * navigation view is now finishing its closing or opening animation + */ + onDrawerStateChanged?: ?(state: DrawerStates) => mixed, + + /** + * Function called whenever the navigation view has been opened. + */ + onDrawerOpen?: ?() => mixed, + + /** + * Function called whenever the navigation view has been closed. + */ + onDrawerClose?: ?() => mixed, + + /** + * The navigation view that will be rendered to the side of the screen and can be pulled in. + */ + renderNavigationView: () => React.Element, + + /** + * Make the drawer take the entire screen and draw the background of the + * status bar to allow it to open over the status bar. It will only have an + * effect on API 21+. + */ + statusBarBackgroundColor?: ?ColorValue, + + children?: React.Node, + style?: ?ViewStyleProp, +|}> + +/** + * React component that wraps the platform `DrawerLayout` (Android only). The + * Drawer (typically used for navigation) is rendered with `renderNavigationView` + * and direct children are the main view (where your content goes). The navigation + * view is initially not visible on the screen, but can be pulled in from the + * side of the window specified by the `drawerPosition` prop and its width can + * be set by the `drawerWidth` prop. + * + * Example: + * + * ``` + * render: function() { + * var navigationView = ( + * + * I'm in the Drawer! + * + * ); + * return ( + * navigationView}> + * + * Hello + * World! + * + * + * ); + * }, + * ``` + */ +declare class DrawerLayoutAndroid extends React.Component { + static positions: () => mixed; + + static defaultProps: {| + drawerBackgroundColor: "white", + |}; + + /** + * Opens the drawer. + */ + openDrawer: () => void; + + /** + * Closes the drawer. + */ + closeDrawer: () => void; +} + +declare module.exports: typeof DrawerLayoutAndroid diff --git a/workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js.flow b/workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js.flow new file mode 100644 index 00000000..98a391f9 --- /dev/null +++ b/workbench/inputs/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js.flow @@ -0,0 +1,2 @@ +import UnimplementedView from "../UnimplementedViews/UnimplementedView" +declare module.exports: typeof UnimplementedView diff --git a/workbench/inputs/Libraries/Utilities/differ/sizesDiffer.js.flow b/workbench/inputs/Libraries/Utilities/differ/sizesDiffer.js.flow index e5c61883..78acdafa 100644 --- a/workbench/inputs/Libraries/Utilities/differ/sizesDiffer.js.flow +++ b/workbench/inputs/Libraries/Utilities/differ/sizesDiffer.js.flow @@ -1,5 +1,7 @@ -// @flow -// TODO: Move these Flow typings upstream +/** + * TODO: Move these Flow typings upstream + */ + type Size = { width: ?number, height: ?number, diff --git a/workbench/outputs/android/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts b/workbench/outputs/android/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts new file mode 100644 index 00000000..95f09ee5 --- /dev/null +++ b/workbench/outputs/android/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts @@ -0,0 +1,144 @@ +/** + * TODO: Figure out why these are not included in the Flow dump + */ +import * as React from "react"; +import { ColorValue, ViewStyleProp } from "../../StyleSheet/StyleSheet"; +import { DirectEventHandler } from "../../Types/CodegenTypes"; +declare type DrawerStates = "Idle" | "Dragging" | "Settling"; +declare type DrawerSlideEvent = Readonly< +/*[FLOW2DTS - Warning] This type was an exact object type in the original Flow source.*/ +{ + offset: number; +}>; +declare type Props = Readonly< +/*[FLOW2DTS - Warning] This type was an exact object type in the original Flow source.*/ +{ + /** + * Determines whether the keyboard gets dismissed in response to a drag. + * - 'none' (the default), drags do not dismiss the keyboard. + * - 'on-drag', the keyboard is dismissed when a drag begins. + */ + keyboardDismissMode?: null | undefined | ("none" | "on-drag"); + + /** + * Specifies the background color of the drawer. The default value is white. + * If you want to set the opacity of the drawer, use rgba. Example: + * + * ``` + * return ( + * + * + * ); + * ``` + */ + drawerBackgroundColor: ColorValue; + + /** + * Specifies the side of the screen from which the drawer will slide in. + */ + drawerPosition: null | undefined | ("left" | "right"); + + /** + * Specifies the width of the drawer, more precisely the width of the view that be pulled in + * from the edge of the window. + */ + drawerWidth?: null | undefined | number; + + /** + * Specifies the lock mode of the drawer. The drawer can be locked in 3 states: + * - unlocked (default), meaning that the drawer will respond (open/close) to touch gestures. + * - locked-closed, meaning that the drawer will stay closed and not respond to gestures. + * - locked-open, meaning that the drawer will stay opened and not respond to gestures. + * The drawer may still be opened and closed programmatically (`openDrawer`/`closeDrawer`). + */ + drawerLockMode?: null | undefined | ("unlocked" | "locked-closed" | "locked-open"); + + /** + * Function called whenever there is an interaction with the navigation view. + */ + onDrawerSlide?: null | undefined | DirectEventHandler; + + /** + * Function called when the drawer state has changed. The drawer can be in 3 states: + * - Idle, meaning there is no interaction with the navigation view happening at the time + * - Dragging, meaning there is currently an interaction with the navigation view + * - Settling, meaning that there was an interaction with the navigation view, and the + * navigation view is now finishing its closing or opening animation + */ + onDrawerStateChanged?: null | undefined | ((state: DrawerStates) => unknown); + + /** + * Function called whenever the navigation view has been opened. + */ + onDrawerOpen?: null | undefined | (() => unknown); + + /** + * Function called whenever the navigation view has been closed. + */ + onDrawerClose?: null | undefined | (() => unknown); + + /** + * The navigation view that will be rendered to the side of the screen and can be pulled in. + */ + renderNavigationView: () => React.Element; + + /** + * Make the drawer take the entire screen and draw the background of the + * status bar to allow it to open over the status bar. It will only have an + * effect on API 21+. + */ + statusBarBackgroundColor?: null | undefined | ColorValue; + children?: React.Node; + style?: null | undefined | ViewStyleProp; +}>; +/** + * React component that wraps the platform `DrawerLayout` (Android only). The + * Drawer (typically used for navigation) is rendered with `renderNavigationView` + * and direct children are the main view (where your content goes). The navigation + * view is initially not visible on the screen, but can be pulled in from the + * side of the window specified by the `drawerPosition` prop and its width can + * be set by the `drawerWidth` prop. + * + * Example: + * + * ``` + * render: function() { + * var navigationView = ( + * + * I'm in the Drawer! + * + * ); + * return ( + * navigationView}> + * + * Hello + * World! + * + * + * ); + * }, + * ``` + */ + +declare class DrawerLayoutAndroid extends React.Component { + static positions(): unknown; + static defaultProps: + /*[FLOW2DTS - Warning] This type was an exact object type in the original Flow source.*/ + { + drawerBackgroundColor: "white"; + }; + + /** + * Opens the drawer. + */ + openDrawer(): void; + + /** + * Closes the drawer. + */ + closeDrawer(): void; +} +export default DrawerLayoutAndroid; \ No newline at end of file diff --git a/workbench/outputs/android/Libraries/Utilities/differ/sizesDiffer.d.ts b/workbench/outputs/android/Libraries/Utilities/differ/sizesDiffer.d.ts index 495c35b5..f745642f 100644 --- a/workbench/outputs/android/Libraries/Utilities/differ/sizesDiffer.d.ts +++ b/workbench/outputs/android/Libraries/Utilities/differ/sizesDiffer.d.ts @@ -1,6 +1,8 @@ import { $TypeOf } from "flow2dts-flow-types-polyfill"; -// @flow -// TODO: Move these Flow typings upstream + +/** + * TODO: Move these Flow typings upstream + */ declare type Size = { width: null | undefined | number; height: null | undefined | number; diff --git a/workbench/outputs/ios/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts b/workbench/outputs/ios/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts new file mode 100644 index 00000000..686c58b0 --- /dev/null +++ b/workbench/outputs/ios/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts @@ -0,0 +1,4 @@ +import { $TypeOf } from "flow2dts-flow-types-polyfill"; +import UnimplementedView from "../UnimplementedViews/UnimplementedView"; +declare const $f2tExportDefault: $TypeOf; +export default $f2tExportDefault; \ No newline at end of file diff --git a/workbench/outputs/ios/Libraries/Utilities/differ/sizesDiffer.d.ts b/workbench/outputs/ios/Libraries/Utilities/differ/sizesDiffer.d.ts index 495c35b5..f745642f 100644 --- a/workbench/outputs/ios/Libraries/Utilities/differ/sizesDiffer.d.ts +++ b/workbench/outputs/ios/Libraries/Utilities/differ/sizesDiffer.d.ts @@ -1,6 +1,8 @@ import { $TypeOf } from "flow2dts-flow-types-polyfill"; -// @flow -// TODO: Move these Flow typings upstream + +/** + * TODO: Move these Flow typings upstream + */ declare type Size = { width: null | undefined | number; height: null | undefined | number;