Skip to content
This repository was archived by the owner on Jun 16, 2023. It is now read-only.

Create Camera Singleton #2230

@ehorodyski

Description

@ehorodyski

Question

To Do First

  • Take a look in the README
  • Take a look in the docs
  • Take a look in the QA

Ask your Question
I'm working on an app that uses react-navigation (createBottomTabNavigator) to toggle between the following views:

  1. Help
  2. Take Picture (or navigate to camera if on other screens)
  3. About

layout

The routing is as follows, the camera icon inside <BottomNavComponent /> either navigates the user to <CameraScreen /> if there are not there, or should take a picture if the user is there.

However, I am unable how to figure out how the pass a reference to the camera from <CameraScreen />, which has a render method that uses <RNCamera />, up to <BottomNavComponent />.

Below are some relevant pieces of code:

CameraScreen.js

class CameraScreen extends Component {

  render() {
    return (
      <View style={CameraScreenStyles.ViewContainer}>
        <RNCamera
          style={CameraScreenStyles.Preview}
          ref={(ref) => { this.camera = ref; }}
          captureAudio={false}
          type={RNCamera.Constants.Type.back}
          flashMode={RNCamera.Constants.FlashMode.auto}
        />
      </View>
    );
  }

}

BottomNavComponent

export default BottomTabNavigator = createBottomTabNavigator(
  {
    ...
    Home: {
      screen: CameraScreen,
      navigationOptions: () => ({
        tabBarIcon: () => <CircleNavButton />
      })
    },
    ...
  }, {
    initialRouteName: 'Home',
    ...
}

CircleNavButton is the component that renders the circle.

App.js

const AppContainer = createAppContainer(BottomTabNavigator);
export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <AppContainer />
      </Provider>
    );
  }
}

You can find my project here. I believe it's currently public, please let me know if it's not.

Thanks for helping!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions