This package has been deprecated

Author message:

converted to private

react-native-dual-screen
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

react-native-dual-screen

npm version Dependency Status devDependencies Status typings included npm

React Native package for dual screen devices support (Surface Duo). Surface Neo support is coming

Surface Duo Demo

Status

  • Android:
    • 10+
  • react-native:
    • supported versions ">= 0.60.5"

Installation

with react-native ">=0.60.5"

0. Setup Swift and Kotlin

  • Modify android/build.gradle:

    buildscript {
      ext {
        ...
    +   kotlinVersion = "1.3.50"
      }
    ...
     
      dependencies {
    +   classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
        ...

1. Install latest version from npm

$ yarn add react-native-dual-screen

2. Modify android:configChanges of your activity

android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"

Example

import * as React from 'react'
import { View } from 'react-native'
import { RNDualScreenManager, Hinge } from 'react-native-dual-screen'
 
export default function App() {
  const [isDualMode, setDualMode] = useState(false)
    useEffect(() => {
        RNDualScreenManager.isDualMode().then((isDual: boolean) => {
            setDualMode(isDual)
        })
 
        RNDualScreenManager.addOnChangeListener((event) => {
            const isDual = event.isDualMode === 'true'
            if (isDualMode !== isDual) {
                setDualMode(isDual)
            }
        })
    })
 
    if (isDualMode) {
      return (
        <View style={{ flex: 1, flexDirection: 'row' }}>
          <View style={{ flex: 1 }}>
            <Text>Screen 1</Text>
          </View>
          <Hinge/>
          <View style={{ flex: 1 }}>
            <Text>Screen 2</Text>
          </View>
        </View>
      )
    }
 
    return (
      <View style={{ flex: 1 }}>
        <Text>Screen 1</Text>
      </View>  
    )
}
 

Reference

Documentation

Get the Surface Duo SDK

Use the Surface Duo emulator

Readme

Keywords

Package Sidebar

Install

npm i react-native-dual-screen

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

24.6 kB

Total Files

41

Last publish

Collaborators

  • npm