From 12b17e3f3601bc98d07191357a2865df739385a7 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Wed, 21 Dec 2022 20:44:36 +0800 Subject: [PATCH] Adds Validation to NewsBlur and Feedbin Views Disables add account button when username or password are empty. --- iOS/Account/FeedbinAddAccountView.swift | 8 ++++++++ iOS/Account/NewsBlurAddAccountView.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/iOS/Account/FeedbinAddAccountView.swift b/iOS/Account/FeedbinAddAccountView.swift index 0fac486cb..51db90293 100644 --- a/iOS/Account/FeedbinAddAccountView.swift +++ b/iOS/Account/FeedbinAddAccountView.swift @@ -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 { diff --git a/iOS/Account/NewsBlurAddAccountView.swift b/iOS/Account/NewsBlurAddAccountView.swift index 37a414d2a..f15387faf 100644 --- a/iOS/Account/NewsBlurAddAccountView.swift +++ b/iOS/Account/NewsBlurAddAccountView.swift @@ -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