-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] #265 - fastlane & 유저 QA 진행 #267
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d3ac4b7
[Fix] #265 - fix gitignore for fastlane
thingineeer 794a550
[Fix] #265 - AppStore lane 구축
thingineeer 59a7da7
[Fix] #265 - 수정하는 닉네임이 중복일때 예외처리
thingineeer b7f0d3e
[Feat] #265 - Toast 메세지 Height 기능 추가
thingineeer 1b638cb
[Chore] #265 - addSubviews 함수 파라미터 줄 바꿈 적용
thingineeer 3ad2e31
[Feat] #265 - 코스 업로드 업로드 버튼 활성화 로직 수정
thingineeer 922e685
[Fix] #265 - 중복 코드 제거 & 유저 편의성 개선
thingineeer 040f837
[Setting] #265 - release 2.0.3
thingineeer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ class CourseUploadVC: UIViewController { | |
} | ||
private let distanceInfoView = CourseDetailInfoView(title: "거리", description: "0.0km") | ||
private let departureInfoView = CourseDetailInfoView(title: "출발지", description: "") | ||
private let placeholder = "코스에 대한 소개를 적어주세요.(난이도/풍경/지형)" | ||
private let placeholder = "코스에 대한 소개를 적어주세요.(난이도/풍경/지형)\n(최대 150자)" | ||
|
||
let activityTextView = UITextView().then { | ||
$0.font = .b4 | ||
|
@@ -61,11 +61,10 @@ class CourseUploadVC: UIViewController { | |
setNavigationBar() | ||
setUI() | ||
setLayout() | ||
setupTextView() | ||
setDelegate() | ||
setAddTarget() | ||
setKeyboardNotification() | ||
setTapGesture() | ||
addKeyboardObserver() | ||
setKeyboardObservers() | ||
analyze(screenName: GAEvent.View.viewCourseUpload) | ||
} | ||
|
||
|
@@ -107,29 +106,21 @@ extension CourseUploadVC { | |
self.uploadButton.addTarget(self, action: #selector(uploadButtonDidTap), for: .touchUpInside) | ||
} | ||
|
||
// 키보드가 올라오면 scrollView 위치 조정 | ||
private func setKeyboardNotification() { | ||
NotificationCenter.default.addObserver( | ||
self, | ||
selector: #selector(keyboardWillShow), | ||
name: UIResponder.keyboardWillShowNotification, | ||
object: nil) | ||
|
||
NotificationCenter.default.addObserver( | ||
self, | ||
selector: #selector(keyboardWillHide), | ||
name: UIResponder.keyboardWillHideNotification, | ||
object: nil) | ||
} | ||
|
||
// 화면 터치 시 키보드 내리기 | ||
private func setTapGesture() { | ||
let tap = UITapGestureRecognizer(target: view, action: #selector(UIView.endEditing)) | ||
tap.cancelsTouchesInView = false | ||
view.addGestureRecognizer(tap) | ||
} | ||
|
||
private func addKeyboardObserver() { | ||
// 업로드 버튼 상태 업데이트 메소드 | ||
private func updateUploadButtonState() { | ||
let isTitleNotEmpty = !(courseTitleTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ?? true) | ||
let isContentNotEmptyAndNotPlaceholder = !(activityTextView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || activityTextView.text == placeholder) | ||
uploadButton.setEnabled(isTitleNotEmpty && isContentNotEmptyAndNotPlaceholder) | ||
} | ||
|
||
private func setKeyboardObservers() { | ||
NotificationCenter.default.addObserver( | ||
self, | ||
selector: #selector(keyboardWillShow), | ||
|
@@ -146,19 +137,7 @@ extension CourseUploadVC { | |
|
||
extension CourseUploadVC { | ||
@objc private func textFieldTextDidChange() { | ||
guard let text = courseTitleTextField.text else { return } | ||
|
||
if text.count > courseTitleMaxLength { | ||
let index = text.index(text.startIndex, offsetBy: courseTitleMaxLength) | ||
let newString = text[text.startIndex..<index] | ||
self.courseTitleTextField.text = String(newString) | ||
} | ||
|
||
if text.count == 0 && activityTextView.text != self.placeholder && activityTextView.text.count == 0 { | ||
uploadButton.setEnabled(true) | ||
} else { | ||
uploadButton.setEnabled(false) | ||
} | ||
updateUploadButtonState() | ||
} | ||
|
||
@objc private func keyboardWillShow(_ notification: Notification) { | ||
|
@@ -175,11 +154,12 @@ extension CourseUploadVC { | |
scrollView.contentInset = contentInset | ||
scrollView.scrollIndicatorInsets = contentInset | ||
|
||
if activityTextView.isFirstResponder { | ||
// scrollView 높이 설정 | ||
if courseTitleTextField.isFirstResponder || activityTextView.isFirstResponder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. textView 누를때도 position 조정하신거 좋네요 !!! |
||
let contentViewHeight = scrollView.contentSize.height | ||
let textViewHeight = activityTextView.frame.height | ||
let textViewOffsetY = contentViewHeight - (contentInset.bottom + textViewHeight) | ||
let position = CGPoint(x: 0, y: textViewOffsetY + 100) | ||
let position = CGPoint(x: 0, y: textViewOffsetY + 50) | ||
scrollView.setContentOffset(position, animated: true) | ||
return | ||
} | ||
|
@@ -198,28 +178,29 @@ extension CourseUploadVC { | |
} | ||
} | ||
|
||
// MARK: - naviVar Layout | ||
|
||
extension CourseUploadVC { | ||
|
||
// MARK: - naviVar Layout | ||
|
||
private func setNavigationBar() { | ||
view.addSubview(navibar) | ||
navibar.snp.makeConstraints { | ||
$0.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) | ||
$0.height.equalTo(48) | ||
} | ||
} | ||
// MARK: - setUI | ||
// MARK: - UI & Layout | ||
|
||
private func setUI() { | ||
view.backgroundColor = .w1 | ||
scrollView.backgroundColor = .clear | ||
buttonContainerView.backgroundColor = .w1 | ||
mapImageView.backgroundColor = .systemGray4 | ||
|
||
activityTextView.text = placeholder | ||
activityTextView.textColor = .g3 | ||
} | ||
|
||
// MARK: - Layout Helpers | ||
|
||
private func setLayout() { | ||
view.addSubview(buttonContainerView) | ||
view.bringSubviewToFront(uploadButton) | ||
|
@@ -241,14 +222,15 @@ extension CourseUploadVC { | |
|
||
private func setScrollViewLayout() { | ||
view.addSubview(scrollView) | ||
[mapImageView, | ||
courseTitleTextField, | ||
dividerView, | ||
distanceInfoView, | ||
departureInfoView, | ||
activityTextView].forEach { | ||
scrollView.addSubview($0) | ||
} | ||
|
||
scrollView.addSubviews( | ||
mapImageView, | ||
courseTitleTextField, | ||
dividerView, | ||
distanceInfoView, | ||
departureInfoView, | ||
activityTextView | ||
) | ||
|
||
scrollView.snp.makeConstraints { | ||
$0.top.equalTo(navibar.snp.bottom) | ||
|
@@ -294,13 +276,14 @@ extension CourseUploadVC { | |
} | ||
} | ||
|
||
func setupTextView() { | ||
func setDelegate() { | ||
activityTextView.delegate = self | ||
activityTextView.text = placeholder | ||
activityTextView.textColor = .g3 | ||
courseTitleTextField.delegate = self | ||
} | ||
} | ||
|
||
// MARK: - UITextViewDelegate | ||
|
||
extension CourseUploadVC: UITextViewDelegate { | ||
func textViewDidBeginEditing(_ textView: UITextView) { | ||
if textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { | ||
|
@@ -314,16 +297,13 @@ extension CourseUploadVC: UITextViewDelegate { | |
} | ||
|
||
func textViewDidChange(_ textView: UITextView) { | ||
if !courseTitleTextField.isEmpty && !activityTextView.text.isEmpty { | ||
uploadButton.setEnabled(true) | ||
} else { | ||
uploadButton.setEnabled(false) | ||
} | ||
updateUploadButtonState() | ||
|
||
if activityTextView.text.count > 150 { | ||
activityTextView.deleteBackward() | ||
} | ||
} | ||
|
||
func textViewDidEndEditing(_ textView: UITextView) { | ||
if textView.text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || textView.text == placeholder { | ||
activityTextView.textColor = .g3 | ||
|
@@ -332,6 +312,18 @@ extension CourseUploadVC: UITextViewDelegate { | |
} | ||
} | ||
|
||
// MARK: - UITextFieldDelegate | ||
|
||
extension CourseUploadVC: UITextFieldDelegate { | ||
func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
if textField == courseTitleTextField { | ||
activityTextView.becomeFirstResponder() | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
|
||
// MARK: - Network | ||
|
||
extension CourseUploadVC { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
업데이트 메소드 따로 빼둔거 확인했습니다~
textfield랑 textview 모두 개행 문자를 제거했을때 글자가 있고, 그 글자가 placeholder와 다른 경우 업로드 버튼 활성화로 이해했는데 맞을까요 ?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요!
코드를 조금 해석해보자면,
예를 들어
제목
같은 경우 text 가 nil 이면 !true를 리턴하여 최종적으로 false가 됩니다.text가 있다면 텍스트 가 있기때문에 항상 !false 즉 최종적으로 true가 됩니다.
내용
같은 경우도 개행문자 제거했을 때 activityTextView가 비어있거나 || 플레이스 홀더 텍스트와 같은지 검사하여필드가 비어있지 않고, 플레이스 홀더와 다를 경우 true 그렇지 않으면 false를 리턴합니다!