Giter Club home page Giter Club logo

expo-full-screen's Introduction

@untitled/expo-full-screen

Enter and exit full screen & bindings for system UI/bars manipulation.

API reference

NOTE: mixed usage of setSystemUiVisibility and setSystemBarsAppearance may lead to undefined system UI/bars states.

import {
  SDK_INT,
  enterFullScreen,
  exitFullScreen,
  enterFullScreenSync,
  exitFullScreenSync,
  getSystemUiVisibility,
  setSystemUiVisibility,
  setSystemUiVisibilitySync,
  getSystemBarsAppearance,
  setSystemBarsAppearance,
  setSystemBarsAppearanceSync,
  getSystemUiFlag,
  setSystemUiFlag,
  setSystemUiFlagSync
} from '@untitled/expo-full-screen'

Constants

SDK_INT

The Android SDK version of the software system currently running on this hardware device. Alias of android.os.Build.VERSION#SDK_INT. When it is larger than or equal to 30, getSystemBarsAppearance, setSystemBarsAppearance and setSystemBarsAppearanceSync are available.

Methods

enterFullScreen

Enter full screen mode by doing the following:

  1. Set decor view to render edge-to-edge.
  2. Hide all system bars, including status bars, caption bar as well as navigation bars, but not IME.
  3. Allow showing transient system bars when users swipe the edge of the screen (BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE).

enterFullScreenSync

Synchronous version of enterFullScreen.

exitFullScreen

Exit full screen mode by reversing what enterFullScreen does:

  1. Set decor view to not render under status bar and navigation bars.
  2. Show all system bars, including status bars, caption bar as well as navigation bars, but not IME.
  3. Reset system bars behavior (BEHAVIOR_SHOW_BARS_BY_TOUCH).

exitFullScreenSync

Synchronous version of exitFullScreen.

getSystemUiVisibility

Get system UI visibility. Alias of getSystemUiVisibility.

setSystemUiVisibility

Set system UI visibility. Alias of setSystemUiVisibility.

setSystemUiVisibilitySync

Synchronous version of setSystemUiVisibility.

getSystemBarsAppearance

Retrieve the requested appearance of system bars. Alias of getSystemBarsAppearance.

setSystemBarsAppearance

Control the appearance of system bars. Alias of setSystemBarsAppearance.

setSystemBarsAppearanceSync

Synchronous version of setSystemBarsAppearance.

getSystemUiFlag

Alias of getSystemUiVisibility when SDK_INT is lower than 30, or getSystemBarsAppearance otherwise. Useful when you will set the same flag value back later, so effectively you don't care what the SDK version really is.

setSystemUiFlag

Alias of setSystemUiVisibility when SDK_INT is lower than 30, or setSystemBarsAppearance otherwise. Useful when you will set back the same flag value that you retrieved via getSystemUiFlag, so effectively you don't care what the SDK version really is.

setSystemUiFlagSync

Synchronous version of setSystemUiFlag.

Installation

Managed Expo projects

For managed Expo projects, simply install the package:

npm install git+https://github.com/Luluno01/expo-full-screen.git

Bare React Native projects

For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.

Add the package to your npm dependencies

npm install git+https://github.com/Luluno01/expo-full-screen.git

Configure for Android

Optionally add the following content to your styles.xml:

<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="o_mr1">shortEdges</item>

So that it looks like

<resources xmlns:tools="http://schemas.android.com/tools">
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:textColor">@android:color/black</item>
    <item name="android:editTextStyle">@style/ResetEditText</item>
    <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="o_mr1">shortEdges</item>
  </style>
  <style name="ResetEditText" parent="@android:style/Widget.EditText">
    <item name="android:padding">0dp</item>
    <item name="android:textColorHint">#c8c8c8</item>
    <item name="android:textColor">@android:color/black</item>
  </style>
  <style name="Theme.App.SplashScreen" parent="AppTheme">
    <item name="android:windowBackground">@drawable/splashscreen</item>
  </style>
</resources>

Usage

See example for a working example.

Contributing

Contributions are very welcome! Simply open an issue or a pull request.

expo-full-screen's People

Contributors

luluno01 avatar

Stargazers

Fredrik Burmester avatar SarbaNanda Bhikkhu avatar Sachin Acharya avatar

Watchers

 avatar

Forkers

akhnaz

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.