Skip to content
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

๐Ÿ”จ [FIX] ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ธ€ ์ž‘์„ฑ/์ˆ˜์ • QA ๋Œ€์‘ #607

Merged
merged 4 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import RxSwift
class BaseWritePostVC: BaseVC {

// MARK: Properties
private let questionSV = UIScrollView()
let questionSV = UIScrollView()
private let disposeBag = DisposeBag()
private var questionTextViewLineCount: Int = 1
var questionTextViewLineCount: Int = 1
private var majorID: Int = MajorInfo.shared.selectedMajorID ?? UserDefaults.standard.value(forKey: UserDefaults.Keys.FirstMajorID) as! Int

let questionWriteNaviBar = NadoSunbaeNaviBar().then {
Expand Down Expand Up @@ -172,6 +172,7 @@ extension BaseWritePostVC {
}

/// textView์˜ ์ƒํƒœ์— ๋”ฐ๋ผ ์Šคํฌ๋กค๋ทฐ๋ฅผ Up, Down ํ•˜๋Š” ๋ฉ”์„œ๋“œ
@objc
func scollByTextViewState(textView: UITextView) {
var contentOffsetY = questionSV.contentOffset.y
var isLineAdded = true
Expand Down Expand Up @@ -201,6 +202,11 @@ extension BaseWritePostVC {
}
questionTextViewLineCount = textView.numberOfLines()
}

/// questionWriteNaviBar์˜ rightActivateBtn์˜ ํ™œ์„ฑ์ƒํƒœ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ
func setNaviBarRightActivateState(isActivated: Bool) {
questionWriteNaviBar.rightActivateBtn.isActivated = isActivated
}
}

// MARK: - Keyboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class WriteQuestionVC: BaseWritePostVC {
setUpAlertMsgByEditState()
setHighlightViewState(textField: questionTitleTextField, highlightView: textHighlightView)
setActivateBtnState(textField: questionTitleTextField, textView: questionWriteTextView)
setNaviBarRightActivateState(isActivated: false)
}
}

Expand All @@ -47,7 +48,6 @@ extension WriteQuestionVC {
questionWriteTextView.setDefaultStyle(isUsePlaceholder: false, placeholderText: "")
questionTitleTextField.text = originTitle
questionWriteTextView.text = originContent
questionWriteNaviBar.rightActivateBtn.isActivated = true
} else {
questionWriteTextView.setDefaultStyle(isUsePlaceholder: true, placeholderText: "์„ ๋ฐฐ์—๊ฒŒ 1:1 ์งˆ๋ฌธ์„ ๋‚จ๊ฒจ๋ณด์„ธ์š”.\n์„ ๋ฐฐ๊ฐ€ ๋‹ต๋ณ€ํ•ด ์ค„ ๊ฑฐ์—์š”!")
}
Expand Down Expand Up @@ -81,9 +81,11 @@ extension WriteQuestionVC {
}

