This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... Other imports | |
#import "Orientation.h" | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
// ... Leave this untouched | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... Other imports | |
import android.content.Intent; | |
import android.content.res.Configuration; | |
public class MainActivity extends ReactActivity { | |
// ... Leave the default code from React Native untouched | |
@Override | |
public void onConfigurationChanged(Configuration newConfig) { | |
super.onConfigurationChanged(newConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... Other imports. Only import 'orientation' in the following line, if you are using TypeScript | |
import Orientation, { orientation } from 'react-native-orientation'; | |
export default class App extends Component<Props> { | |
componentDidMount = () => { | |
Orientation.lockToPortrait(); | |
Orientation.addOrientationListener(this.orientationDidChange); | |
}; | |
componentWillUnmount = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Orientation from 'react-native-orientation'; | |
// ... | |
Orientation.getOrientation((err, orientation) => { | |
console.log(`Current Device Orientation: ${orientation}`); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StyleSheet } from 'react-native'; | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: "center", | |
alignItems: "center" | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styles from './styles'; | |
import React, { Component } from 'react'; | |
import { Text, View } from 'react-native'; | |
class NameScreen extends Component { | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text>This is the NameScreen.</Text> | |
</View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NameScreen from "./NameScreen"; | |
export default NameScreen; |