From c360809e730b68857fd3b32920cf506c8305fad1 Mon Sep 17 00:00:00 2001 From: Yigit Kerem Oktay Date: Thu, 30 Jan 2025 02:00:51 +0300 Subject: [PATCH 1/2] Create SettingSecureField.swift --- Sources/Views/SettingSecureField.swift | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Sources/Views/SettingSecureField.swift diff --git a/Sources/Views/SettingSecureField.swift b/Sources/Views/SettingSecureField.swift new file mode 100644 index 0000000..31b8bc4 --- /dev/null +++ b/Sources/Views/SettingSecureField.swift @@ -0,0 +1,59 @@ +// +// SettingSecureField.swift +// Setting +// +// Created by Yiğit Kerem Oktay on 30/1/2025. +// Copyright © 2025 The Skyfallen Company. All rights reserved. +// + +import SwiftUI + +/** + A text field. + */ +public struct SettingSecureField: View, Setting { + public var id: AnyHashable? + public var placeholder: String + @Binding public var text: String + public var verticalPadding = CGFloat(14) + public var horizontalPadding = CGFloat(16) + + public init( + id: AnyHashable? = nil, + placeholder: String, + text: Binding, + verticalPadding: CGFloat = CGFloat(14), + horizontalPadding: CGFloat = CGFloat(16) + ) { + self.id = id + self.placeholder = placeholder + self._text = text + self.verticalPadding = verticalPadding + self.horizontalPadding = horizontalPadding + } + + public var body: some View { + SettingSecureFieldView( + placeholder: placeholder, + text: $text, + verticalPadding: verticalPadding, + horizontalPadding: horizontalPadding + ) + } +} + +struct SettingSecureFieldView: View { + let placeholder: String + @Binding var text: String + + var verticalPadding = CGFloat(14) + var horizontalPadding = CGFloat(16) + + var body: some View { + SecureField(placeholder, text: $text) + .frame(maxWidth: .infinity, alignment: .leading) + .padding(.vertical, verticalPadding) + .padding(.horizontal, horizontalPadding) + .accessibilityElement(children: .combine) + } +} From f021b7ba9e73ba720c459d27913fab8dd8f13c34 Mon Sep 17 00:00:00 2001 From: Yigit Kerem Oktay Date: Thu, 30 Jan 2025 02:01:18 +0300 Subject: [PATCH 2/2] Update SettingView.swift --- Sources/Views/SettingView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/Views/SettingView.swift b/Sources/Views/SettingView.swift index 0c9e44a..1b8fd46 100644 --- a/Sources/Views/SettingView.swift +++ b/Sources/Views/SettingView.swift @@ -35,6 +35,8 @@ public struct SettingView: View { picker case let textField as SettingTextField: textField + case let secureField as SettingSecureField: + secureField case let page as SettingPage: if isPagePreview {