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

✨ [FEAT] 과방탭 질문 메인뷰 디자인 수정사항 대응 #254

Merged
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 @@ -10,29 +10,12 @@ import UIKit
class QuestionHeaderTVC: BaseTVC {

// MARK: Properties
private let headerTitleLabel = UILabel().then {
$0.text = "구성원 모두가 답할 수 있어요!"
$0.textColor = .mainDefault
$0.font = .PretendardR(size: 14.0)
$0.sizeToFit()
}

private let questionWriteBtn = UIButton().then {
$0.setBackgroundImage(UIImage(named: "btnWrite"), for: .normal)
$0.setBackgroundImage(UIImage(named: "goToQuestion"), for: .normal)
$0.contentMode = .scaleAspectFill
}
var tapWriteBtnAction : (() -> ())?

// MARK: Life Cycle
override func awakeFromNib() {
super.awakeFromNib()
}

override func layoutSubviews() {
super.layoutSubviews()
contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 12, left: 16, bottom: 11, right: 16))
}

// MARK: init
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
Expand All @@ -50,20 +33,14 @@ class QuestionHeaderTVC: BaseTVC {
// MARK: - UI
extension QuestionHeaderTVC {
private func configureUI() {
contentView.addSubviews([headerTitleLabel, questionWriteBtn])
contentView.addSubview(questionWriteBtn)

questionWriteBtn.snp.makeConstraints {
$0.trailing.equalToSuperview()
$0.height.equalTo(36)
$0.width.equalTo(104)
$0.trailing.equalTo(contentView).offset(-8)
$0.height.equalTo(36.adjustedH)
$0.width.equalTo(104.adjusted)
$0.centerY.equalTo(contentView)
}

headerTitleLabel.snp.makeConstraints {
$0.leading.equalToSuperview()
$0.trailing.equalTo(questionWriteBtn.snp.leading).offset(-30)
$0.centerY.equalTo(questionWriteBtn)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,38 @@ class QuestionMainVC: BaseVC {
$0.isScrollEnabled = true
}
private let contentView = UIView()
private let personalQuestionBtn = UIButton().then {
$0.setBackgroundImage(UIImage(named: "imgRoomMain"), for: .normal)
$0.contentMode = .scaleToFill
private let personalQuestionLabel = UILabel().then {
$0.text = "선배에게 1:1 개인 질문"
$0.textColor = .black
$0.font = .PretendardM(size: 16.0)
$0.sizeToFit()
}

private let whiteBoardView = UIView().then {
$0.backgroundColor = .white
$0.layer.borderWidth = 1
$0.layer.borderColor = UIColor.gray0.cgColor
$0.makeRounded(cornerRadius: 16)
}

private let questionBoardImgView = UIImageView().then {
$0.image = UIImage(named: "imgRoomMain")
}

private let findSunbaeImgView = UIImageView().then {
$0.image = UIImage(named: "findSunbae")
}

private let findSunbaeEntireBtn = UIButton()
private let entireQuestionTitleLabel = UILabel().then {
$0.text = "전체에게 질문"
$0.text = "선배 전체에게 질문"
$0.textColor = .black
$0.font = .PretendardM(size: 16.0)
$0.sizeToFit()
}

private let entireQuestionTV = UITableView().then {
$0.layer.cornerRadius = 8
$0.layer.cornerRadius = 16
$0.layer.borderWidth = 1
$0.layer.borderColor = UIColor.gray0.cgColor
$0.isScrollEnabled = false
Expand All @@ -49,13 +67,13 @@ class QuestionMainVC: BaseVC {
setUpDelegate()
setUpTapInfoBtn()
registerCell()
setUpTapPersonalQuestionBtn()
setUpTapFindSunbaeBtn()
addActivateIndicator()
setUpRequestData()
NotificationCenter.default.addObserver(self, selector: #selector(updateDataBySelectedMajor), name: Notification.Name.dismissHalfModal, object: nil)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
override func viewDidAppear(_ animated: Bool) {
setUpRequestData()
Copy link
Member

Choose a reason for hiding this comment

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

요것이 그부분인가보네....

}
}
Expand All @@ -65,10 +83,10 @@ extension QuestionMainVC {

/// 전체 UI를 구성하는 메서드
private func configureUI() {

view.addSubview(questionSV)
questionSV.addSubview(contentView)
contentView.addSubviews([questionSegmentView, personalQuestionBtn, entireQuestionTitleLabel, entireQuestionTV])
contentView.addSubviews([questionSegmentView, personalQuestionLabel, whiteBoardView, questionBoardImgView, findSunbaeImgView, findSunbaeEntireBtn, entireQuestionTitleLabel, entireQuestionTV])

questionSV.snp.makeConstraints {
$0.top.leading.trailing.bottom.equalToSuperview()
Expand All @@ -86,24 +104,48 @@ extension QuestionMainVC {
$0.height.equalTo(38.adjustedH)
}

personalQuestionBtn.snp.makeConstraints {
personalQuestionLabel.snp.makeConstraints {
$0.top.equalTo(questionSegmentView.snp.bottom).offset(16)
$0.leading.equalToSuperview().offset(24)
$0.height.equalTo(19)
}

whiteBoardView.snp.makeConstraints {
$0.top.equalTo(personalQuestionLabel.snp.bottom).offset(16)
$0.leading.equalToSuperview().offset(24)
$0.trailing.equalToSuperview().offset(-24)
$0.height.equalTo(176.adjustedH)
$0.height.equalTo(188.adjustedH)
$0.width.equalTo(327.adjustedH)
$0.centerX.equalToSuperview()
}

questionBoardImgView.snp.makeConstraints {
$0.leading.trailing.equalTo(whiteBoardView)
$0.bottom.equalTo(whiteBoardView.snp.bottom)
$0.height.equalTo(144.adjustedH)
$0.centerX.equalToSuperview()
}

findSunbaeImgView.snp.makeConstraints {
$0.top.equalTo(whiteBoardView.snp.top).offset(4)
$0.trailing.equalTo(whiteBoardView.snp.trailing).offset(-8)
$0.width.equalTo(104.adjusted)
$0.height.equalTo(36.adjustedH)
}

findSunbaeEntireBtn.snp.makeConstraints {
$0.top.leading.trailing.bottom.equalTo(whiteBoardView)
}

entireQuestionTitleLabel.snp.makeConstraints {
$0.top.equalTo(personalQuestionBtn.snp.bottom).offset(24)
$0.leading.equalTo(personalQuestionBtn)
$0.top.equalTo(whiteBoardView.snp.bottom).offset(40)
$0.leading.equalTo(whiteBoardView)
$0.height.equalTo(19)
}

entireQuestionTV.snp.makeConstraints {
$0.top.equalTo(entireQuestionTitleLabel.snp.bottom).offset(16)
$0.leading.trailing.equalTo(personalQuestionBtn)
$0.leading.trailing.equalTo(whiteBoardView)
$0.height.equalTo(236)
$0.bottom.equalToSuperview().offset(-24)
}
Expand Down Expand Up @@ -149,8 +191,8 @@ extension QuestionMainVC {
}

/// 질문가능선배Btn tap Action 설정 메서드
private func setUpTapPersonalQuestionBtn() {
personalQuestionBtn.press(vibrate: true) {
private func setUpTapFindSunbaeBtn() {
findSunbaeEntireBtn.press(vibrate: true) {
let questionPersonVC = QuestionPersonListVC()
questionPersonVC.majorID = MajorInfo.shared.selectedMajorID ?? UserDefaults.standard.value(forKey: UserDefaults.Keys.FirstMajorID) as! Int
self.navigationController?.pushViewController(questionPersonVC, animated: true)
Expand All @@ -173,6 +215,17 @@ extension QuestionMainVC {
activityIndicator.center = CGPoint(x: self.view.center.x, y: view.center.y - 106)
view.addSubview(self.activityIndicator)
}

/// entireQuestionTV 업데이트 메서드
private func updateEntireQuestionTV() {
DispatchQueue.main.async {
self.entireQuestionTV.reloadData()
self.entireQuestionTV.layoutIfNeeded()
Copy link
Member

Choose a reason for hiding this comment

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

요기 layoutIfNeeded() 이후에 automaticDimension 다시 호출해도 안됏어? ㅠ

Copy link
Member Author

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.

ㅠㅠ 안된다 ~~

Copy link
Member Author

Choose a reason for hiding this comment

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

호출시점을 바꿔봐도 두번정도 reload를 시켜야 얘가 딱 맞네 뭐 학습되는건가 ㅋㅋㅋ

Copy link
Member Author

Choose a reason for hiding this comment

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

일단 머지하겠슴다..~

self.entireQuestionTV.snp.updateConstraints {
$0.height.equalTo(self.entireQuestionTV.contentSize.height)
}
}
}
}

// MARK: - UITableViewDataSource
Expand Down Expand Up @@ -229,9 +282,9 @@ extension QuestionMainVC: UITableViewDelegate {
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0:
return 70
return 44
case 1:
return (questionList.count == 0 ? 236 : 120)
return (questionList.count == 0 ? 189 : 120)
case 2:
return (questionList.count > 5 ? 40 : 0)
default:
Expand All @@ -243,9 +296,9 @@ extension QuestionMainVC: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0:
return 70
return 44
case 1:
return (questionList.count == 0 ? 236 : UITableView.automaticDimension)
return (questionList.count == 0 ? 189 : UITableView.automaticDimension)
case 2:
return (questionList.count > 5 ? 40 : 0)
default:
Expand Down Expand Up @@ -283,13 +336,7 @@ extension QuestionMainVC {
case .success(let res):
if let data = res as? [ClassroomPostList] {
self.questionList = data
DispatchQueue.main.async {
self.entireQuestionTV.reloadData()
self.entireQuestionTV.layoutIfNeeded()
self.entireQuestionTV.snp.updateConstraints {
$0.height.equalTo(self.entireQuestionTV.contentSize.height)
}
}
self.updateEntireQuestionTV()
self.activityIndicator.stopAnimating()
}
case .requestErr(let msg):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_write.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_write.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"images" : [
{
"filename" : "imgRoomMain.png",
"idiom" : "universal",
"filename" : "imgRoomMain.png",
"scale" : "1x"
},
{
"scale" : "2x",
"filename" : "[email protected]",
"idiom" : "universal"
"idiom" : "universal",
"filename" : "[email protected]"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
"scale" : "3x",
"filename" : "[email protected]"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.