import * as React from 'react'; import { Component, Styles, Types, View } from 'reactxp'; import { colors } from '../../config.json'; import { TunnelState } from '../../shared/daemon-rpc-types'; import { messages } from '../../shared/gettext'; import ConnectionPanelContainer from '../containers/ConnectionPanelContainer'; import * as AppButton from './AppButton'; import ImageView from './ImageView'; import Marquee from './Marquee'; import { IMainButtonProps, ISideButtonProps, MultiButton } from './MultiButton'; import SecuredLabel, { SecuredDisplayStyle } from './SecuredLabel'; interface ITunnelControlProps { tunnelState: TunnelState; selectedRelayName: string; city?: string; country?: string; onConnect: () => void; onDisconnect: () => void; onReconnect: () => void; onSelectLocation: () => void; } const styles = { body: Styles.createViewStyle({ paddingTop: 0, paddingLeft: 24, paddingRight: 24, paddingBottom: 0, marginTop: 176, flex: 1, }), footer: Styles.createViewStyle({ flex: 0, paddingBottom: 16, paddingLeft: 24, paddingRight: 24, }), wrapper: Styles.createViewStyle({ flex: 1, }), switch_location_button: Styles.createViewStyle({ marginBottom: 16, }), status_security: Styles.createTextStyle({ fontFamily: 'Open Sans', fontSize: 16, fontWeight: '800', lineHeight: 22, marginBottom: 2, }), status_location: Styles.createTextStyle({ flexDirection: 'column', marginBottom: 2, }), status_location_text: Styles.createTextStyle({ fontFamily: 'DINPro', fontSize: 34, lineHeight: 38, fontWeight: '900', overflow: 'hidden', letterSpacing: -0.9, color: colors.white, }), }; export default class TunnelControl extends Component { public render() { const Location = ({ children }: { children?: React.ReactNode }) => ( {children} ); const City = () => {this.props.city}; const Country = () => ( {this.props.country} ); const SwitchLocation = () => { return ( {messages.pgettext('tunnel-control', 'Switch location')} ); }; const SelectedLocation = () => ( {this.props.selectedRelayName} ); const Connect = () => ( {messages.pgettext('tunnel-control', 'Secure my connection')} ); const Disconnect = (props: IMainButtonProps) => ( {messages.pgettext('tunnel-control', 'Disconnect')} ); const Cancel = (props: IMainButtonProps) => ( {messages.pgettext('tunnel-control', 'Cancel')} ); const Dismiss = (props: IMainButtonProps) => ( {messages.pgettext('tunnel-control', 'Dismiss')} ); const Reconnect = (props: ISideButtonProps) => ( ); const Secured = ({ displayStyle }: { displayStyle: SecuredDisplayStyle }) => ( ); const Footer = ({ children }: { children: React.ReactNode }) => ( {children} ); let state = this.props.tunnelState.state; switch (this.props.tunnelState.state) { case 'disconnecting': switch (this.props.tunnelState.details) { case 'block': state = 'error'; break; case 'reconnect': state = 'connecting'; break; default: state = 'disconnecting'; break; } break; } switch (state) { case 'connecting': return (
); case 'connected': return (
); case 'error': if ( this.props.tunnelState.state === 'error' && !this.props.tunnelState.details.isBlocking ) { return (
); } else { return (
); } case 'disconnecting': return (
); case 'disconnected': return (
); default: throw new Error(`Unknown TunnelState: ${this.props.tunnelState}`); } } } interface IContainerProps { children?: Types.ReactNode; } class Wrapper extends Component { public render() { return {this.props.children}; } } class Body extends Component { public render() { return {this.props.children}; } }