Coder Social home page Coder Social logo

brentvatne / react-native-overlay Goto Github PK

View Code? Open in Web Editor NEW
639.0 13.0 79.0 1.63 MB

An <Overlay /> component that brings content inside to the front of the view regardless of its current position in the component tree.

Objective-C 70.68% JavaScript 22.34% Ruby 6.98%

react-native-overlay's Introduction

react-native-overlay

An <Overlay /> component that brings content inside to the front of the view regardless of its current position in the component tree. This was extracted from react-native-modal because a modal is not the only time that you want to bring something to the front of the screen.

Should you use this?

Ideally, no. This should probably only be used as a last resort. You can usually accomplish what you need to by just absolute positioning an view at the bottom of your root component.

In fact, as of 0.29.0 zIndex is supported on iOS and Android, so you should probably never use this.

Add it to your project

  1. Run npm install react-native-overlay --save
  2. Open your project in XCode, right click on Libraries and click Add Files to "Your Project Name" (Screenshot) then (Screenshot).
  3. Add libRNOverlay.a to Build Phases -> Link Binary With Libraries (Screenshot).
  4. Whenever you want to use it within React code now you can: var Overlay = require('react-native-overlay');

Example - Loading Overlay

This shows how you might implement a loading overlay and uses react-native-blur to blur the background. Notice that all we need to do is wrap the content that we want to bring to the front in an Overlay element!

var React = require('react-native');
var Overlay = require('react-native-overlay');
var BlurView = require('react-native-blur').BlurView;

var {
  View,
  ActivityIndicatorIOS,
  StyleSheet,
} = React;

var LoadingOverlay = React.createClass({
  getDefaultProps(): StateObject {
    return {
      isVisible: false
    }
  },

  render(): ReactElement {
    return (
      <Overlay isVisible={this.props.isVisible}>
        <BlurView style={styles.background} blurType="dark">
          <ActivityIndicatorIOS
            size="large"
            animating={true}
            style={styles.spinner} />
        </BlurView>
      </Overlay>
    );
  }
});

var styles = StyleSheet.create({
  background: {
    flex: 1,
    justifyContent: 'center',
  },
})

module.exports = LoadingOverlay;

Elsewhere in our app, we can render this:

var LoadingOverlayExampleApp = React.createClass({
  render: function() {
    return (
      <View style={styles.container}>
        <Image source={require('image!announcement')} style={styles.image} />

        { /* It doesn't matter where we put this component, it can be nested */ }
        { /* anywhere within your component tree */ }
        <LoadingOverlay isVisible={true} />
      </View>
    );
  }
});

This would produce something like this:

Example code result

You can try this code yourself by cloning this repo and running Examples/LoadingOverlay.

Example - Toast

There are so many other types of overlays but I thought I'd give another simple example to stir your imagination.

Example code result

Check it out in Examples/Toast.

react-native-overlay's People

Contributors

adrienbrault avatar alejomendoza avatar almost avatar brentvatne avatar gmethvin avatar jdeppen avatar joecritch avatar johanneslumpe avatar keeth avatar niftylettuce avatar xiaoyann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-overlay's Issues

Height does not get updated with aboveStatusBar={true}

For some reason the overlay is exactly 64px too small. If I manually set bottom: -64px in Overlay.ios.js, the overlay fills the screen, but otherwise it is not large enough. I checked the height of the UIView and it seemed to be correct -- so I suppose the error is somewhere in the JS. Maybe the view gets laid out before the UIView has the full height?

Move objects to overlay without re-rendering

Hiya!

I'm trying to animate a MapView so that when it's pressed, it goes from being an element in a ScrollView to the map covering the entire screen (including navigation and status bars).

I've got it sort of working by:

  1. measuring the map position with UIManager.measure
  2. activating the overlay and rendering the same map but now inside an overlay
  3. positioning the map relative to the overlay based on measurement
  4. animating the map size to cover the entire screen

The problem is that when going to/from overlay, the entire map reloads which effectively kills the magic of the animation.

From what I understand, since I move the MapView pretty far in the VDOM tree, React kills it and inits a new one. I've tried to avoid this by initialising the element in a wrapper component and then passing it as a prop. So that the prop itself will not be changed, just where it is placed in the tree. Unfortunately this doesn't help.. It is still being re-instantiated.

I also tried wrapping the MapView in another component and having shouldComponentUpdate always returning false. Doesn't help either..

