import * as React from 'react';
import { Button, StatusBar } from 'react-native';
import { SafeAreaView } from '@react-navigation/native';
import { createStackNavigator } from 'react-navigation-stack';
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigation } = this.props;
const { push } = navigation;
return (
);
}
}
class OtherScreen extends React.Component {
static navigationOptions = {
title: 'Your title here',
};
render() {
const { navigation } = this.props;
const { push, pop } = navigation;
return (
push('ScreenWithLongTitle')}
title="Push another screen"
/>
push('ScreenWithNoHeader')}
title="Push screen with no header"
/>
pop()} title="Pop" />
navigation.goBack(null)} title="Go back" />
);
}
}
class ScreenWithLongTitle extends React.Component {
static navigationOptions = {
title: "Another title that's kind of long",
};
render() {
const { navigation } = this.props;
const { pop } = navigation;
return (
pop()} title="Pop" />
navigation.goBack(null)} title="Go back" />
);
}
}
class ScreenWithNoHeader extends React.Component {
static navigationOptions = {
header: null,
title: 'No Header',
};
render() {
const { navigation } = this.props;
const { push, pop } = navigation;
return (
push('Other')} title="Push another screen" />
pop()} title="Pop" />
navigation.goBack(null)} title="Go back" />
);
}
}
const StackWithHeaderPreset = createStackNavigator(
{
Home: HomeScreen,
Other: OtherScreen,
ScreenWithNoHeader: ScreenWithNoHeader,
ScreenWithLongTitle: ScreenWithLongTitle,
},
{
headerTransitionPreset: 'uikit',
}
);
export default StackWithHeaderPreset;