Skip to content

Commit

Permalink
[Chore] #32 - alertDelegate를 프로토콜로 타입 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Dec 8, 2022
1 parent 1fa73df commit 97d1b79
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public enum TextFieldAlertType {
}
}

public protocol CustomTextFieldViewAlertDelegate: AnyObject {
func changeAlertLabelText(_ alertText: String)
}

public class CustomTextFieldView: UIView {

// MARK: - Properties
Expand Down Expand Up @@ -139,7 +143,7 @@ public class CustomTextFieldView: UIView {
}

/// alert Label을 다른 CustomTextField에 보여주기 위한 delegate
weak var alertDelegate: CustomTextFieldView?
weak var alertDelegate: CustomTextFieldViewAlertDelegate?

private var cancelBag = CancelBag()

Expand Down Expand Up @@ -238,7 +242,7 @@ extension CustomTextFieldView {
}

/// alertText를 다른 TextField에 보여주기 위한 delegate 설정
public func setAlertDelegate(_ textView: CustomTextFieldView) -> Self {
public func setAlertDelegate(_ textView: CustomTextFieldViewAlertDelegate) -> Self {
self.alertDelegate = textView
return self
}
Expand All @@ -253,11 +257,6 @@ extension CustomTextFieldView {
self.alertlabel.isHidden = false
}

/// 경고 문구 라벨의 컬러 설정
public func changeAlertLabelTextColor(toWarning: Bool) {
alertlabel.textColor = toWarning ? SoptampColor.error300.color : SoptampColor.access300.color
}

/// textField의 state를 지정하여 자동으로 배경색과 테두리 색이 바뀌도록 설정
public func setTextFieldViewState(_ state: TextFieldViewState) {
textFieldContainerView.backgroundColor = state.backgroundColor
Expand Down Expand Up @@ -479,3 +478,12 @@ extension CustomTextFieldView: UITextFieldDelegate {
}
}
}

// MARK: - CustomTextFieldViewAlertDelegate

extension CustomTextFieldView: CustomTextFieldViewAlertDelegate {
/// 경고 문구 라벨의 컬러 설정
public func changeAlertLabelTextColor(toWarning: Bool) {
alertlabel.textColor = toWarning ? SoptampColor.error300.color : SoptampColor.access300.color
}
}

0 comments on commit 97d1b79

Please sign in to comment.