-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainApp.js
More file actions
96 lines (77 loc) · 2.79 KB
/
Copy pathMainApp.js
File metadata and controls
96 lines (77 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React, { Component } from 'react';
import {
Dimensions,
} from 'react-native';
import Orientation from 'react-native-orientation-locker';
import ApplicationNavigator from "./src/components/pages/Navigation";
import { Provider } from "react-redux";
import setupStore from "./src/redux/setupStore";
export default class MainApp extends Component {
constructor (props) {
super(props);
let firstTime = false;
if (typeof this.props.navigation != "undefined"){
firstTime = true;
}
this.state = {
current_screen: "None",
navigation: {},
first: firstTime,
activeFilters: [],
filterMenu: false,
menuSide: false,
rateScreen: false,
guideScreen: false,
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
navigatorMethod: null,
}
}
_onOrientationDidChange = (orientation) => {
if (orientation == 'LANDSCAPE-LEFT') {
//do something with landscape left layout
} else {
//do something with portrait layout
}
};
componentWillMount() {
//The getOrientation method is async. It happens sometimes that
//you need the orientation at the moment the js starts running on device.
//getInitialOrientation returns directly because its a constant set at the
//beginning of the js code.
var initial = Orientation.getInitialOrientation();
if (initial === 'PORTRAIT') {
//do stuff
} else {
//do other stuff
}
};
componentDidMount() {
Orientation.getAutoRotateState((rotationLock) => this.setState({rotationLock}));
//this allows to check if the system autolock is enabled or not.
Orientation.lockToPortrait(); //this will lock the view to Portrait
//Orientation.lockToLandscapeLeft(); //this will lock the view to Landscape
//Orientation.unlockAllOrientations(); //this will unlock the view to all Orientations
//get current UI orientation
/*
Orientation.getOrientation((orientation)=> {
console.log("Current UI Orientation: ", orientation);
});
//get current device orientation
Orientation.getDeviceOrientation((deviceOrientation)=> {
console.log("Current Device Orientation: ", deviceOrientation);
});
*/
Orientation.addOrientationListener(this._onOrientationDidChange);
}
componentWillUnmount() {
Orientation.removeOrientationListener(this._onOrientationDidChange);
}
render() {
return (
<Provider store={setupStore}>
<ApplicationNavigator />
</Provider>
);
}
}