|
|
@ -3,6 +3,11 @@ import React, { PureComponent } from 'react';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import TrezorConnect from 'trezor-connect';
|
|
|
|
import TrezorConnect from 'trezor-connect';
|
|
|
|
import type { TrezorDevice } from 'flowtype';
|
|
|
|
import type { TrezorDevice } from 'flowtype';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import COLORS from 'config/colors';
|
|
|
|
|
|
|
|
import { FONT_SIZE, FONT_WEIGHT } from 'config/variables';
|
|
|
|
|
|
|
|
import { SLIDE_DOWN } from 'config/animations';
|
|
|
|
|
|
|
|
|
|
|
|
import Button from 'components/Button';
|
|
|
|
import Button from 'components/Button';
|
|
|
|
import * as deviceUtils from 'utils/device';
|
|
|
|
import * as deviceUtils from 'utils/device';
|
|
|
|
import MenuItems from './components/MenuItems';
|
|
|
|
import MenuItems from './components/MenuItems';
|
|
|
@ -12,9 +17,18 @@ import type { Props } from '../common';
|
|
|
|
|
|
|
|
|
|
|
|
import Divider from '../Divider';
|
|
|
|
import Divider from '../Divider';
|
|
|
|
|
|
|
|
|
|
|
|
const Wrapper = styled.div``;
|
|
|
|
const Wrapper = styled.div`
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
padding-bottom: 8px;
|
|
|
|
|
|
|
|
border-bottom: 1px solid #E3E3E3;
|
|
|
|
|
|
|
|
background: white;
|
|
|
|
|
|
|
|
box-shadow: 0 3px 8px rgba(0,0,0,0.06);
|
|
|
|
|
|
|
|
animation: ${SLIDE_DOWN} 0.25s cubic-bezier(0.17, 0.04, 0.03, 0.94) forwards;
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
const ButtonWrapper = styled.div`
|
|
|
|
const ButtonWrapper = styled.div`
|
|
|
|
margin-top: 10px;
|
|
|
|
margin: 10px 0;
|
|
|
|
padding: 0 10px;
|
|
|
|
padding: 0 10px;
|
|
|
|
display: flex;
|
|
|
|
display: flex;
|
|
|
|
`;
|
|
|
|
`;
|
|
|
@ -22,6 +36,14 @@ const StyledButton = styled(Button)`
|
|
|
|
flex: 1;
|
|
|
|
flex: 1;
|
|
|
|
`;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const StyledDivider = styled(Divider)`
|
|
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
|
|
color: ${COLORS.TEXT_PRIMARY};
|
|
|
|
|
|
|
|
font-weight: ${FONT_WEIGHT.MEDIUM};
|
|
|
|
|
|
|
|
font-size: ${FONT_SIZE.BASE};
|
|
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
type DeviceMenuItem = {
|
|
|
|
type DeviceMenuItem = {
|
|
|
|
type: string;
|
|
|
|
type: string;
|
|
|
|
label: string;
|
|
|
|
label: string;
|
|
|
@ -32,6 +54,7 @@ class DeviceMenu extends PureComponent<Props> {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
this.mouseDownHandler = this.mouseDownHandler.bind(this);
|
|
|
|
this.mouseDownHandler = this.mouseDownHandler.bind(this);
|
|
|
|
this.blurHandler = this.blurHandler.bind(this);
|
|
|
|
this.blurHandler = this.blurHandler.bind(this);
|
|
|
|
|
|
|
|
this.myRef = React.createRef();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount(): void {
|
|
|
|
componentDidMount(): void {
|
|
|
@ -63,6 +86,10 @@ class DeviceMenu extends PureComponent<Props> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getMenuHeight(): number {
|
|
|
|
|
|
|
|
return this.myRef.current ? this.myRef.current.getBoundingClientRect().height : 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
blurHandler(): void {
|
|
|
|
blurHandler(): void {
|
|
|
|
this.props.toggleDeviceDropdown(false);
|
|
|
|
this.props.toggleDeviceDropdown(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -96,26 +123,28 @@ class DeviceMenu extends PureComponent<Props> {
|
|
|
|
return deviceUtils.isDeviceAccessible(this.props.wallet.selectedDevice);
|
|
|
|
return deviceUtils.isDeviceAccessible(this.props.wallet.selectedDevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
myRef: { current: ?HTMLDivElement }
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
const { devices, onSelectDevice, forgetDevice } = this.props;
|
|
|
|
const { devices, onSelectDevice, forgetDevice } = this.props;
|
|
|
|
const { transport } = this.props.connect;
|
|
|
|
const { transport } = this.props.connect;
|
|
|
|
const { selectedDevice } = this.props.wallet;
|
|
|
|
const { selectedDevice } = this.props.wallet;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Wrapper>
|
|
|
|
<Wrapper ref={this.myRef}>
|
|
|
|
{this.showMenuItems() && <MenuItems device={selectedDevice} {...this.props} />}
|
|
|
|
{this.showMenuItems() && <MenuItems device={selectedDevice} {...this.props} />}
|
|
|
|
{this.showDivider() && <Divider hasBorder textLeft="Other devices" />}
|
|
|
|
{this.showDivider() && <StyledDivider hasBorder textLeft="Other devices" />}
|
|
|
|
<DeviceList
|
|
|
|
<DeviceList
|
|
|
|
devices={devices}
|
|
|
|
devices={devices}
|
|
|
|
selectedDevice={selectedDevice}
|
|
|
|
selectedDevice={selectedDevice}
|
|
|
|
onSelectDevice={onSelectDevice}
|
|
|
|
onSelectDevice={onSelectDevice}
|
|
|
|
forgetDevice={forgetDevice}
|
|
|
|
forgetDevice={forgetDevice}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<ButtonWrapper>
|
|
|
|
{deviceUtils.isWebUSB(transport) && (
|
|
|
|
{deviceUtils.isWebUSB(transport) && (
|
|
|
|
<ButtonWrapper>
|
|
|
|
<StyledButton isWebUsb>Check for devices</StyledButton>
|
|
|
|
<StyledButton isWebUsb>Check for devices</StyledButton>
|
|
|
|
)}
|
|
|
|
</ButtonWrapper>
|
|
|
|
</ButtonWrapper>
|
|
|
|
)}
|
|
|
|
</Wrapper>
|
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|