From 30cad46ce7878e6931d52c9162a045c4bac50822 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Wed, 3 Apr 2024 12:44:04 +0200 Subject: [PATCH 1/5] Add button to open website in single tap --- DuckDuckGo/AutofillLoginDetailsView.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/AutofillLoginDetailsView.swift b/DuckDuckGo/AutofillLoginDetailsView.swift index ba9eee9654..974086714e 100644 --- a/DuckDuckGo/AutofillLoginDetailsView.swift +++ b/DuckDuckGo/AutofillLoginDetailsView.swift @@ -148,7 +148,10 @@ struct AutofillLoginDetailsView: View { actionTitle: UserText.autofillCopyPrompt(for: UserText.autofillLoginDetailsAddress), action: { viewModel.copyToPasteboard(.address) }, secondaryActionTitle: viewModel.websiteIsValidUrl ? UserText.autofillOpenWebsitePrompt : nil, - secondaryAction: viewModel.websiteIsValidUrl ? { viewModel.openUrl() } : nil) + secondaryAction: viewModel.websiteIsValidUrl ? { viewModel.openUrl() } : nil, + buttonImageName: "Globe-24", + buttonAccessibilityLabel: UserText.autofillOpenWebsitePrompt, + buttonAction: viewModel.websiteIsValidUrl ? { viewModel.openUrl() } : nil) } Section { From c40832774f4db3b334b7c05c962730cf3b2d25b4 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Wed, 3 Apr 2024 15:58:48 +0200 Subject: [PATCH 2/5] Add support for second button and add show / hide button to password field --- DuckDuckGo/AutofillLoginDetailsView.swift | 51 ++++++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/DuckDuckGo/AutofillLoginDetailsView.swift b/DuckDuckGo/AutofillLoginDetailsView.swift index 974086714e..18e78a0914 100644 --- a/DuckDuckGo/AutofillLoginDetailsView.swift +++ b/DuckDuckGo/AutofillLoginDetailsView.swift @@ -324,9 +324,12 @@ struct AutofillLoginDetailsView: View { action: { viewModel.isPasswordHidden.toggle() }, secondaryActionTitle: UserText.autofillCopyPrompt(for: UserText.autofillLoginDetailsPassword), secondaryAction: { viewModel.copyToPasteboard(.password) }, - buttonImageName: "Copy-24", - buttonAccessibilityLabel: UserText.autofillCopyPrompt(for: UserText.autofillLoginDetailsPassword), - buttonAction: { viewModel.copyToPasteboard(.password) }) + buttonImageName: viewModel.isPasswordHidden ? "Eye-24" : "Eye-Closed-24", + buttonAccessibilityLabel: viewModel.isPasswordHidden ? UserText.autofillShowPassword : UserText.autofillHidePassword, + buttonAction: { viewModel.isPasswordHidden.toggle() }, + secondaryButtonImageName: "Copy-24", + secondaryButtonAccessibilityLabel: UserText.autofillCopyPrompt(for: UserText.autofillLoginDetailsPassword), + secondaryButtonAction: { viewModel.copyToPasteboard(.password) }) } @@ -430,6 +433,10 @@ private struct CopyableCell: View { var buttonAccessibilityLabel: String? var buttonAction: (() -> Void)? + var secondaryButtonImageName: String? + var secondaryButtonAccessibilityLabel: String? + var secondaryButtonAction: (() -> Void)? + var body: some View { ZStack { HStack { @@ -455,7 +462,11 @@ private struct CopyableCell: View { } .padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 8)) - Spacer(minLength: buttonImageName != nil ? Constants.textFieldImageSize : 8) + if secondaryButtonImageName != nil { + Spacer(minLength: Constants.textFieldImageSize * 2) + } else { + Spacer(minLength: buttonImageName != nil ? Constants.textFieldImageSize : 8) + } } .copyable(isSelected: selectedCell == id, menuTitle: actionTitle, @@ -469,7 +480,7 @@ private struct CopyableCell: View { if let buttonImageName = buttonImageName, let buttonAccessibilityLabel = buttonAccessibilityLabel { let differenceBetweenImageSizeAndTapAreaPerEdge = (Constants.textFieldTapSize - Constants.textFieldImageSize) / 2.0 - HStack(alignment: .center) { + HStack(alignment: .center, spacing: 0) { Spacer() Button { @@ -495,6 +506,34 @@ private struct CopyableCell: View { .accessibilityLabel(buttonAccessibilityLabel) .contentShape(Rectangle()) .frame(width: Constants.textFieldTapSize, height: Constants.textFieldTapSize) + + if let secondaryButtonImageName = secondaryButtonImageName, + let secondaryButtonAccessibilityLabel = secondaryButtonAccessibilityLabel { + Button { + secondaryButtonAction?() + self.selectedCell = nil + } label: { + VStack(alignment: .trailing) { + Spacer() + HStack { + Spacer() + Image(secondaryButtonImageName) + .resizable() + .frame(width: Constants.textFieldImageSize, height: Constants.textFieldImageSize) + .foregroundColor(Color(UIColor.label).opacity(Constants.textFieldImageOpacity)) + .opacity(subtitle.isEmpty ? 0 : 1) + Spacer() + } + Spacer() + } + } + .buttonStyle(.plain) // Prevent taps from being forwarded to the container view + .background(BackgroundColor(isSelected: selectedCell == id).color) + .accessibilityLabel(secondaryButtonAccessibilityLabel) + .contentShape(Rectangle()) + .frame(width: Constants.textFieldTapSize, height: Constants.textFieldTapSize) + } + } .padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: -differenceBetweenImageSizeAndTapAreaPerEdge)) } @@ -598,7 +637,7 @@ private struct Constants { static let minRowHeight: CGFloat = 60 static let textFieldImageOpacity: CGFloat = 0.84 static let textFieldImageSize: CGFloat = 20 - static let textFieldTapSize: CGFloat = 44 + static let textFieldTapSize: CGFloat = 32 static let insets = EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16) } From 208fd3f272f8abf62a1ead235877c24a094ba9af Mon Sep 17 00:00:00 2001 From: amddg44 Date: Wed, 3 Apr 2024 17:20:05 +0200 Subject: [PATCH 3/5] Reduce hidden password length restriction so it is always limited to one line --- DuckDuckGo/AutofillLoginDetailsView.swift | 2 +- DuckDuckGo/PasswordHider.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/AutofillLoginDetailsView.swift b/DuckDuckGo/AutofillLoginDetailsView.swift index 18e78a0914..046ef2f986 100644 --- a/DuckDuckGo/AutofillLoginDetailsView.swift +++ b/DuckDuckGo/AutofillLoginDetailsView.swift @@ -463,7 +463,7 @@ private struct CopyableCell: View { .padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 8)) if secondaryButtonImageName != nil { - Spacer(minLength: Constants.textFieldImageSize * 2) + Spacer(minLength: Constants.textFieldImageSize * 2 + 8) } else { Spacer(minLength: buttonImageName != nil ? Constants.textFieldImageSize : 8) } diff --git a/DuckDuckGo/PasswordHider.swift b/DuckDuckGo/PasswordHider.swift index 4a91618fe6..1849248f24 100644 --- a/DuckDuckGo/PasswordHider.swift +++ b/DuckDuckGo/PasswordHider.swift @@ -22,7 +22,7 @@ import Foundation struct PasswordHider { let password: String var hiddenPassword: String { - let maximumPasswordDisplayCount = 40 + let maximumPasswordDisplayCount = 22 let passwordCount = password.count > maximumPasswordDisplayCount ? maximumPasswordDisplayCount : password.count return String(repeating: "•", count: passwordCount) } From 3b5e8bf4553c87ede7c34da2a7fc2988212c72eb Mon Sep 17 00:00:00 2001 From: amddg44 Date: Thu, 4 Apr 2024 11:14:20 +0200 Subject: [PATCH 4/5] Remove button icons background --- DuckDuckGo/AutofillLoginDetailsView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/DuckDuckGo/AutofillLoginDetailsView.swift b/DuckDuckGo/AutofillLoginDetailsView.swift index 046ef2f986..497c87207c 100644 --- a/DuckDuckGo/AutofillLoginDetailsView.swift +++ b/DuckDuckGo/AutofillLoginDetailsView.swift @@ -502,7 +502,6 @@ private struct CopyableCell: View { } } .buttonStyle(.plain) // Prevent taps from being forwarded to the container view - .background(BackgroundColor(isSelected: selectedCell == id).color) .accessibilityLabel(buttonAccessibilityLabel) .contentShape(Rectangle()) .frame(width: Constants.textFieldTapSize, height: Constants.textFieldTapSize) @@ -528,7 +527,6 @@ private struct CopyableCell: View { } } .buttonStyle(.plain) // Prevent taps from being forwarded to the container view - .background(BackgroundColor(isSelected: selectedCell == id).color) .accessibilityLabel(secondaryButtonAccessibilityLabel) .contentShape(Rectangle()) .frame(width: Constants.textFieldTapSize, height: Constants.textFieldTapSize) From 033ded998faaec26a387d0926755da713c3c35d0 Mon Sep 17 00:00:00 2001 From: amddg44 Date: Thu, 4 Apr 2024 17:26:50 +0200 Subject: [PATCH 5/5] Increase icon tappable area --- DuckDuckGo/AutofillLoginDetailsView.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/AutofillLoginDetailsView.swift b/DuckDuckGo/AutofillLoginDetailsView.swift index 497c87207c..1c6fd06be6 100644 --- a/DuckDuckGo/AutofillLoginDetailsView.swift +++ b/DuckDuckGo/AutofillLoginDetailsView.swift @@ -502,6 +502,8 @@ private struct CopyableCell: View { } } .buttonStyle(.plain) // Prevent taps from being forwarded to the container view + // can't use .clear here or else both button padded area and container both respond to tap events + .background(BackgroundColor(isSelected: selectedCell == id).color.opacity(0)) .accessibilityLabel(buttonAccessibilityLabel) .contentShape(Rectangle()) .frame(width: Constants.textFieldTapSize, height: Constants.textFieldTapSize) @@ -527,6 +529,7 @@ private struct CopyableCell: View { } } .buttonStyle(.plain) // Prevent taps from being forwarded to the container view + .background(BackgroundColor(isSelected: selectedCell == id).color.opacity(0)) .accessibilityLabel(secondaryButtonAccessibilityLabel) .contentShape(Rectangle()) .frame(width: Constants.textFieldTapSize, height: Constants.textFieldTapSize) @@ -634,8 +637,8 @@ private struct Constants { static let verticalPadding: CGFloat = 4 static let minRowHeight: CGFloat = 60 static let textFieldImageOpacity: CGFloat = 0.84 - static let textFieldImageSize: CGFloat = 20 - static let textFieldTapSize: CGFloat = 32 + static let textFieldImageSize: CGFloat = 24 + static let textFieldTapSize: CGFloat = 36 static let insets = EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16) }