Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with react-navigation and width of the alert #15

Open
marceloHashzen opened this issue Oct 10, 2017 · 5 comments
Open

Problem with react-navigation and width of the alert #15

marceloHashzen opened this issue Oct 10, 2017 · 5 comments

Comments

@marceloHashzen
Copy link

marceloHashzen commented Oct 10, 2017

Hi, is there any tip to use this alert with the returned navigator from react-navigation, so it appears on all screens? Or is it possible to manually set the width of the alert (if I try to insert the alert inside a view in the returned component, the width is just the width of the text inside the alert)?

Some screenshots:

In this situation I'm putting the alert inside de Login screen, so I would have to put inside every other screen, but the width is delimited by the text width:

android1
ios1

In this situation, I'm putting the alert with the navigation that is returned, but in android all the screen got blank and on iOS everything is squished in the top:

android2
ios2

@gnestor
Copy link
Owner

gnestor commented Oct 11, 2017

Hi @marceloHashzen! If you put StatusBarAlert inside of a top-level View with flex: 1, it should render with full width. Additionally, putting your login content inside of a container View with flex: 1 should resolve what you're seeing in the last screenshot.

I just added an example app directory to this repo. Check that out for reference. Let me know if you continue to have issues.

@marceloHashzen
Copy link
Author

Hello @gnestor, thank you very much for the help. I've used the second situation (StatusBar outside the navigation screen), with the container View with flex: 1, it's working wonderfully.
Just another doubt, is there any other better way than setting the statusbarHeight={25}, so the message will not hidden by the android top header?

@gnestor
Copy link
Owner

gnestor commented Oct 13, 2017

I haven't used this component with Android, but the purpose of statusbarHeight is to offset the alert's top position by the statusbarHeight value.

@gnestor
Copy link
Owner

gnestor commented Oct 16, 2017

@marceloHashzen Check out the ReactNativeStatusBarAlertExample directory for an example implementation with react-navigation 👍 To summarize:

<View style={styles.container}>
	<StatusBar />
	<StatusBarAlert
		visible={this.state.alert}
		message="Alert!"
		backgroundColor="#3CC29E"
		color="white"
		style={styles.alert}
		onPress={this.toggleAlert}
	>
		{this.state.customAlert}
	</StatusBarAlert>
	<MyStackNavigation />
</View>

@marceloHashzen
Copy link
Author

Awesome @gnestor! Will try by the end of the week, but the alert is already working here on iOS and Android!
Thank you very much for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants