From 841da2d570eaaf5a39dbecd7f62c0da4dd91e8f1 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Sun, 6 Dec 2020 08:00:34 +0800 Subject: [PATCH] show/hide password when signing up --- .../AddFeedlyViewModel.swift | 1 - .../AddNewsBlurViewModel.swift | 1 + .../AddFeedWranglerAccountView.swift | 27 ++++++++++++++++++- .../AddNewsBlurAccountView.swift | 27 ++++++++++++++++++- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift b/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift index 7a1d983e0..e2e784459 100644 --- a/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift +++ b/Multiplatform/Shared/Add/Add Account Models/AddFeedlyViewModel.swift @@ -18,7 +18,6 @@ class AddFeedlyViewModel: ObservableObject, OAuthAccountAuthorizationOperationDe @Published var showError: Bool = false @Published var username: String = "" @Published var password: String = "" - @Published var showPassword: Bool = false func authenticateFeedly() { isAuthenticating = true diff --git a/Multiplatform/Shared/Add/Add Account Models/AddNewsBlurViewModel.swift b/Multiplatform/Shared/Add/Add Account Models/AddNewsBlurViewModel.swift index 5e6fee54e..96f58b78f 100644 --- a/Multiplatform/Shared/Add/Add Account Models/AddNewsBlurViewModel.swift +++ b/Multiplatform/Shared/Add/Add Account Models/AddNewsBlurViewModel.swift @@ -19,6 +19,7 @@ class AddNewsBlurViewModel: ObservableObject, AddAccountSignUp { @Published var username: String = "" @Published var password: String = "" @Published var canDismiss: Bool = false + @Published var showPassword: Bool = false func authenticateNewsBlur() { isAuthenticating = true diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift index a97780878..7ec1390ab 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddFeedWranglerAccountView.swift @@ -34,7 +34,32 @@ struct AddFeedWranglerAccountView: View { .scaleEffect(CGSize(width: 0.5, height: 0.5)) .hidden(!model.isAuthenticating) , content: { TextField("me@email.com", text: $model.username) - SecureField("•••••••••••", text: $model.password) + if model.showPassword == false { + ZStack { + HStack { + SecureField("Password", text: $model.password) + Spacer() + Image(systemName: "eye.fill") + .foregroundColor(.accentColor) + .onTapGesture { + model.showPassword = true + } + } + } + } + else { + ZStack { + HStack { + TextField("Password", text: $model.password) + Spacer() + Image(systemName: "eye.slash.fill") + .foregroundColor(.accentColor) + .onTapGesture { + model.showPassword = false + } + } + } + } }) }.navigationBarItems(leading: Button(action: { diff --git a/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift b/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift index 5fe3ca937..f6b25df25 100644 --- a/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift +++ b/Multiplatform/Shared/Add/Add Account Sheets/AddNewsBlurAccountView.swift @@ -32,7 +32,32 @@ struct AddNewsBlurAccountView: View { .scaleEffect(CGSize(width: 0.5, height: 0.5)) .hidden(!model.isAuthenticating) , content: { TextField("me@email.com", text: $model.username) - SecureField("•••••••••••", text: $model.password) + if model.showPassword == false { + ZStack { + HStack { + SecureField("Password", text: $model.password) + Spacer() + Image(systemName: "eye.fill") + .foregroundColor(.accentColor) + .onTapGesture { + model.showPassword = true + } + } + } + } + else { + ZStack { + HStack { + TextField("Password", text: $model.password) + Spacer() + Image(systemName: "eye.slash.fill") + .foregroundColor(.accentColor) + .onTapGesture { + model.showPassword = false + } + } + } + } }) }.navigationBarItems(leading: Button(action: {