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

isTranslucent method #12

Closed
Noitidart opened this issue Dec 8, 2017 · 4 comments
Closed

isTranslucent method #12

Noitidart opened this issue Dec 8, 2017 · 4 comments

Comments

@Noitidart
Copy link

May I please reuqest a isTranslucent method? Because i needed to detect if status bar is going to overlap or not. And there is a bug in RN implemtnation that is not being fixed:

facebook/react-native#16432 (comment)

import { StatusBar } from 'react-native'

console.log('StatusBar.translucent:', StatusBar.translucent); // should be false - is undefined
StatusBar.setTranslucent(true);
console.log('StatusBar.translucent:', StatusBar.translucent); // should be true - is undefined
@jazmon
Copy link
Owner

jazmon commented Dec 9, 2017

'isTranslucent' method or a variable for StatusBar isn't what this library is for. Really sucks that it doesn't work for you currently in the base React Native library, but that's where it should be fixed.


I didn't get the same impression as you might have gotten from the issue you just posted that they wouldn't fix it. Here's the code for StatusBar in RN it seems like it should work to me. I think you are understanding wrong how it works. You are setting the translucent prop to the StatusBar, thus "overriding" the behavior. It's up to you to store the isTranslucent-boolean somewhere, like in the component's state or some state management library of your choice.

Minimal example:

import { StatusBar, View } from 'react-native';
import React from 'react';

class MyApp extends React.Component {
  constructor(props) {
    this.state = {
      translucentStatusBar: true,
    }
  }

  render() {
    return (
      <View>
        <StatusBar translucent={this.state.translucentStatusBar} />
      </View>
    );
  }
}

@Noitidart
Copy link
Author

Oh thanks @jazmon so it always starts up in non-translucent mode huh? And then whenever I change it I can just keep track?

Really appreciate the help here!

@jazmon
Copy link
Owner

jazmon commented Dec 9, 2017

By default it's not translucent, unless you give it the prop to tell it to be transulcent

@Noitidart
Copy link
Author

Thanks very much!

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

No branches or pull requests

2 participants