All Projects → greenfrvr → react-native-window-guard

greenfrvr / react-native-window-guard

Licence: MIT license
SafeAreaView alternative for React Native which provides relevant window insets for both iOS and Android.

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
objective c
16641 projects - #2 most used programming language
swift
15916 projects
python
139335 projects - #7 most used programming language
ruby
36898 projects - #4 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to react-native-window-guard

React Native Beautiful Video Recorder
The video recorder component that extends from react-native-camera. It works for both iOS & Android.
Stars: ✭ 204 (+580%)
Mutual labels:  react-native-component
react-native-vector-image
iOS/Android native vector assets generated from SVG
Stars: ✭ 224 (+646.67%)
Mutual labels:  react-native-component
react-native-chat-ui
Actively maintained, community-driven chat UI implementation with an optional Firebase BaaS.
Stars: ✭ 168 (+460%)
Mutual labels:  react-native-component
React Native Dynamic Search Bar
Medium Article: https://freakycoder.com/react-native-library-dynamic-search-bar-c03fea9fae36
Stars: ✭ 225 (+650%)
Mutual labels:  react-native-component
react-native-component-splitter
VS Code Extension allows splitting React Native Component into Sub-Component
Stars: ✭ 33 (+10%)
Mutual labels:  react-native-component
react-native-multi-selectbox
Platform independent (Android / iOS) Selectbox | Picker | Multi-select | Multi-picker. The idea is to bring out the common user interface & user experience on both platforms.
Stars: ✭ 169 (+463.33%)
Mutual labels:  react-native-component
React Native Photos Framework
A modern and comprehensive CameraRoll/iCloud-library-API for React Native 📸 📹
Stars: ✭ 190 (+533.33%)
Mutual labels:  react-native-component
react-native-uiw
A UI component library based on React Native (Android & iOS).
Stars: ✭ 28 (-6.67%)
Mutual labels:  react-native-component
react-native-android-notification-listener
React Native Android Notification Listener - Listen for status bar notifications from all applications
Stars: ✭ 87 (+190%)
Mutual labels:  react-native-component
react-native-select-pro
React Native dropdown (select) component developed by Mobile Reality
Stars: ✭ 79 (+163.33%)
Mutual labels:  react-native-component
React Native Hero
🤘 A super duper easy hero unit react-native component with support for dynamic image, dynamic sizing, color overlays, and more
Stars: ✭ 234 (+680%)
Mutual labels:  react-native-component
react-native-touchable
React-Native button helper library
Stars: ✭ 46 (+53.33%)
Mutual labels:  react-native-component
expo-ui-kit
expo-ui-kit - a components based React-Native UI Kit
Stars: ✭ 88 (+193.33%)
Mutual labels:  react-native-component
React Native Swipe List View
A React Native ListView component with rows that swipe open and closed
Stars: ✭ 2,524 (+8313.33%)
Mutual labels:  react-native-component
react-native-ios-modal
A react-native component for displaying a modal on iOS by natively wrapping a react-native view inside a UIViewController and presenting it.
Stars: ✭ 94 (+213.33%)
Mutual labels:  react-native-component
React Native Side Menu
Side menu component for React Native
Stars: ✭ 2,214 (+7280%)
Mutual labels:  react-native-component
AutoInsetter
📐 Easily provide custom view controller auto-insetting
Stars: ✭ 13 (-56.67%)
Mutual labels:  safearea
react-native-radio-buttons-group
Simple, best and easy to use radio buttons for react native apps.
Stars: ✭ 145 (+383.33%)
Mutual labels:  react-native-component
react-native-carousel-component
React Native Carousel Component for IOS & Android
Stars: ✭ 61 (+103.33%)
Mutual labels:  react-native-component
react-native-image-blur-shadow
A React Native Image component with Blur Drop Shadows,100% JavaScript, 0 dependency component. Supports Android, iOS and Web. A light weight <Image/> component for your react native project.
Stars: ✭ 80 (+166.67%)
Mutual labels:  react-native-component

react-native-window-guard

npm package license

Project represents simple way to handle notches and system ui decorations for React Native. In comparison to alternatives (e.g. SafeAreaView) it works on both iOS and Android and doesn't use hardcoded values, getting all insets with operating system APIs instead.

Android iOS

Getting started

$ npm install react-native-window-guard --save

Mostly automatic installation

$ react-native link react-native-window-guard

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-window-guard and add RNWindowGuard.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNWindowGuard.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.github.greenfrvr.RNWindowGuardPackage; to the imports at the top of the file
  • Add new RNWindowGuardPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-window-guard'
    project(':react-native-window-guard').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-window-guard/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-window-guard')
    

Usage

Put your layout inside WindowGuard component and define which insets you want to be applied. To make this use applyInsets prop. It takes array with sides which should be affected with insets. Available values: top, bottom, left, right. After this relevant window insets will be requested from native and applied as paddings to WindowGuard component.

For convenience and better perfomance there are serveral insets configurations that are predefined. They are defined statically in WindowGuard. Available predefined insets configurations are:

  • left
  • right
  • top
  • bottom
  • vertical
  • horizontal
  • all

Below is an example of applying insets both for top and bottom sides of your content:

import WindowGuard from 'react-native-window-guard';

export default class App extends React.Component {

  componentDidMount() {
    WindowGuard.requestWindowInsets();
  }

  render() {
    return (
      <WindowGuard
        style={{flex: 1}}
        applyInsets={WindowGuard.vertical}>
        //content
      </WindowGuard>
    );
  }
}

Notice that you can still add paddings to WindowGuard and they will be added to applied window insets. Currently all paddings definitions are supported includeing paddingHorizontal, paddingVertical and padding attributes.

Dynamic changes

Window guard will handle orientation changes and apply new relevant insets automatically for you. Unfortunately there are still cases where you need to handle some ui changes manually. For example hiding status bar. You can request window guard to refresh insets after configuation change by calling adjustInsets method. Below is small usage example:

import WindowGuard from 'react-native-window-guard';

export default class App extends React.Component {

 toggleStatusBar = () => {
   //change statusBarHidden state
   StatusBar.setHidden(statusBarHidden, true);       //change system ui views state
   this.container && this.container.adjustInsets()   //request to refresh insets values
 };

 render() {
   return (
     <WindowGuard
       ref={r => this.container = r}
       style={{flex: 1}}
       applyInsets={WindowGuard.all}>
       //content
     </WindowGuard>
   );
 }
}

HOC

For convenience there is HOC wich will simplify WindowGuard usage. withWindowGuard HOC will return component wrapped into WindowGuard with defined insets configuration. For example

const GuardedView = withWindowGuard(View, WindowGuard.all)

will return View component wrapped into WindowGuard with insets applied to all sides.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].