Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Last active June 6, 2018 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/430fc977a56f2ba682e17f77b61b70f6 to your computer and use it in GitHub Desktop.
Save Noitidart/430fc977a56f2ba682e17f77b61b70f6 to your computer and use it in GitHub Desktop.
files i use in my flow-typed dir
type IdStr = string;
type Id = number;
type UTC = number; // Date.now
type InteractableSnap = (e: { nativeEvent:{ id:null|string, index:number }}) => void
// @flow
import type { StyleObj } from 'react-native/Libraries/StyleSheet/StyleSheetTypes'
import type { ImageSource as ImageSourceType } from 'react-native/Libraries/Image/ImageSource'
import type { Styles as StylesType, StyleSheet as StyleSheetTypeType } from 'react-native/Libraries/StyleSheet/StyleSheet'
type ImageSource = ImageSourceType;
type Style = StyleObj;
type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
type FontStyle = 'normal' | 'italic';
type FontSize = number;
type StyleSheetStyle = number;
type Styles = StylesType;
type StyleSheetType = StyleSheet;
type Color = string;
type TextProps = {};
type TouchableHighlightProps = {};
type AnimatedValue = *;
type AnimatedCallback = ({ finished:boolean }) => void
type LayoutEvent = { nativeEvent:{ layout:{ width:number, height:number, x:number, y:number } } };
type ImageLoadEvent = { nativeEvent:{ source:{ width:number, height:number } } };
type ScrollEvent = {
nativeEvent: { // tested on android 6.0/23 for onScroll and onMomentScrollEnd on <ScrollView>
contentInset: { bottom:number, left:number, right:number, top:number },
contentOffset: { x:number, y:number },
contentSize: { height:number, width:number },
layoutMeasurement: { height:number, width:number },
responderIgnoreScroll: boolean,
target: number,
velocity: { x:number, y:number }
}
}
// FlatList
type RenderItemArg ={|
item: {| // not really exact, but i need it exact as i spread it. it also has each DataItem
key: string,
// ...DataItem
|},
index: number,
separators: {| // seen on android rn 0.53.3
highlight: () => void,
unhighlight: () => void,
updateProps: () => void
|}
|}
type RenderItem = RenderItemArg => Element
type ScrollToIndex = ({ animated?:boolean, index:number, viewOffset?:number, viewPosition?:number }) => void // https://github.com/facebook/react-native/blob/master/Libraries/Lists/FlatList.js#L345
// Keyboard listener
type KeyboardDidShowEvent = { // tested on android 6.0/23
endCoodrinates: {
height: number,
screenX: number,
screenY: number, // float
width: number
}
}
type KeyboardWillShowEvent = {| // tested ios rn 0.53.3
easing: 'keyboard',
endCoordinates: {|
screenY: number,
height: number,
screenX: number,
width: number
|},
startCoordinates: {|
screenY: number,
height: number,
screenX: number,
width: number
|},
duration: number
|}
type KeyboardWillHideEvent = KeyboardWillShowEvent; // tested ios rn 0.53.3
type KeyboardDidHideEvent = null; // tested on android 6.0/23
type Navigate = string => void
type GoBack = void => void
type SetParams = ({}) => void
type Navigation = {
navigate: Navigate,
goBack: GoBack,
setParams: SetParams,
state: {
routes: { key:string }[],
state: key
}
}
// https://flow.org/en/docs/react/types/
import * as React from 'react'
type Node = React.Node;
type ChildrenArray = React.ChildrenArray;
type Element = React.Element; // React.Element<typeof Component>
type ElementRef = React.ElementRef; // React.ElementRef<typeof Component>
type ComponentType = React.ComponentType;
type PureComponentType = React.StatelessFunctionalComponent;
type Key = React.Key;
type ElementProps = React.ElementProps;
type ElementConfig = React.ElementConfig;
type Ref = React.Ref;
// https://flow.org/en/docs/react/redux/
type Dispatch = (action: {type:string}) => any;
type Action = { type:string }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment