44 */
55
66import React from 'react' ;
7- import { StyleSheet , View , Dimensions , Alert , RefreshControl , Modal } from 'react-native' ;
7+ import { StyleSheet , View , Alert , RefreshControl , Modal } from 'react-native' ;
88import { Button , Icon , Text , Thumbnail , Form , Item , Label , Content , Input , Spinner , Badge , ListItem , List , Left , Right , Body , H2 } from 'native-base' ;
99import QRCode from 'react-native-qrcode' ;
1010import * as jws from '../../../utils/jws' ;
@@ -33,7 +33,6 @@ export default class ProfileScreen extends React.Component {
3333 qrcodeCountDown : 60 ,
3434 qrcodeContent : null ,
3535
36- showDialog : false ,
3736 showQrCode : false ,
3837 showChangePassword : false ,
3938
@@ -164,27 +163,6 @@ export default class ProfileScreen extends React.Component {
164163 ) ;
165164 }
166165
167- renderModalLogout ( ) {
168- const dialogSize = Math . round ( ( Dimensions . get ( 'screen' ) . width * 4 ) / 5 ) ;
169- return (
170- < Modal visible = { this . state . showDialog } transparent animationType = "none" onRequestClose = { ( ) => this . setState ( { showDialog : false } ) } >
171- < View style = { { flex : 1 , justifyContent : 'center' , alignItems : 'center' , backgroundColor : '#00000050' } } >
172- < View style = { { flexDirection : 'column' , paddingHorizontal : 20 , paddingVertical : 15 , backgroundColor : color . white , width : dialogSize , borderRadius : 12 } } >
173- < Text style = { { marginVertical : 15 , fontSize : 18 } } > Do you want to logout?</ Text >
174- < View style = { { flexDirection : 'row' , justifyContent : 'flex-end' , marginBottom : 5 } } >
175- < Button dark onPress = { ( ) => this . setState ( { showDialog : false } ) } style = { { margin : 3 } } >
176- < Text > Cancel</ Text >
177- </ Button >
178- < Button danger onPress = { this . _onClickSignOut } style = { { margin : 3 } } >
179- < Text > OK</ Text >
180- </ Button >
181- </ View >
182- </ View >
183- </ View >
184- </ Modal >
185- ) ;
186- }
187-
188166 renderModalQrCode ( ) {
189167 const qrcodeSize = 256 ;
190168 return (
@@ -272,7 +250,7 @@ export default class ProfileScreen extends React.Component {
272250 < View style = { { position : 'absolute' , top : 0 , left : 0 , height : 80 , width : '100%' , backgroundColor : color . primary } } />
273251 < View style = { { height : 160 , justifyContent : 'center' , alignItems : 'center' } } >
274252 < View style = { { flexDirection : 'row' , flex : 1 , height : 120 , width : '100%' , justifyContent : 'space-around' , alignItems : 'center' } } >
275- < Button rounded small iconLeft style = { { backgroundColor : '#d60022' , alignSelf : 'center' } } onPress = { ( ) => this . setState ( { showDialog : true } ) } >
253+ < Button rounded small iconLeft style = { { backgroundColor : '#d60022' , alignSelf : 'center' } } onPress = { ( ) => this . handleLogout ( ) } >
276254 < Icon name = "logout" type = "SimpleLineIcons" style = { { fontSize : 15 } } />
277255 < Text style = { { fontSize : 12 } } > Logout</ Text >
278256 </ Button >
@@ -338,12 +316,26 @@ export default class ProfileScreen extends React.Component {
338316 </ List >
339317 { this . renderModalQrCode ( ) }
340318 { this . renderModalChangePassword ( ) }
341- { this . renderModalLogout ( ) }
342319 </ Content >
343320 </ AppScreenWrapper >
344321 ) ;
345322 }
346323
324+ handleLogout ( ) {
325+ Alert . alert ( 'Warning' , 'Do you want to logout?' , [
326+ {
327+ text : 'Cancel' ,
328+ style : 'cancel' ,
329+ } ,
330+ {
331+ text : 'YES' ,
332+ onPress : async ( ) => {
333+ this . signOut ( ) ;
334+ } ,
335+ } ,
336+ ] ) ;
337+ }
338+
347339 onChangePassword = async ( ) => {
348340 if ( this . state . oldPassword === '' || this . state . newPassword === '' ) {
349341 return Alert . alert ( 'Error' , "Fields can't be empty" ) ;
@@ -364,7 +356,7 @@ export default class ProfileScreen extends React.Component {
364356 } ) ;
365357 } ;
366358
367- _onClickSignOut = async ( ) => {
359+ signOut = async ( ) => {
368360 authApi
369361 . logout ( )
370362 . then ( ( ) => this . props . navigation . navigate ( 'Auth' ) )
0 commit comments