From 42f064c3c4fb2f8bdf792e4dde29cd2871c54d9c Mon Sep 17 00:00:00 2001 From: HongSJae Date: Fri, 26 Apr 2024 19:57:59 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20::=20onSuccess=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Shared/ViewUtil/Sources/View+onSuccess.swift | 9 ++++++--- .../DesignSystem/Sources/TextField/KGTextField.swift | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Projects/Shared/ViewUtil/Sources/View+onSuccess.swift b/Projects/Shared/ViewUtil/Sources/View+onSuccess.swift index b882839..75f369f 100644 --- a/Projects/Shared/ViewUtil/Sources/View+onSuccess.swift +++ b/Projects/Shared/ViewUtil/Sources/View+onSuccess.swift @@ -1,8 +1,11 @@ import SwiftUI public extension View { - func onSuccess(of value: Bool, _ action: () -> Void) -> some View { - if value { action() } - return self + func onSuccess(of value: Bool, _ action: @escaping () -> Void) -> some View { + self.onChange(of: value) { changedValue in + if changedValue { + action() + } + } } } diff --git a/Projects/UserInterface/DesignSystem/Sources/TextField/KGTextField.swift b/Projects/UserInterface/DesignSystem/Sources/TextField/KGTextField.swift index cea365c..9e19534 100644 --- a/Projects/UserInterface/DesignSystem/Sources/TextField/KGTextField.swift +++ b/Projects/UserInterface/DesignSystem/Sources/TextField/KGTextField.swift @@ -69,6 +69,9 @@ public struct KGTextField: View { lineWidth: 1 ) } + .onTapGesture { + self.isFocused = true + } if !description.isEmpty || isErrorAndNotEmpty { Text(isErrorAndNotEmpty ? errorMessage : description)