Skip to content

Commit 528aff8

Browse files
baquerchashmeetsingh
authored andcommitted
Fix:Alert Controller in logout cell in SettingVC (#501)
* Alert Controller in logout cell * Changes done
1 parent 7bf1f4e commit 528aff8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Susi/Controllers/SettingsController/SettingsViewController.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,19 @@ class SettingsViewController: UITableViewController {
125125
} else if row == 2 {
126126
presentResetPasswordController()
127127
} else if row == 3 {
128-
logoutUser()
129-
}
128+
if logoutTitle.text == ControllerConstants.Settings.logout.localized() {
129+
let logoutAlert = UIAlertController(title: ControllerConstants.Logout.title, message: ControllerConstants.Logout.message, preferredStyle: UIAlertController.Style.alert)
130+
logoutAlert.addAction(UIAlertAction(title: ControllerConstants.Logout.cancel, style: .default, handler: { (action: UIAlertAction!) in
131+
logoutAlert.dismiss(animated: true, completion: nil)
132+
}))
133+
logoutAlert.addAction(UIAlertAction(title: ControllerConstants.Logout.confirm, style: .destructive, handler: { (action: UIAlertAction!) in
134+
self.logoutUser()
135+
}))
136+
present(logoutAlert, animated: true, completion: nil)
137+
} else {
138+
logoutUser()
139+
}
140+
}
130141
}
131142
tableView.deselectRow(at: indexPath, animated: true)
132143
}

Susi/Helpers/ControllerConstants.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,5 +273,12 @@ class ControllerConstants {
273273
static let reportIssueURL = "https://github.com/fossasia/susi_iOS/issues"
274274
static let licenseURL = "https://github.com/fossasia/susi_iOS/blob/master/LICENSE"
275275
}
276+
277+
struct Logout {
278+
static let title = "Logout"
279+
static let message = "Are you sure, you want to log out?"
280+
static let cancel = "Cancel"
281+
static let confirm = "Confirm"
282+
}
276283

277284
}

0 commit comments

Comments
 (0)