react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Open source BlurView

Open ide opened this issue 11 years ago • 6 comments

ide avatar Feb 25 '15 00:02 ide

Just curious, is this a wrapper for UIVisualEffectView with a UIBlurEffect?

jordanna avatar Feb 25 '15 08:02 jordanna

@jordanna - yeah, I imagine so. The nuanced part is that when you add React children, the subviews need to be added to the UIVisualEffectView's contentView. I don't think the current BlurView was necessarily built with vibrancy effects in mind but my current thinking is that it's desirable to write:

<BlurView blurStyle={BlurView.DarkStyle}>
  <Text>Title</Text>
  <VibrancyView>
    <Image source={ix('Icon')} />
  </VibrancyView>
</BlurView>

The native blur view can automatically pass its blur effect to the native vibrancy view (also implemented with a UIVisualEffectView) that needs the blur effect to create its vibrancy effect. Another thing that may make sense to do -- although iOS may do this automatically now -- is to set the nested image to render as a template or otherwise the image won't take on the vibrancy effect.

I actually have a project that demonstrates the available effects (https://github.com/ide/UIVisualEffects). The native APIs aren't all that intuitive and used to require a bit of fiddling to get right so I think it's a helpful reference if you're interested in learning how to produce these effects.

ide avatar Feb 25 '15 09:02 ide

James: If you're referring to the existing BlurView we have internally, it's iOS7 compatible and just uses a UIToolbar (so is pretty lame in comparison) - we'll need to build something from scratch for the stuff you want. Want to build it?

sahrens avatar Feb 25 '15 16:02 sahrens

Caveat implementor; use UIToolbar as a fallback when UIVisualEffectView isn't available.

a2 avatar Feb 25 '15 16:02 a2

You guys are right about iOS 7 support. UIToolbar should handle the common case for creating blurry overlays but there is no simple way to get the vibrancy effect. Here's a strawman proposal w.r.t. iOS 7:

  • Support <BlurView> on iOS 7+, using UIVisualEffectView if possible and UIToolbar otherwise
  • Support light and dark blur styles on iOS 7+ since UIToolbars can be dark or light
  • Support the extra light blur style only on iOS 8. Fall back to the light style and print a warning and maybe red box in dev on iOS 7.
  • Support <VibrancyView> on iOS 8+ and don't define it at all on iOS 7 (module.exports = undefined)

I probably won't be able to get to building this in the next couple of weeks so you may want to open source the existing BlurView for navigation bars. If someone else is interested in building this in the meantime I can help with code reviews.

ide avatar Feb 25 '15 19:02 ide

@Kureev implementated blur view: https://github.com/Kureev/react-native-blur

vjeux avatar May 29 '15 22:05 vjeux