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

Allows translucent backgrounds to be applied to WebViews + adds props for disabling scrolling #767

Closed
wants to merge 5 commits into from

Conversation

lwansbrough
Copy link
Contributor

Enables overwriting of underlying colors for WebViews. Especially useful if you want to give your WebView a transparent background.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@lwansbrough
Copy link
Contributor Author

Signed the CLA.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 9, 2015
@nicklockwood
Copy link
Contributor

Why not just "backgroundColor"? Also, I feel like the "opaque" attribute is an implementation detail that we should hide. For example, we could set it automatically based on the opacity of the color specified.

@lwansbrough
Copy link
Contributor Author

I really have no preferences as to how it's implemented :P I just did it the way it makes sense to me. I used underlayColor so that it isn't confused with the backgroundColor style attribute.

@nicklockwood
Copy link
Contributor

I'm a little unclear about why backgroundColor is distinct from underlayColor? Why would you ever want them to be different?

@lwansbrough
Copy link
Contributor Author

@nicklockwood Yeah I regret changing that. I see now also that backgroundColor is probably already manipulated through the React style prop, so adding backgroundColor (and especially (!) underlayColor under a different name than the actual property it's editing) is completely redundant.

I agree with your initial comment: hiding the opaque property behind the backgroundColor setter is best. Just check if the color has opacity and if it does, set opaque = false.

- Enable/disable scrolling through `allowScroll`
- Enable/disable scroll bouncing through `allowBounce`
- Automatically adjust WebView's opacity based on backgroundColor
- Default WebView backgroundColor to white to account for the opacity changes
@lwansbrough lwansbrough changed the title Adds opaque and underlayColor to WebView. Allows translucent backgrounds to be applied to WebViews + adds props for disabling scrolling Apr 11, 2015
@lwansbrough
Copy link
Contributor Author

Changes discussed above have been made. Also added props for disabling scrolling and/or scroll bounce.

@@ -213,6 +217,8 @@ var RCTWebView = createReactIOSNativeComponentClass({
validAttributes: merge(ReactIOSViewAttributes.UIView, {
url: true,
html: true,
allowBounce: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the same name as <ScrollView> component? I think it's just bounces and scrollEnabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

@vjeux
Copy link
Contributor

vjeux commented Apr 12, 2015

Looks good to me after the change, thanks for using backgroundColor, it's much more logical that way

@sahrens sahrens closed this in 765779a Apr 24, 2015
@lwansbrough lwansbrough deleted the webview-improvements branch July 27, 2015 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants