Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
Axel Chalon
committed
import React, { Component } from 'react';
import {
BrowserRouter,
MemoryRouter,
Redirect,
Route,
Switch
Axel Chalon
committed
} from 'react-router-dom';
import { inject, observer } from 'mobx-react';
import isElectron from 'is-electron';
import ReactResizeDetector from 'react-resize-detector';
import styled, { ThemeProvider } from 'styled-components';
Axel Chalon
committed
import Accounts from '../Accounts';
import BackupAccount from '../BackupAccount';
Axel Chalon
committed
import Onboarding from '../Onboarding';
import RequireHealth from '../RequireHealthOverlay';
Axel Chalon
committed
import Tokens from '../Tokens';
import { fetherTheme, GlobalStyle } from '../assets/theme/globalStyle';
import { DivContentStyles, DivWindowStyles } from './style';
const DivContent = styled.div`
${DivContentStyles};
`;
const DivWindow = styled.div`
${DivWindowStyles};
`;
// Use MemoryRouter for production viewing in file:// protocol
// https://github.com/facebook/create-react-app/issues/3591
const Router =
Axel Chalon
committed
process.env.NODE_ENV === 'production' ? MemoryRouter : BrowserRouter;
const electron = isElectron() ? window.require('electron') : null;
handleResize = (_, height) => {
if (!electron) {
return;
}
// Send height to main process
Axel Chalon
committed
electron.ipcRenderer.send('asynchronous-message', 'app-resize', height);
Axel Chalon
committed
<div className='window'>
<Onboarding />
</div>
);
<ReactResizeDetector handleHeight onResize={this.handleResize}>
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<ThemeProvider theme={fetherTheme}>
<div>
<GlobalStyle theme={fetherTheme} />
<DivContent>
<DivWindow>
{/* Don't display child components requiring RPCs if API is not yet set */}
<RequireHealth require='connected' fullscreen>
<Router>
<Switch>
{/* The next line is the homepage */}
<Redirect exact from='/' to='/accounts' />
<Route path='/accounts' component={Accounts} />
<Route path='/onboarding' component={Onboarding} />
<Route
path='/tokens/:accountAddress'
component={Tokens}
/>
<Route
path='/whitelist/:accountAddress'
component={Whitelist}
/>
<Route
path='/backup/:accountAddress'
component={BackupAccount}
/>
<Route
path='/send/:tokenAddress/from/:accountAddress'
component={Send}
/>
<Redirect from='*' to='/' />
</Switch>
</Router>
</RequireHealth>
</DivWindow>
</DivContent>
</ThemeProvider>