Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions playground/src/screens/WelcomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,59 @@ class WelcomeScreen extends Component {
<Button title='Orientation' testID={testIDs.ORIENTATION_BUTTON} onPress={this.onClickPushOrientationMenuScreen} />
<Button title='Provided Id' testID={testIDs.PROVIDED_ID} onPress={this.onClickProvidedId} />
<Button title='Complex Layout' testID={testIDs.COMPLEX_LAYOUT_BUTTON} onPress={this.onClickComplexLayout} />
<Button title='Push screen after async action' onPress={this.onClickSwitchToStack} />
<Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
</View>
<View style={{ width: 2, height: 2, borderRadius: 1, backgroundColor: 'red', alignSelf: 'center' }} />
</View>
);
}

onClickSwitchToStack = () => {
Navigation.setRoot({
root: {
stack: {
id: 'MyStack',
children: [
{
component: {
name: 'navigation.playground.ProfileScreen',
passProps: {
text: 'This is Profile',
myFunction: () => 'Hello from a function!'
},
}
},
{
component: {
name: 'navigation.playground.LoginScreen',
passProps: {
text: 'This is Login',
myFunction: () => 'Hello from a function!'
},
}
}
],
options: {
topBar: {
visible: false,
}
}
},
}
})

// lets pretend this is async action dispatched from store
// basically user logs in > dispatch an action > change screen to Profile
setTimeout(() => {
Navigation.push('MyStack', {
component: {
name: 'navigation.playground.ProfileScreen'
}
})
}, 3000)
}

onClickSwitchToTabs = () => {
Navigation.setRoot({
root: {
Expand Down
3 changes: 3 additions & 0 deletions playground/src/screens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function registerScreens() {
Navigation.registerComponent('CustomTextButton', () => CustomTextButton);
Navigation.registerComponent('CustomRoundedButton', () => CustomRoundedButton);
Navigation.registerComponent('TopBarBackground', () => TopBarBackground);

Navigation.registerComponent('navigation.playground.LoginScreen', () => TextScreen)
Navigation.registerComponent('navigation.playground.ProfileScreen', () => TextScreen)
}

module.exports = {
Expand Down