// @flow import * as React from 'react'; import {ActivityIndicator, Button, Dialog, Paragraph, Portal, withTheme} from 'react-native-paper'; import ConnectionManager from "../../managers/ConnectionManager"; import i18n from 'i18n-js'; type Props = { navigation: Object, visible: boolean, onDismiss: Function, } type State = { loading: boolean, } class LogoutDialog extends React.PureComponent { colors: Object; state = { loading: false, }; constructor(props) { super(props); this.colors = props.theme.colors; } onClickAccept = () => { this.setState({loading: true}); ConnectionManager.getInstance().disconnect() .then(() => { this.props.onDismiss(); this.setState({loading: false}); this.props.navigation.reset({ index: 0, routes: [{name: 'Main'}], }); }); }; onDismiss = () => { if (!this.state.loading) this.props.onDismiss(); }; render() { return ( {this.state.loading ? i18n.t("dialog.disconnect.titleLoading") : i18n.t("dialog.disconnect.title")} {this.state.loading ? : {i18n.t("dialog.disconnect.message")} } {this.state.loading ? null : } ); } } export default withTheme(LogoutDialog);