GithubHelp home page GithubHelp logo

paulxuca / react-native-home-indicator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flowkey/react-native-home-indicator

0.0 2.0 0.0 431 KB

A <PrefersHomeIndicatorAutoHidden /> component for react-native

License: MIT License

JavaScript 65.08% Objective-C 25.73% Ruby 9.19%

react-native-home-indicator's Introduction

npm version CircleCI codecov

A declarative approach for hiding the iPhone X Home Indicator in react-native.

Getting Started

1. Add dependency

npm install react-native-home-indicator --save

2. Link library

If you're using RN >= 0.60.0 just go run pod install inside the ios-directory. To install in projects using RN < 0.60.0 follow the manual linking steps

3. Add Header to Search Path

Because you need to call react-native-home-indicator from native, ensure that you add $(SRCROOT)/../node_modules/react-native-home-indicator/ios to your Header Search Paths as described here

4. Changes in Appdelegate.m

// add to your imports
#import <RNHomeIndicator.h>
// find this line
UIViewController *rootViewController = [UIViewController new];
// and replace with
UIViewController *rootViewController = [HomeIndicatorViewController new];

Simple Usage

Render <PrefersHomeIndicatorAutoHidden /> to signal your preference for hiding the Home Indicator. "The system takes your preference into account, but returning true is no guarantee that the indicator will be hidden." see developer.apple.com/documentation

...
import PrefersHomeIndicatorAutoHidden from 'react-native-home-indicator';

const SomeReactNativeComponent = () => {
    return (
        <View>
            <PrefersHomeIndicatorAutoHidden />
            ...
        </View>
    );
}

Extended Usage

For more complex usage you can use the HomeIndicator component which allows passing your preferred indicator setting as prop. Its even possible to override previous rendered indicator preferences as you can see in the following example.

...
import { HomeIndicator } from 'react-native-home-indicator';

const SomeReactNativeComponent = () => {
    return (
        <View>
            <HomeIndicator autoHidden />
            <SomeDeepComponentTree>
                 <HomeIndicator autoHidden={false} />
            </SomeDeepComponentTree>
        </View>
    );
}

react-native-home-indicator's People

Contributors

coryjb avatar dependabot[bot] avatar michaelknoch avatar paulxuca avatar

Watchers

 avatar  avatar

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.