What's going on here? Is there someway I can retain a reference to the MapView component and tell React that it shouldn't re-initialize it just because it got moved in the tree?

PS. I'm totally in love with react-naive!! Ds.

zIndex is not always working as a replacement of the react-native-overlay component

The readme says:

In fact, as of 0.29.0 zIndex is supported on iOS and Android, 
so you should probably never use this.

I had to make a kind of dropdown list for Android and iOS and zIndex doesn't help that much in the case of making something appear above everything else. Let me explain.

Web
If you are familiar with the web, then you know what a dropdown is. The list appearing on focus needs to be positioned (absolute, relative, etc) and at a zIndex higher than the components it should be above to. It just works, right.

Well... kind of. It works as long as you stay in the current stack / tree. For a complete example see: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_context_example_3

This means that in order to really use the zIndex property to put something above everything else, it needs to be rendered at the bottom. And that's what js libs do (for example: dropdown, modal components).

React Native
As said in the readme, in theory, in React Native it is possible to use the zIndex since version 0.29 (for iOS and 0.30 for Android) as it introduced the possibility to use this style property.

But the RN implementation strictly follows the spec of the web version of zIndex.

So, this means that a given zIndex only affects the _current tree_.

This is, same on the web, quite a problem when you want a nested component to display above everything else. Like in my case a dropdown list.

Other options
As the readme says, I thought about adding a "DropdownOptions" component at the bottom of the app tree and pass it down as a ref to the real "Dropdown" component which is inside a form.
But it does not feel right and is hardly testable IMO.

I also thought about making all the siblings component to be at a zIndex lower than my component's parent.

But I feel that these solutions are just more pain and not as scalable as using the react-native-overlay component.

Overlay Size

This is a quick question, but is it possible to change the size of the overlay layer? I'm trying to overlay a pin on a map (like uber or lyft) but the overlay covers the whole MapView which prevents map movement. Is there are way to make the overlay the size of the View I'm centering on the map?

Working with `Animated`

A perfect use for overlay is to slide it down from the top of the screen as a in-app notification. However, Overlay currently doesn't work with Animated from React Native. This feature would be really useful.

Overlay brings View to the top, but the viewPosition changes to top-left (absolute?)

I have a nested component within an ImageView for correct alignment. But then I wanted to animate it outside the image (and above the other components).

So i wrapped the component within an Overlay.

But now the starting position is completely wrong (top-left). Is this the intended behaviour? Because if i have to adjust the position absolute anyways, i could simple put the view on the bottom of my renderView without the need of the Overlay component?

greetings

Overlay not covering TabBar

Wondering whether Overlay layers should be able to cover TabBar's. In my use case, I am setting up an Overlay within a scene that is 2 "stacks" deep from the Navigator (e.g. the 2nd scene that has been navigator.push()).

Couldn't run

In project it was displaying under views.

Examples in repo couldn't run.
Xcode error: RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation

Add support for partial overlay?

I noticed it covers the entire screen because of the absolute positioning. So for example, in the Toast example, you wouldn't be able to interact with anything else other than the Toast (right?).

Are you able to perhaps add options to set top, left, right, bottom? That way we can expose some touchables underneath the overlay?

Last, thanks for this project.

Improve LoadingOverlay Example

  • styles.spinner is used but never defined
  • Currently the spinner is centered vertically but not horizontally. I think you want:
  background: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },

Error running Examples with Xcode 7

Hi @brentvatne. Love the project!

Looks like some of the examples are giving the redbox error when run from Xcode 7:

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Based on my upgrade research here's a fix for those looking:

Add to Info.plist the following entry:

  <key>NSAppTransportSecurity</key>
  <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
  </dict>

Push a new version

Hi guys,

I saw you pushed a fix for support of the new versions of React Native but... on master.
And not on npm.

Is there a particular reason for that?

Does this project have the equivalent of a bringToFront?

Since React Native doesn't support zIndex, I'm looking for a way to bring an element to the front of the rendering. Looks like this project sorta might have the ability to do that, but I don't see something that makes that clear.

Does this codebase have the ability to bring a view to the front of the rendering?

requireNativeComponent is not a function

Hi I am getting the following error

screen shot 2015-11-06 at 16 14 51

It seems to be that the "requireNativeComponent" call is not working. I am using ReactNative 0.11.0 and iOS 9. Any ideas on howto resolve this?

Process supplied styles

Could you process user-supplied optional styles in stead of forcing the use of your local style? This would allows us to customize it more easily

"RNOverlay" does not exist

My project is working and the overlay works fine too, but the console keeps showing that error in console any one experiencing this same error?

Warning: Native component for "RNOverlay" does not exist

It doesn't show children elements

Hello.
I have written this test code:

        <Overlay isVisible={this.state.visible}>
            <View style={style.background}>
                <ActivityIndicator
                color='white'
                size="large"
                style={style.centering}
                animating={true} />
                <Text style={{color: 'white', fontSize: 48}}>Hello, hello, hello!</Text>
            </View>
        </Overlay>

But it doesn't show children elements: View, ActivityIndicator, Text. Only the Overlay. Why?
React Native version is "0.35.0".

Loading Overlay styles seem to not be included

Hey team,

I'm trying to use the LoadingOverlay, essentially exactly as it is in your examples. Here's what I see on my emulator:

And here is the related code:
The component

Where I'm using the component

Am I wrong to assume the styles should look like the example? And if it is, what am I missing here?

overlayed component in parent component

I'm trying to create an (open-source) slider button which has an animated text layed over a slider. However, when trying to overlay the Text component over the slider the Text is put on top of the screen into the status bar, as illustrated by the following screenshot (the green arrow indicates where i want the label to be).

overlay

Thus I suppose that the component is put on top of the view. That's why I want to know if there is any possibility of keeping the component wrapped by the Overlay in it's parent view instead of putting it on top of the view. As expected, the property aboveStatusBar={false} has not solved this issue.

Below you can see my JSX.

<View style={styles.container}>
    <Overlay isVisible={true} aboveStatusBar={false}>
        <Animated.Text
            style={[styles.text, styles.textAlignment,
            {
                opacity: this.state.textAlphaValue 
            }
        ]}>
            {this.props.text}
        </Animated.Text>
    </Overlay>

    <SliderIOS key={this.state.timestamp}
        style={[styles.slider, styles.sliderBorder]}
        onSlidingComplete={(newValue) => this.onSliderValueChanged(newValue)}
        {...this.props}>
    </SliderIOS>
</View>

Overlay child height is based on owner, not overlay

Layout

Phone height: 480
First block height: 100
Second block height: 380

+-----------------------------------------------+
|          height: 100                          |
|-----------------------------------------------|
|                                               |
|             flex: 1                           |
+-----------------------------------------------+

JSX

<View style={styles.container}>
    <View></View>
    <View>
        <LoadingOverlay />
    </View>
</View>

Expected

LoadingOverlay height = 480

Actual

LoadingOverlay height = 380 (same as owner view)

Example: https://rnplay.org/apps/_j9F_A/edit

Library for Android?

I have a warning when running on Android. It could not find the RNOverlay library file.
I think this is the reason why panResponder doesn't work with the components I nested in Overlay on Android.

Can you give me some info about this? Thanks

Android support?

I needed this to implement autocomplete popover (as in picture below). With <Modal> I can't do it, because we can't "click-through" a modal, there is no pointerEvents option. Is there any plans to continue supporting this awesome module? Esepcially any palns for Android support? Any alts you may know of?

Thanks so much!

'Cannot Find Protocol'

Hey Brent - been trying to implement the overlay, but I seem to be getting some errors linking it into my project. I've run through steps 1-4 as outlined in the documentation.

screen shot 2015-08-24 at 12 46 45 pm

Any advice would be greatly appreciated. Peace, and appreciate all the work you do.

Overlay and actionsheets?

Hi! First of all, I love this component. Thanks a lot for creating it!

I was wondering if there is a way to make this work with ActionSheets. I noticed that actionsheets are displayed under the overlay which I am not sure if it's wanted or a oversight

Missing License

Would it be possible for you to add a license to the project?

Trouble installing

I followed the instructions, but I get an error saying that it cannot find the module. Other modules I installed via npm are okay. I did restart the packager of course.

Is this module working with the latest react native tools?

image

Breaking in RN 0.26+: Separate React from React Native

Console warnings coming from Overlay_render in RN 0.25 (breaking errors in RN 0.26+):

2016-06-06 12:38:32.783 index.ios.bundle:14030Warning: ReactNative.createElement is deprecated. Use React.createElement from the "react" package instead.reactConsoleError @ index.ios.bundle:14030console.error @ index.ios.bundle:59059warning @ index.ios.bundle:5273get @ index.ios.bundle:35430Overlay_render @ index.ios.bundle:71367_renderValidatedComponentWithoutOwnerOrContext @ index.ios.bundle:19094_renderValidatedComponent @ index.ios.bundle:19114ReactCompositeComponent__renderValidatedComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:18727ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponentIntoNode @ index.ios.bundle:17074perform @ index.ios.bundle:18278batchedMountComponentIntoNode @ index.ios.bundle:17093perform @ index.ios.bundle:18278batchedUpdates @ index.ios.bundle:26203batchedUpdates @ index.ios.bundle:17918renderComponent @ index.ios.bundle:17179ReactMount__renderNewRootComponent @ index.ios.bundle:7416render @ index.ios.bundle:12911renderApplication @ index.ios.bundle:57999run @ index.ios.bundle:57868runApplication @ index.ios.bundle:57896__callFunction @ index.ios.bundle:6932(anonymous function) @ index.ios.bundle:6836guard @ index.ios.bundle:6790callFunctionReturnFlushedQueue @ index.ios.bundle:6835onmessage @ debuggerWorker.js:39
2016-06-06 12:38:32.793 index.ios.bundle:14030Warning: ReactNative.Children is deprecated. Use React.Children from the "react" package instead.reactConsoleError @ index.ios.bundle:14030console.error @ index.ios.bundle:59059warning @ index.ios.bundle:5273get @ index.ios.bundle:35430Overlay_render @ index.ios.bundle:71368_renderValidatedComponentWithoutOwnerOrContext @ index.ios.bundle:19094_renderValidatedComponent @ index.ios.bundle:19114ReactCompositeComponent__renderValidatedComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:18727ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponentIntoNode @ index.ios.bundle:17074perform @ index.ios.bundle:18278batchedMountComponentIntoNode @ index.ios.bundle:17093perform @ index.ios.bundle:18278batchedUpdates @ index.ios.bundle:26203batchedUpdates @ index.ios.bundle:17918renderComponent @ index.ios.bundle:17179ReactMount__renderNewRootComponent @ index.ios.bundle:7416render @ index.ios.bundle:12911renderApplication @ index.ios.bundle:57999run @ index.ios.bundle:57868runApplication @ index.ios.bundle:57896__callFunction @ index.ios.bundle:6932(anonymous function) @ index.ios.bundle:6836guard @ index.ios.bundle:6790callFunctionReturnFlushedQueue @ index.ios.bundle:6835onmessage @ debuggerWorker.js:39
2016-06-06 12:38:32.795 index.ios.bundle:14030Warning: ReactNative.cloneElement is deprecated. Use React.cloneElement from the "react" package instead.reactConsoleError @ index.ios.bundle:14030console.error @ index.ios.bundle:59059warning @ index.ios.bundle:5273get @ index.ios.bundle:35430Overlay_render @ index.ios.bundle:71368_renderValidatedComponentWithoutOwnerOrContext @ index.ios.bundle:19094_renderValidatedComponent @ index.ios.bundle:19114ReactCompositeComponent__renderValidatedComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:18727ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountChildren @ index.ios.bundle:31395initializeChildren @ index.ios.bundle:30992mountComponent @ index.ios.bundle:31129mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponent @ index.ios.bundle:18732ReactCompositeComponent_mountComponent @ index.ios.bundle:7416mountComponent @ index.ios.bundle:17324mountComponentIntoNode @ index.ios.bundle:17074perform @ index.ios.bundle:18278batchedMountComponentIntoNode @ index.ios.bundle:17093perform @ index.ios.bundle:18278batchedUpdates @ index.ios.bundle:26203batchedUpdates @ index.ios.bundle:17918renderComponent @ index.ios.bundle:17179ReactMount__renderNewRootComponent @ index.ios.bundle:7416render @ index.ios.bundle:12911renderApplication @ index.ios.bundle:57999run @ index.ios.bundle:57868runApplication @ index.ios.bundle:57896__callFunction @ index.ios.bundle:6932(anonymous function) @ index.ios.bundle:6836guard @ index.ios.bundle:6790callFunctionReturnFlushedQueue @ index.ios.bundle:6835onmessage @ debuggerWorker.js:39
2016-06-06 12:39:28.909 ExceptionsManager.js:76Warning: ReactNative.PropTypes is deprecated. Use React.PropTypes from the "react" package instead.reactConsoleError @ ExceptionsManager.js:76warning @ warning.js:44get @ ReactNative.js:41(anonymous function) @ Overlay.ios.js:14requireImpl @ require.js:82_require @ require.js:31(anonymous function) @ index.ios.js:29requireImpl @ require.js:82requireImpl @ require.js:39_require @ require.js:31(anonymous function) @ require-0.js:1executeApplicationScript @ debuggerWorker.js:18onmessage @ debuggerWorker.js:33
2016-06-06 12:39:28.916 ExceptionsManager.js:76Warning: ReactNative.createClass is deprecated. Use React.createClass from the "react" package instead.reactConsoleError @ ExceptionsManager.js:76warning @ warning.js:44get @ ReactNative.js:41(anonymous function) @ Overlay.ios.js:20requireImpl @ require.js:82_require @ require.js:31(anonymous function) @ index.ios.js:29requireImpl @ require.js:82requireImpl @ require.js:39_require @ require.js:31(anonymous function) @ require-0.js:1executeApplicationScript @ debuggerWorker.js:18onmessage @ debuggerWorker.js:33

See React API deprecation note: https://github.com/facebook/react-native/releases/tag/v0.25.1

Question about performance

I am interested in why you said, you really shouldn't use this and to choose 'absolute' positioning instead. Absolute positioning doesn't always solve the problem that this would. Are there performance issues with using this ?

Send data to main view

Hi,
how could I send data to main view and close overlay? In overlay I had function that get from API array, with I would like to send to main view. Thanks

Overlay Style Overrides in-code Style, Misaligning Components in View

I noticed that when using overlay, it seems to have a mind of its own when it comes to component positioning on the window. I'm not sure which part of the overlay component is doing this, but I can provide an example of what it does to my components:

Here is my component code without the overlay component:

module.exports = React.createClass({
  //onPress function that triggers when button pressed
  //this.props.text is property that can be dynamically filled within button 
  render: function() {
    return (
      <TouchableHighlight 
        underlayColor={'transparent'}
        onPress={this.props.onPress} >
          <Image source={this.props.source} resizeMode={this.props.resize} style={[styles.articlePreview, this.border('red')]}>
                  <View style={[styles.container, this.border('organge')]}>
                      <View style={[styles.header, this.border('blue')]}>
                          <Text style={[styles.previewText]}>{this.props.text}</Text>
                      </View>
                      <View style={[styles.footer, this.border('white')]}>
                          <ImageButton
                              style={[styles.heartBtn, , this.border('red')]}
                              resizeMode={'contain'}
                              onPress={this.onHeartPress}
                              source={require('../../img/heart_btn.png')} />
                          <KeywordBox 
                              style={[styles.category, this.border('blue')]}
                              key={this.props.key} 
                              text={this.props.category} 
                              onPress={this.props.categoryPress}
                              selected={this.props.selected} />
                      </View>
                  </View>
          </Image>
      </TouchableHighlight>
    );
  }, 

And here is what that gives us:

screen shot 2015-12-11 at 1 32 55 am

With Overlay, however, with this code:

module.exports = React.createClass({
  //onPress function that triggers when button pressed
  //this.props.text is property that can be dynamically filled within button 
  render: function() {
    return (
      <TouchableHighlight 
        underlayColor={'transparent'}
        onPress={this.props.onPress} >
          <Image source={this.props.source} resizeMode={this.props.resize} style={[styles.articlePreview, this.border('red')]}>
                <Overlay isVisible={true}>
                  <View style={[styles.container, this.border('organge')]}>
                      <View style={[styles.header, this.border('blue')]}>
                          <Text style={[styles.previewText]}>{this.props.text}</Text>
                      </View>
                      <View style={[styles.footer, this.border('white')]}>
                          <ImageButton
                              style={[styles.heartBtn, , this.border('red')]}
                              resizeMode={'contain'}
                              onPress={this.onHeartPress}
                              source={require('../../img/heart_btn.png')} />
                          <KeywordBox 
                              style={[styles.category, this.border('blue')]}
                              key={this.props.key} 
                              text={this.props.category} 
                              onPress={this.props.categoryPress}
                              selected={this.props.selected} />
                      </View>
                  </View>
                </Overlay>
          </Image>
      </TouchableHighlight>
    );
  }, 

We get this:
screen shot 2015-12-11 at 1 37 25 am

I'm not sure what's going on but the issue has been targeted to the Overlay component - much appreciate any insight!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.