From 6bff17f226d99b2b80a2ca0c4b55ca52722ea1ff Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 22 Jan 2021 14:54:34 +0100 Subject: [PATCH] added orientation locker --- android/app/src/main/java/com/opendeck/MainApplication.java | 1 + android/settings.gradle | 2 ++ ios/Podfile | 2 ++ package-lock.json | 5 +++++ package.json | 3 ++- src/components/Deck.tsx | 6 +++++- 6 files changed, 17 insertions(+), 2 deletions(-) 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}