mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Switch from var to const * import React instead of /// <reference types="react" /> * Fix TextInput and remove TextInputStatic See #16318 [react-native] Wrong type for component ref * Remove TextStatic * Remove ActivityIndicatorStatic * Remove ActivityIndicatorIOSStatic * Remove DatePickerIOSStatic * Remove DrawerLayoutAndroidStatic * Remove ImageStatic * Remove ImageBackgroundStatic * Remove InputAccessoryViewStatic * Remove ListViewStatic * Remove MapViewStatic * Remove MaskedViewStatic * Remove ModalStatic * Remove NavigatorIOSStatic * Remove PickerStatic * Remove PickerIOSStatic * Remove ProgressBarAndroidStatic * Remove ProgressViewIOSStatic * Remove RefreshControlStatic * Remove RecyclerViewBackedScrollViewStatic * Remove SafeAreaViewStatic * Remove SegmentedControlIOSStatic * Remove SliderStatic * Remove StatusBarStatic * Remove ScrollViewStatic * Remove SnapshotViewIOSStatic * Remove SwipeableListViewStatic * Remove SwitchStatic * Remove SwitchIOSStatic * Remove TabBarIOSStatic * Remove ToolbarAndroidStatic * Remove TouchableHighlightStatic * Remove TouchableNativeFeedbackStatic * Remove TouchableOpacityStatic * Remove TouchableWithoutFeedbackStatic * Remove ViewStatic * Remove ViewPagerAndroidStatic * Remove WebViewStatic * Remove ButtonStatic * Remove ClippingRectangleStatic, GroupStatic, ShapeStatic, SurfaceStatic, ARTTextStatic, ARTTextStatic * Remove KeyboardAvoidingViewStatic * Remove FlatListStatic * Rename TextProperties and friends to *Props * Rename TextInputProperties and friends to *Props * Rename WebViewProperties and friends to *Props * Rename *Properties to *Props * Rename ScrollViewProperties and friends to *Props * Improve DatePickerAndroid.open() * Rename ImagePropertiesSourceOptions to ImageSourcePropType * Rename MaskedViewProps to MaskedViewIOSProps * Rename PointProperties to PointPropType * Rename TabBarItem to TabBarIOSItem * Remove internal *Properties * ImagePropertiesSourceOptions => ImagePropsSourceOptions * Merge fail: react-native-linear-gradient has been removed * Rename ImageProperties to ImageProps * Update authors list * Remove ImagePropsSourceOptions * Move *Properties redirections to legacy-properties.d.ts
90 lines
2.0 KiB
TypeScript
90 lines
2.0 KiB
TypeScript
import * as React from 'react';
|
|
import { StyleSheet, Text, TouchableOpacity, TouchableOpacityProps, View } from 'react-native';
|
|
import { AndroidBackButton, BackButton, Link, NativeRouter as Router, Route } from 'react-router-native';
|
|
|
|
const Home: React.SFC = () => {
|
|
return (
|
|
<View>
|
|
<Text style={styles.welcome}>
|
|
Welcome to React Native!
|
|
</Text>
|
|
<Text style={styles.instructions}>
|
|
Press Cmd+R to reload,{'\n'}
|
|
Cmd+D or shake for dev menu
|
|
</Text>
|
|
</View>
|
|
);
|
|
};
|
|
|
|
const About: React.SFC = () => {
|
|
return (
|
|
<Text style={styles.header}>
|
|
About
|
|
</Text>
|
|
);
|
|
};
|
|
|
|
interface ButtonTextProps extends TouchableOpacityProps {
|
|
text: string;
|
|
}
|
|
|
|
const ButtonText: React.SFC<ButtonTextProps> = ({ text, ...props }) => (
|
|
<TouchableOpacity {...props}><Text>{text}</Text></TouchableOpacity>
|
|
);
|
|
|
|
export default class App extends React.Component {
|
|
render() {
|
|
return (
|
|
<Router initialEntries={['/']} initialIndex={0}>
|
|
<BackButton />
|
|
<AndroidBackButton>
|
|
<View style={styles.container}>
|
|
<View style={styles.nav}>
|
|
<Link to="/" style={styles.navItem}>
|
|
<Text>Home</Text>
|
|
</Link>
|
|
<Link to="/about" style={styles.navItem} component={ButtonText} text="About" />
|
|
</View>
|
|
<Route exact path="/" component={Home} />
|
|
<Route path="/about" component={About} />
|
|
</View>
|
|
</AndroidBackButton>
|
|
</Router>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor: '#F5FCFF',
|
|
},
|
|
header: {
|
|
fontSize: 20
|
|
},
|
|
nav: {
|
|
flexDirection: 'row',
|
|
justifyContent: 'space-around'
|
|
},
|
|
navItem: {
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
padding: 10
|
|
},
|
|
subNavItem: {
|
|
padding: 5
|
|
},
|
|
welcome: {
|
|
fontSize: 20,
|
|
textAlign: 'center',
|
|
margin: 10,
|
|
},
|
|
instructions: {
|
|
textAlign: 'center',
|
|
color: '#333333',
|
|
marginBottom: 5,
|
|
},
|
|
});
|