mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-06 16:20:26 +08:00
Merge pull request #8113 from j6lim/react-native
Update definition for react-native : AppState
This commit is contained in:
@@ -21,7 +21,14 @@ For a list of complete Typescript examples: check https://github.com/bgrieder/RN
|
||||
|
||||
|
||||
import * as React from 'react-native'
|
||||
const { StyleSheet, Text, View } = React
|
||||
import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
AppState,
|
||||
AppStateIOS,
|
||||
ViewPagerAndroid
|
||||
} from 'react-native';
|
||||
|
||||
var styles = StyleSheet.create(
|
||||
{
|
||||
@@ -67,5 +74,40 @@ class Welcome extends React.Component<any,any> {
|
||||
}
|
||||
}
|
||||
|
||||
export default Welcome
|
||||
export default Welcome;
|
||||
|
||||
// App State
|
||||
|
||||
function appStateListener(state : string) {
|
||||
console.log('New state: ' + state);
|
||||
}
|
||||
|
||||
function appStateTest() {
|
||||
console.log('Current state: ' + AppState.currentState);
|
||||
AppState.addEventListener('change', appStateListener);
|
||||
}
|
||||
|
||||
function appStateIOSTest() {
|
||||
console.log('Current state: ' + AppStateIOS.currentState);
|
||||
AppStateIOS.addEventListener('change', appStateListener);
|
||||
}
|
||||
|
||||
// ViewPagerAndroid
|
||||
|
||||
export class ViewPagerAndroidTest {
|
||||
render() {
|
||||
return (
|
||||
<ViewPagerAndroid style={{height: 56}}
|
||||
initialPage={0}
|
||||
keyboardDismissMode={'on-drag'}
|
||||
onPageScroll={(e) => {
|
||||
console.log(`position: ${e.nativeEvent.position}`);
|
||||
console.log(`offset: ${e.nativeEvent.offset}`);
|
||||
}}
|
||||
onPageSelected={(e) => {
|
||||
console.log(`position: ${e.nativeEvent.position}`)
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+35
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for react-native 0.14
|
||||
// Type definitions for react-native 0.19
|
||||
// Project: https://github.com/facebook/react-native
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -979,6 +979,31 @@ declare namespace __React {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/viewpagerandroid.html#props
|
||||
*/
|
||||
|
||||
|
||||
export interface ViewPagerAndroidOnPageScrollEventData {
|
||||
position: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
export interface ViewPagerAndroidOnPageSelectedEventData {
|
||||
position: number;
|
||||
}
|
||||
|
||||
export interface ViewPagerAndroidProperties extends ViewProperties {
|
||||
initialPage?: number;
|
||||
onPageScroll?: ( event: NativeSyntheticEvent<ViewPagerAndroidOnPageScrollEventData> ) => void;
|
||||
onPageSelected?: ( event: NativeSyntheticEvent<ViewPagerAndroidOnPageSelectedEventData> ) => void;
|
||||
keyboardDismissMode?: string; /* enum('none', 'on-drag') */
|
||||
}
|
||||
|
||||
export interface ViewPagerAndroidStatic extends NativeComponent, React.ComponentClass<ViewPagerAndroidProperties> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* //FIXME: No documentation extracted from code comment on WebView.ios.js
|
||||
*/
|
||||
@@ -2853,7 +2878,7 @@ declare namespace __React {
|
||||
*
|
||||
* @see https://facebook.github.io/react-native/docs/appstateios.html#content
|
||||
*/
|
||||
export interface AppStateIOSStatic {
|
||||
export interface AppStateStatic {
|
||||
currentState: string
|
||||
addEventListener( type: string, listener: ( state: string ) => void ): void
|
||||
removeEventListener( type: string, listener: ( state: string ) => void ): void
|
||||
@@ -3364,6 +3389,9 @@ declare namespace __React {
|
||||
export var View: ViewStatic
|
||||
export type View = ViewStatic
|
||||
|
||||
export var ViewPagerAndroid: ViewPagerAndroidStatic
|
||||
export type ViewPagerAndroid = ViewPagerAndroidStatic
|
||||
|
||||
export var WebView: WebViewStatic
|
||||
export type WebView = WebViewStatic
|
||||
|
||||
@@ -3378,8 +3406,11 @@ declare namespace __React {
|
||||
export var AlertIOS: AlertIOSStatic
|
||||
export type AlertIOS = AlertIOSStatic
|
||||
|
||||
export var AppStateIOS: AppStateIOSStatic
|
||||
export type AppStateIOS = AppStateIOSStatic
|
||||
export var AppState : AppStateStatic;
|
||||
export type AppState = AppStateStatic;
|
||||
|
||||
export var AppStateIOS: AppStateStatic
|
||||
export type AppStateIOS = AppStateStatic
|
||||
|
||||
export var AsyncStorage: AsyncStorageStatic
|
||||
export type AsyncStorage = AsyncStorageStatic
|
||||
|
||||
Reference in New Issue
Block a user