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

[PR] 약속 - 약속 수정/삭제 리팩토링 #46

Merged
merged 2 commits into from
Jan 21, 2024
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
2 changes: 1 addition & 1 deletion CoNet/Main/Meeting/MeetingInfoEditViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MeetingInfoEditViewController: UIViewController, UITextFieldDelegate {

addView()
layoutConstriants()
buttonClicks()
buttonActions()
meetingnameTextField.delegate = self
}

Expand Down
38 changes: 21 additions & 17 deletions CoNet/Main/Meeting/Plan/TimeShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class TimeShareViewController: UIViewController, TimeShareProtocol {
layoutConstraints()
timeTableSetting()

btnClickEvents()
buttonActions()
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -255,7 +255,7 @@ class TimeShareViewController: UIViewController, TimeShareProtocol {
peopleNum4.text = sectionMemberCount[3]
}

func btnClickEvents() {
func buttonActions() {
xButton.addTarget(self, action: #selector(xButtonTapped), for: .touchUpInside)
inputTimeButton.addTarget(self, action: #selector(didClickInputTimeButton), for: .touchUpInside)
prevBtn.addTarget(self, action: #selector(didClickPrevButton), for: .touchUpInside)
Expand Down Expand Up @@ -318,26 +318,30 @@ class TimeShareViewController: UIViewController, TimeShareProtocol {
// 약속 수정 페이지로 이동
func pushEditPlanPage() {
let nextVC = MakePlanViewController()

// setting
nextVC.titleLabel.text = "약속 수정하기"
nextVC.planNameTextField.text = planTitle.text
nextVC.planStartDateField.text = sendDate[0].replacingOccurrences(of: "-", with: ". ")
nextVC.calendarButton.isEnabled = false
nextVC.cautionLabel.text = "약속 기간은 수정할 수 없습니다."
nextVC.cautionLabel.textColor = UIColor.textDisabled
nextVC.cautionLabel.snp.makeConstraints { make in
make.leading.equalTo(nextVC.view.safeAreaLayoutGuide.snp.leading).offset(24)
}
nextVC.cautionImage.isHidden = true
nextVC.planStartDateField.isUserInteractionEnabled = false
nextVC.makeButton.setTitle("수정", for: .normal)
nextVC.planId = planId
setupEditPlanPage(nextVC)

nextVC.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(nextVC, animated: true)
}

// 약속 수정페이지 설정
func setupEditPlanPage(_ viewController: MakePlanViewController) {
viewController.titleLabel.text = "약속 수정하기"

viewController.planNameTextField.text = planTitle.text
viewController.planStartDateField.text = sendDate[0].replacingOccurrences(of: "-", with: ". ")
viewController.planStartDateField.textColor = UIColor.textDisabled
viewController.calendarButton.isEnabled = false

viewController.cautionLabel.text = "약속 기간은 수정할 수 없습니다."
viewController.cautionLabel.textColor = UIColor.textDisabled
viewController.cautionImage.isHidden = true

viewController.planStartDateField.isUserInteractionEnabled = false
viewController.makeButton.setTitle("수정", for: .normal)
viewController.planId = planId
}

Comment on lines +327 to +344
Copy link
Contributor

Choose a reason for hiding this comment

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

오오 이렇게 뺀 건 좋은 것 같아여!
그런데 어쩌다가 이렇게 nextVC에 설정해야할 내용이 많아진건가요..??

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
Contributor Author

Choose a reason for hiding this comment

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

오우 이건 원래 있던 설정들인데 따로 함수화하면 깔끔해 보일것같아서 함수화를 해놓은거랍니다~~

// 약속 삭제 팝업
func pushDeletePlanPopUp() {
let popUpVC = DeletePlanPopUpViewController()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class DeletePlanPopUpViewController: UIViewController {
view.backgroundColor = .clear

layoutConstraints()

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissPopUp))
background.addGestureRecognizer(tapGesture)
}
Expand All @@ -54,8 +53,10 @@ class DeletePlanPopUpViewController: UIViewController {
}
}
}

// 모든 layout Constraints
}

// layout
extension DeletePlanPopUpViewController {
private func layoutConstraints() {
backgroundConstraints()
popUpConstraints()
Expand All @@ -74,11 +75,8 @@ class DeletePlanPopUpViewController: UIViewController {
view.addSubview(popUp)
popUp.snp.makeConstraints { make in
make.width.equalTo(view.snp.width).offset(-48)
make.leading.equalTo(view.snp.leading).offset(24)
make.trailing.equalTo(view.snp.trailing).offset(24)

make.centerX.equalTo(view.snp.centerX)
make.centerY.equalTo(view.snp.centerY)
make.horizontalEdges.equalTo(view.snp.horizontalEdges).offset(24)
make.center.equalTo(view.snp.center)
}
}
}