Skip to content

Instantly share code, notes, and snippets.

View janhesters's full-sized avatar
📈
Learning.

Jan Hesters janhesters

📈
Learning.
View GitHub Profile
// ... Other imports
#import "Orientation.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ... Leave this untouched
}
// ... 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);
// ... 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 = () => {
import Orientation from 'react-native-orientation';
// ...
Orientation.getOrientation((err, orientation) => {
console.log(`Current Device Orientation: ${orientation}`);
});
import { StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center"
}
});
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>
import NameScreen from "./NameScreen";
export default NameScreen;
import DetailScreen from '../screens/Detail';
import HomeScreen from '../screens/Home';
import LoadingScreen from '../screens/Loading';
import OptionsScreen from '../screens/Options';
import SettingsScreen from '../screens/Settings';
// ... screen imports
import { createStackNavigator } from 'react-navigation'; // Remember to import the other navigators later
const HomeStack = createStackNavigator({ DetailScreen, HomeScreen, OptionsScreen });
const MainTabs = createBottomTabNavigator({ HomeStack, SettingsScreen });