import * as React from 'react'; import {ActivityIndicator, Button, Dialog, Paragraph, Portal, withTheme} from 'react-native-paper'; import ConnectionManager from "../managers/ConnectionManager"; 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 ( DISCONNECT {this.state.loading ? : DISCONNECT? } {this.state.loading ? null : } ); } } export default withTheme(LogoutDialog);