Skip to content

Commit

Permalink
feat #394: 여행 생성 제목 글자수 제한
Browse files Browse the repository at this point in the history
  • Loading branch information
otoolz committed Jan 12, 2024
1 parent 9e84389 commit e2afd47
Showing 1 changed file with 11 additions and 0 deletions.
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,14 @@ 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 {
return false
}
return true
}
}

// MARK: - TLBottomSheetDelegate
Expand Down

0 comments on commit e2afd47

Please sign in to comment.