DefinitelyTyped/react-native/react-native-tests.tsx
Andy Shu Xin 5a3d3f6fbd RN: Fix typo and flukes (#9665)
* RN: add props definition for WebView

* RN: Add platform-specific props to WebView

* RN: Add getWebViewHandle method

* RN: add source props to WebView

* RN: fix type of decelerationRate

* RN: Update Picker.Item props

* RN: Update props name

* RN: Clarify mode range

* RN: Add definition for DrawerLayoutAndroid

* RN: Update Image

* RN: Update ListView

* RN: Update MapView to 0.25

* RN: Add Modal

* RN: Update ScrollView

* RN: Add SegmentedControlIOS

* RN: Add Slider

* RN: Update SliderIOS

* RN: Define Status Bar

* RN: export StatusBar

* RN: Define Switch

* RN: Update Text

* RN: Update TextInput

* RN: Add ToolbarAndroid

* RN: Update TouchableOpacity

* RN: Update TouchableWithoutFeedback

* RN: Update View

* RN: Update ViewPagerAndroid

* RN: Fix mistakes

* RN: Unify indentation

* Add 2 components; fix some minor problems

* fix: follow the convention

* RN: Update ActionSheetIOS

* RN: Add Alert api

* RN: Fix reference

* RN: Update AlertIOS

* RN: add typing for type parameter

* RN: Update AppRegistry

* RN: Update AppState and AppStateIOS

* RN: Add BackAndroid

* RN: Update Camera Roll

* RN: Add Clipboard

* RN: Add DatePickerAndroid

* RN: Update Dimensions

* RN: Update InteractionManager

* RN: Add methods to DrawerLayoutAndroid

* RN: Export DatePickerAndroid

* RN: Add IntentAndroid

* RN: Add Linking

* RN: Add LinkingIOS

* RN: Add NetInfo

* RN: Update PixelRatio

* RN: Update PushNotificationIOS

* RN: Update StyleSheet

* RN: Add TimePickerAndroid

* RN: Update ToastAndroid

* RN: Add Vibration

* RN: Set stricter definition for flexbox props

* RN: Define ShadowPropTypesIOSStatic

* RN: Fix indentation

* RN: Add Geolocation

* RN: Export Geolocation

* RN: Move Geolocation to proper position

* RN: Define fetch

* RN: Fix tabs

* RN: Define schedulers

* RN: Major fixes from @PublicParadise

* RN: Update version

* RN: Add documentation as comments

* RN: Add more comments

* fix: typo

* add some missing callbacks

* RN: Export switch

* add missing commentes

* Fix(Switch): add style property

* RN: Update Navigation Experimental

* RN: Define SwipableListView

* RN: Add necessary marks

* RN: Improve unclear typing

* RN: Enable pagingEnabled for ScrollView

* RN: Enable returnKeyType for both platforms

* RN: Add returnKeyLabel to Android

* RN: Add a prop

* RN: Add scrollEnabled prop in 0.27

* RN: Add new prop from 0.27

* RN: Fix typo

* RN: Remove redundant export

* RN: Fix typo

* RN: Add missing definitions

* RN: Fix missing type declarations

* Annotate params
2016-06-19 12:00:06 +09:00

154 lines
3.3 KiB
TypeScript

/*
Note: This must be compiled with the target set to ES6
The content of index.io.js could be something like
'use strict';
import { AppRegistry } from 'react-native'
import Welcome from './gen/Welcome'
AppRegistry.registerComponent('MopNative', () => Welcome);
For a list of complete Typescript examples: check https://github.com/bgrieder/RNTSExplorer
*/
///<reference path="../react-native/react-native.d.ts" />
import * as React from 'react-native'
import {
StyleSheet,
Text,
View,
AppState,
AppStateIOS,
ViewPagerAndroid,
Dimensions,
BackAndroid,
} from 'react-native';
function testDimensions() {
var {
width,
height,
scale,
fontScale,
} = Dimensions.get("window");
var {
width,
height,
scale,
fontScale,
} = Dimensions.get("screen");
}
BackAndroid.addEventListener("hardwareBackPress", () => {
});
interface LocalStyles {
container: React.ViewStyle;
welcome: React.TextStyle;
instructions: React.TextStyle;
}
var styles = StyleSheet.create<LocalStyles>(
{
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
}
)
class Welcome extends React.Component<any,any> {
refs: {
[key: string]: any
rootView: View
}
testNativeMethods() {
// this.setNativeProps({});
const { rootView } = this.refs;
rootView.measure((x: number, y: number, width: number, height: number) => {
});
}
render() {
return (
<View ref="rootView" style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
)
}
}
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}`)
}}
/>
);
}
}