-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
65 lines (62 loc) · 1.84 KB
/
App.js
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
import React, { useEffect, useState } from "react";
import { View, Platform } from "react-native";
import Navigation from "./navigation";
import { LemmyAPIProvider } from "./contexts/LemmyAPIContext";
import { MenuProvider } from "react-native-popup-menu";
import { connect, Provider } from "react-redux";
import { store, persistor } from "./redux/store";
import { PersistGate } from "redux-persist/integration/react";
import { FontProvider } from "./FontContext";
import { StateProvider } from "./StateContext";
import withColorScheme from "./styles/Formatting";
import { isDesktop } from "react-device-detect";
const App = ({ instance }) => {
// LogBox.ignoreLogs();
console.disableYellowBox = true;
const [isPWA, setIsPWA] = useState(false);
useEffect(() => {
if (Platform.OS == "ios" || Platform.OS == "android") {
return;
} else {
const isStandalone =
window.navigator.standalone ||
window.matchMedia("(display-mode: standalone)").matches;
setIsPWA(isStandalone && !isDesktop);
}
}, []);
return (
<LemmyAPIProvider instance={instance}>
<StateProvider>
<MenuProvider>
<View
style={{
width: "100%",
height: isPWA ? 50 : 0,
backgroundColor: "#1cb0f6",
}}
/>
<Navigation />
</MenuProvider>
</StateProvider>
</LemmyAPIProvider>
);
};
const mapStateToProps = (state) => {
return {
instance: state.updateItem.reduxGlobal.instance,
};
};
const ReduxConnect = connect(mapStateToProps)(App);
const ConnectedApp = withColorScheme(ReduxConnect);
const Root = () => {
return (
<Provider store={store}>
<PersistGate persistor={persistor}>
<FontProvider>
<ConnectedApp />
</FontProvider>
</PersistGate>
</Provider>
);
};
export default Root;