/// dismissBtn Press
questionWriteNaviBar.dismissBtn.press {
questionWriteNaviBar.dismissBtn.press { [weak self] in
guard let self = self else { return }

guard let alert = Bundle.main.loadNibNamed(NadoAlertVC.className, owner: self, options: nil)?.first as? NadoAlertVC else { return }
alert.showNadoAlert(vc: self, message: self.dismissAlertMsg, confirmBtnTitle: "๊ณ„์† ์ž‘์„ฑ", cancelBtnTitle: "๋‚˜๊ฐˆ๋ž˜์š”")
alert.showNadoAlert(vc: self, message: self.dismissAlertMsg, confirmBtnTitle: self.isEditState ? "๊ณ„์† ์ˆ˜์ •" : "๊ณ„์† ์ž‘์„ฑ", cancelBtnTitle: "๋‚˜๊ฐˆ๋ž˜์š”")
alert.cancelBtn.press {
self.dismiss(animated: true, completion: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ final class CommunityWriteVC: BaseWritePostVC, View {
setUpCategoryCVByEditState()
setHighlightViewState(textField: questionTitleTextField, highlightView: textHighlightView)
setActivateBtnState(textField: questionTitleTextField, textView: questionWriteTextView)
setNaviBarRightActivateState(isActivated: false)
}

func bind(reactor: CommunityWriteReactor) {
Expand All @@ -93,7 +94,7 @@ extension CommunityWriteVC {
contentView.addSubviews([selectMajorLabel, majorSelectTextField, majorSelectBtn, categoryLabel, categoryCV, questionDescLabel, partitionBar])

selectMajorLabel.snp.makeConstraints {
$0.top.equalTo(questionWriteNaviBar.snp.bottom).offset(24)
$0.top.equalToSuperview().offset(24)
$0.leading.equalToSuperview().offset(24)
}

Expand Down Expand Up @@ -168,25 +169,30 @@ extension CommunityWriteVC {
.disposed(by: disposeBag)

questionWriteNaviBar.rightActivateBtn.rx.tap
.subscribe(onNext: {
self.nadoAlert?.showNadoAlert(vc: self, message: self.confirmAlertMsg, confirmBtnTitle: "๋„ค", cancelBtnTitle: "์•„๋‹ˆ์š”")
.subscribe(onNext: { [weak self] in
guard let self = self else { return }

guard let alert = Bundle.main.loadNibNamed(NadoAlertVC.className, owner: self, options: nil)?.first as? NadoAlertVC else { return }
alert.showNadoAlert(vc: self, message: self.confirmAlertMsg, confirmBtnTitle: "๋„ค", cancelBtnTitle: "์•„๋‹ˆ์š”")
alert.confirmBtn.press {
if self.isEditState {
reactor.action.onNext(.tapQuestionEditBtn(postID: self.postID ?? 0, title: self.questionTitleTextField.text ?? "", content: self.questionWriteTextView.text ?? ""))
} else {
reactor.action.onNext(.tapQuestionWriteBtn(type: self.selectedCategory, majorID: self.majorID ?? MajorIDConstants.regardlessMajorID, answererID: 0, title: self.questionTitleTextField.text ?? "", content: self.questionWriteTextView.text))
}
}
})
.disposed(by: disposeBag)

nadoAlert?.confirmBtn.rx.tap.map{
if self.isEditState {
return CommunityWriteReactor.Action.tapQuestionEditBtn(postID: self.postID ?? 0, title: self.questionTitleTextField.text ?? "", content: self.questionWriteTextView.text ??
"")
} else {
return CommunityWriteReactor.Action.tapQuestionWriteBtn(type: self.selectedCategory, majorID: self.majorID ?? MajorIDConstants.regardlessMajorID, answererID: 0, title: self.questionTitleTextField.text ?? "", content: self.questionWriteTextView.text)
}
}
.bind(to: reactor.action)
.disposed(by: disposeBag)

questionWriteNaviBar.dismissBtn.rx.tap
.subscribe(onNext: {
self.nadoAlert?.showNadoAlert(vc: self, message: self.dismissAlertMsg, confirmBtnTitle: "๊ณ„์† ์ž‘์„ฑ", cancelBtnTitle: "๋‚˜๊ฐˆ๋ž˜์š”")
.subscribe(onNext: { [weak self] in
guard let self = self else { return }

guard let alert = Bundle.main.loadNibNamed(NadoAlertVC.className, owner: self, options: nil)?.first as? NadoAlertVC else { return }
alert.showNadoAlert(vc: self, message: self.dismissAlertMsg, confirmBtnTitle: self.isEditState ? "๊ณ„์† ์ˆ˜์ •" : "๊ณ„์† ์ž‘์„ฑ", cancelBtnTitle: "๋‚˜๊ฐˆ๋ž˜์š”")
alert.cancelBtn.press {
self.dismiss(animated: true, completion: nil)
}
})
.disposed(by: disposeBag)

Expand Down Expand Up @@ -314,6 +320,36 @@ extension CommunityWriteVC {
slideVC.selectCommunityDelegate = self
self.present(slideVC, animated: true)
}

override func scollByTextViewState(textView: UITextView) {
var contentOffsetY = questionSV.contentOffset.y
var isLineAdded = true

if questionTextViewLineCount != textView.numberOfLines() {

if questionTextViewLineCount > textView.numberOfLines() {
isLineAdded = false
} else {
isLineAdded = true
}

if isLineAdded && textView.numberOfLines() > 2 && questionSV.contentOffset.y < 193 {
contentOffsetY += 38
questionSV.setContentOffset(CGPoint(x: 0, y: contentOffsetY), animated: true)

} else if !isLineAdded && questionTextViewLineCount < 9 && questionSV.contentOffset.y > 0 {

if contentOffsetY - 38 > 0 {
contentOffsetY -= 38
questionSV.setContentOffset(CGPoint(x: 0, y: contentOffsetY), animated: true)
} else {
contentOffsetY = 0
questionSV.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
Comment on lines +336 to +347
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ถ„๋…ธ์˜ ๋ถ„๊ธฐ์ฒ˜๋ฆฌ๊ฐ€ ๋Š๊ปด์ง„๋‹น

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์‚ฌ์‹ค ๋ฐ˜๋…„๋„ ๋” ์ „์—.. ์ง  ์ฝ”๋“ ๋ฐ overrideํ•˜๋ฉด์„œ ๊ฐ€์ ธ์˜ดใ…‹ใ…‹ใ…‹ใ…Žใ…‹ใ…Žใ…‹ใ…Ž

}
}
}
questionTextViewLineCount = textView.numberOfLines()
}
}

// MARK: - UICollectionViewDelegateFlowLayout
Expand Down Expand Up @@ -355,6 +391,10 @@ extension CommunityWriteVC: UITextViewDelegate {
textView.text = nil
textView.textColor = .mainText
}

UIView.animate(withDuration: 0.5) { [weak self] in
self?.questionSV.contentOffset.y = 193
}
}

/// textViewDidChange
Expand Down