Adds Validation to NewsBlur and Feedbin Views

Disables add account button when username or password are empty.
This commit is contained in:
Stuart Breckenridge
2022-12-21 20:44:36 +08:00
parent f590fd1b7c
commit 12b17e3f36
2 changed files with 16 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ struct FeedbinAddAccountView: View {
Spacer()
}
}
.disabled(!validateCredentials())
}
}
@@ -110,6 +111,13 @@ struct FeedbinAddAccountView: View {
return Text("").multilineTextAlignment(.center)
}
private func validateCredentials() -> Bool {
if (accountEmail.trimmingWhitespace.count == 0) || (accountPassword.trimmingWhitespace.count == 0) {
return false
}
return true
}
private func retrieveCredentials() {
if let account = account {
do {

View File

@@ -116,6 +116,7 @@ struct NewsBlurAddAccountView: View, Logging {
Spacer()
}
}
.disabled(!validateCredentials())
}
}
@@ -127,6 +128,13 @@ struct NewsBlurAddAccountView: View, Logging {
return Text("").multilineTextAlignment(.center)
}
private func validateCredentials() -> Bool {
if (accountUserName.trimmingWhitespace.count == 0) || (accountPassword.trimmingWhitespace.count == 0) {
return false
}
return true
}
private func executeAccountCredentials() async throws {
let trimmedUsername = accountUserName.trimmingWhitespace