Skip to content

Commit

Permalink
[Feat] #14 - state를 사용하여 상태변경에 따른 stroke 색상 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
yungu0010 committed Aug 30, 2024
1 parent e00ca96 commit e562c60
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import SwiftUI

struct PophoryTextFieldStyle: TextFieldStyle {
@Binding var isEmpty: Bool

func _body(configuration: TextField<Self._Label>) -> some View {
configuration
.padding(EdgeInsets(top: 19, leading: 15, bottom: 18, trailing: 18))
.fontWithLineHeightView(fontType: .text01Medium)
.overlay(
RoundedRectangle(cornerRadius: 18)
.stroke(.pryPurple, lineWidth: 1.0)
.stroke(isEmpty ? .gray300 : .pryPurple, lineWidth: 1.0)
)
.onAppear {
UITextField.appearance().clearButtonMode = .whileEditing
Expand All @@ -23,14 +25,16 @@ struct PophoryTextFieldStyle: TextFieldStyle {
}

struct PophoryTextField: View {
@State var text = ""
@State private var text: String = ""
let placeholder: String

var body: some View {
TextField("Hi...", text: $text)
.textFieldStyle(PophoryTextFieldStyle())
}
var body: some View {
TextField(placeholder, text: $text)
.textFieldStyle(PophoryTextFieldStyle(isEmpty: .constant(text.isEmpty))
)
}
}

#Preview {
PophoryTextField()
PophoryTextField(placeholder: "Enter")
}

0 comments on commit e562c60

Please sign in to comment.