Skip to content

Commit

Permalink
merge #396: 여행생성시 제목 글자수 제한 작업
Browse files Browse the repository at this point in the history
[feat] 여행생성시 제목 글자수 제한 작업
  • Loading branch information
otoolz authored Jan 19, 2024
2 parents 7d57f44 + a8f46aa commit 2f7c047
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iOS/traveline/Sources/DesignSystem/View/TLToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class TLToastView: UIView {
translatesAutoresizingMaskIntoConstraints = false
alpha = 1.0
NSLayoutConstraint.activate([
bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -24),
bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor, constant: -24),
leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: Metric.margin),
trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -Metric.margin),
heightAnchor.constraint(equalToConstant: Metric.toastHeight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ final class TravelVC: UIViewController {
}

private enum Constants {
static let titleLimit: Int = 14
static let titleLimitToastMessage = "제목은 1 - 14자 이내만 가능합니다."
static let title: String = "여행 생성"
static let textFieldPlaceholder: String = "제목 *"
static let done: String = "완료"
Expand Down Expand Up @@ -144,6 +146,7 @@ final class TravelVC: UIViewController {

private extension TravelVC {
func setupAttributes() {
view.keyboardLayoutGuide.followsUndockedKeyboard = true
view.backgroundColor = TLColor.black
titleTextField.placeholder = Constants.textFieldPlaceholder
baseScrollView.delegate = self
Expand Down Expand Up @@ -354,6 +357,16 @@ extension TravelVC: UITextFieldDelegate {
dismissKeyboard()
return true
}

func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let text = textField.text ?? ""
if text.count + string.count > Constants.titleLimit {
let textLimitToast = TLToastView(type: .failure, message: Constants.titleLimitToastMessage)
textLimitToast.show(in: self.view)
return false
}
return true
}
}

// MARK: - TLBottomSheetDelegate
Expand Down

0 comments on commit 2f7c047

Please sign in to comment.