forked from buttercup/buttercup-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.shared.js
74 lines (70 loc) · 3.02 KB
/
index.shared.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
66
67
68
69
70
71
72
73
74
import "react-native-gesture-handler";
import "./shim.js";
import React, { Component, Fragment } from "react";
import { AppRegistry, View, YellowBox, StatusBar } from "react-native";
import { I18nextProvider } from "react-i18next";
import { Provider } from "react-redux";
import DropdownAlert from "react-native-dropdownalert";
import { patchCrypto } from "./source/library/crypto.js";
import { getSharedArchiveManager } from "./source/library/buttercup.js";
import store from "./source/store.js";
import ButtercupApp from "./source/routing.js";
import AutoFillApp from "./source/autofill/routing.js";
import { setNotificationFunction } from "./source/global/notify.js";
import { registerAuthWatchers } from "./source/library/auth.js";
import { setTopLevelNavigator } from "./source/shared/nav.js";
import i18n from "./source/shared/i18n";
// Ignore some warnings
// @TODO: remove this once we are fully upgraded
YellowBox.ignoreWarnings(["Warning: componentWill"]);
export default class ButtercupShared extends Component {
constructor(...args) {
super(...args);
// Setup native crypto
patchCrypto();
// Initialise the manager
getSharedArchiveManager().rehydrate();
// Setup notifications
setNotificationFunction((type, title, message, timeOverride = null) => {
if (this.dropdown) {
console.log(type, title);
if (timeOverride && timeOverride > 0) {
this.dropdown.alertWithType(type, title, message, undefined, timeOverride);
} else {
this.dropdown.alertWithType(type, title, message);
}
}
});
// Watch for auth failures and handle refreshing of tokens
registerAuthWatchers();
}
render() {
return (
<View style={{ flex: 1 }}>
<StatusBar barStyle="dark-content" />
<Provider store={store}>
<I18nextProvider i18n={i18n}>
{/* Show the main app stack when NOT in autofill mode */}
{!this.props.isContextAutoFill && (
<ButtercupApp ref={navigator => setTopLevelNavigator(navigator)} />
)}
{/* Show the AutoFill app stack when IN autofill mode */}
{!!this.props.isContextAutoFill && (
<AutoFillApp
screenProps={this.props}
ref={navigator => setTopLevelNavigator(navigator)}
/>
)}
</I18nextProvider>
</Provider>
<DropdownAlert
ref={ref => (this.dropdown = ref)}
closeInterval={8000}
activeStatusBarStyle="light-content"
inactiveStatusBarStyle="dark-content"
/>
</View>
);
}
}
AppRegistry.registerComponent("Buttercup", () => ButtercupShared);