diff --git a/android/app/src/main/java/com/opendeck/MainApplication.java b/android/app/src/main/java/com/opendeck/MainApplication.java index 3074f7a..2ced354 100644 --- a/android/app/src/main/java/com/opendeck/MainApplication.java +++ b/android/app/src/main/java/com/opendeck/MainApplication.java @@ -4,6 +4,7 @@ import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; +import org.wonday.orientation.OrientationPackage; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; diff --git a/android/settings.gradle b/android/settings.gradle index 0f9582b..5b0fc9f 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,3 +1,5 @@ rootProject.name = 'opendeck' +include ':react-native-orientation-locker' +project(':react-native-orientation-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-locker/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' diff --git a/ios/Podfile b/ios/Podfile index 0238978..55303b0 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -8,6 +8,8 @@ target 'opendeck' do use_react_native!(:path => config["reactNativePath"]) + pod 'react-native-orientation-locker', :path => '../node_modules/react-native-orientation-locker' + target 'opendeckTests' do inherit! :complete # Pods for testing diff --git a/package-lock.json b/package-lock.json index 7d6e87f..68d620a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10014,6 +10014,11 @@ } } }, + "react-native-orientation-locker": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/react-native-orientation-locker/-/react-native-orientation-locker-1.2.0.tgz", + "integrity": "sha512-lnwp9Jbt1m/0Gfw9a5Mrwj/APNSuYkVdJEgBKRyQgOshDrKRv5dxpD0P786AgIEjnEbjyrNOS6GQvBdqPYSxsg==" + }, "react-refresh": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.4.3.tgz", diff --git a/package.json b/package.json index db39d52..0b4b9ee 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ }, "dependencies": { "react": "16.13.1", - "react-native": "0.63.4" + "react-native": "0.63.4", + "react-native-orientation-locker": "^1.2.0" }, "devDependencies": { "@babel/core": "^7.8.4", diff --git a/src/components/Deck.tsx b/src/components/Deck.tsx index 47e4acf..ada080d 100644 --- a/src/components/Deck.tsx +++ b/src/components/Deck.tsx @@ -1,7 +1,11 @@ -import React, {PropsWithChildren} from 'react'; +import React, {PropsWithChildren, useEffect} from 'react'; import {StyleSheet, View} from 'react-native'; +import Orientation from 'react-native-orientation-locker'; export default function Deck(props: PropsWithChildren<{}>) { + useEffect(() => { + Orientation.lockToPortrait(); + }); return ( <> {props.children}