Przeglądaj źródła

loginButton now disabled when logged in

Bastian van de Wetering 6 lat temu
rodzic
commit
4d471e3efa

+ 8 - 2
deltachat-ios/Controller/AccountSetupController.swift

@@ -150,7 +150,11 @@ class AccountSetupController: UITableViewController {
 	}()
 	}()
 
 
 	// this loginButton can be enabled and disabled
 	// this loginButton can be enabled and disabled
-	lazy var loginButton: UIBarButtonItem = UIBarButtonItem(title: "Login", style: .done, target: self, action: #selector(loginButtonPressed))
+	private lazy var loginButton: UIBarButtonItem = {
+		let button = UIBarButtonItem(title: "Login", style: .done, target: self, action: #selector(loginButtonPressed))
+		button.isEnabled = dc_is_configured(mailboxPointer) == 0
+		return button
+	}()
 
 
 	private lazy var basicSectionCells: [UITableViewCell] = [emailCell, passwordCell]
 	private lazy var basicSectionCells: [UITableViewCell] = [emailCell, passwordCell]
 	private lazy var restoreCells: [UITableViewCell] = [restoreCell]
 	private lazy var restoreCells: [UITableViewCell] = [restoreCell]
@@ -563,6 +567,7 @@ extension AccountSetupController: UITextFieldDelegate {
 
 
 	func textFieldDidBeginEditing(_ textField: UITextField) {
 	func textFieldDidBeginEditing(_ textField: UITextField) {
 		if textField.accessibilityIdentifier == "emailTextField" {
 		if textField.accessibilityIdentifier == "emailTextField" {
+			loginButton.isEnabled = true
 			// this will re-enable possible oAuth2-login
 			// this will re-enable possible oAuth2-login
 			skipOauth = false
 			skipOauth = false
 		}
 		}
@@ -635,7 +640,7 @@ extension AccountSetupController {
 	func showProgressHud() {
 	func showProgressHud() {
 		configProgressAlert.actions[0].isEnabled = true
 		configProgressAlert.actions[0].isEnabled = true
 		configProgressAlert.title = "Configuring Account"
 		configProgressAlert.title = "Configuring Account"
-		configProgressAlert.message = "\n\n\n"
+		configProgressAlert.message = "\n\n\n"	// workaround to create space for progress indicator
 		configProgressIndicator.alpha = 1
 		configProgressIndicator.alpha = 1
 		configProgressIndicator.value = 0
 		configProgressIndicator.value = 0
 		present(configProgressAlert, animated: true, completion: nil)
 		present(configProgressAlert, animated: true, completion: nil)
@@ -653,6 +658,7 @@ extension AccountSetupController {
 		configProgressIndicator.alpha = 0
 		configProgressIndicator.alpha = 0
 		configProgressAlert.title = "Login Successful!"
 		configProgressAlert.title = "Login Successful!"
 		configProgressAlert.message = "You are ready to use Delta Chat."
 		configProgressAlert.message = "You are ready to use Delta Chat."
+		loginButton.isEnabled = dc_is_configured(mailboxPointer) == 0
 		DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
 		DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
 			self.configProgressAlert.dismiss(animated: true) {
 			self.configProgressAlert.dismiss(animated: true) {
 				self.handleLoginSuccess()
 				self.handleLoginSuccess()