mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-20 12:46:36 +08:00
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import * as React from 'react';
|
|
import { View } from 'react-native';
|
|
import {
|
|
addNavigationHelpers,
|
|
NavigationScreenProps,
|
|
NavigationStackAction,
|
|
NavigationTabScreenOptions,
|
|
StackNavigator,
|
|
TabNavigatorConfig,
|
|
TabBarTop,
|
|
TabBarBottom,
|
|
} from 'react-navigation';
|
|
|
|
/**
|
|
* @class StartScreen @extends React.Component
|
|
* @desc Simple screen component class with typed component props that should
|
|
* receive the navigation prop from the AppNavigator.
|
|
*/
|
|
interface StartScreenComponentProps {
|
|
id: number,
|
|
s: string,
|
|
}
|
|
interface StartScreenProps extends NavigationScreenProps<StartScreenComponentProps> { }
|
|
class StartScreen extends React.Component<StartScreenProps, {}> {
|
|
render() {
|
|
// Implicit type checks.
|
|
const navigationStateParams: StartScreenComponentProps = this.props.navigation.state.params;
|
|
const id = this.props.navigation.state.params.id;
|
|
const s = this.props.navigation.state.params.s;
|
|
|
|
return (
|
|
<View />
|
|
);
|
|
}
|
|
}
|
|
|
|
export const AppNavigator = StackNavigator({
|
|
StartImage: {
|
|
path: 'startImage',
|
|
screen: StartScreen,
|
|
},
|
|
}, {
|
|
initialRouteName: 'StartImage',
|
|
});
|
|
|
|
const Router = (props: any) => (
|
|
<AppNavigator
|
|
navigation={
|
|
addNavigationHelpers({
|
|
dispatch: (action: NavigationStackAction): boolean => { return true; },
|
|
state: {},
|
|
})
|
|
}
|
|
/>
|
|
);
|
|
|
|
const tabNavigatorScreenOptions: NavigationTabScreenOptions = {
|
|
title: 'title',
|
|
tabBarVisible: true,
|
|
tabBarIcon: <View />,
|
|
tabBarLabel: 'label',
|
|
}
|
|
|
|
const tabNavigatorConfig: TabNavigatorConfig = {
|
|
lazy: true,
|
|
tabBarComponent: TabBarTop,
|
|
}
|