-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] #212 - 러닝 기록 상세페이지 메뉴 변경 #219
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
The head ref may contain hidden characters: "#212---\uB7EC\uB2DD-\uAE30\uB85D-\uC0C1\uC138\uD398\uC774\uC9C0-\uBA54\uB274-\uBCC0\uACBD"
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,21 +10,22 @@ import UIKit | |
| import SnapKit | ||
| import Then | ||
| import Moya | ||
| import DropDown | ||
|
|
||
| final class ActivityRecordDetailVC: UIViewController { | ||
|
|
||
| // MARK: - Properties | ||
|
|
||
| private let recordProvider = Providers.recordProvider | ||
|
|
||
| private var recordId: Int? | ||
|
|
||
| private let courseTitleMaxLength = 20 | ||
|
|
||
| // MARK: - UI Components | ||
|
|
||
| private lazy var navibar = CustomNavigationBar(self, type: .titleWithLeftButton) | ||
|
|
||
| private let moreButton = UIButton(type: .system).then { | ||
| $0.setImage(ImageLiterals.icMore, for: .normal) | ||
| $0.tintColor = .g1 | ||
|
|
@@ -42,15 +43,16 @@ final class ActivityRecordDetailVC: UIViewController { | |
| $0.font = .h4 | ||
| } | ||
|
|
||
| private let courseTitleTextField = UITextField().then { | ||
| $0.resignFirstResponder() | ||
| private lazy var courseTitleTextField = UITextField().then { | ||
|
|
||
| $0.attributedPlaceholder = NSAttributedString( | ||
| string: "글 제목", | ||
| attributes: [.font: UIFont.h4, .foregroundColor: UIColor.g3] | ||
| ) | ||
| $0.font = .h4 | ||
| $0.textColor = .g1 | ||
| $0.addLeftPadding(width: 2) | ||
| $0.addTarget(self, action: #selector(textFieldTextDidChange), for: .editingChanged) | ||
| } | ||
|
|
||
| private let recordDateInfoView = CourseDetailInfoView(title: "날짜", description: String()) | ||
|
|
@@ -70,15 +72,15 @@ final class ActivityRecordDetailVC: UIViewController { | |
| private lazy var recordDistanceLabel = SetInfoLayout.makeGreySmailTitleLabel().then { | ||
| $0.text = "거리" | ||
| } | ||
|
|
||
| private lazy var recordRunningTimeLabel = SetInfoLayout.makeGreySmailTitleLabel().then { | ||
| $0.text = "이동 시간" | ||
| } | ||
|
|
||
| private lazy var recordAveragePaceLabel = SetInfoLayout.makeGreySmailTitleLabel().then { | ||
| $0.text = "평균 페이스" | ||
| } | ||
|
|
||
| private lazy var recordDistanceValueLabel = SetInfoLayout.makeBlackTitleLabel() | ||
|
|
||
| private lazy var recordRunningTimeValueLabel = SetInfoLayout.makeBlackTitleLabel() | ||
|
|
@@ -125,25 +127,35 @@ final class ActivityRecordDetailVC: UIViewController { | |
|
|
||
| extension ActivityRecordDetailVC { | ||
| @objc func moreButtonDidTap() { | ||
| let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) | ||
| let editAction = UIAlertAction(title: "수정하기", style: .default, handler: {(_: UIAlertAction!) in | ||
| // 수정 모드일 때 | ||
| self.setEditMode() | ||
| }) | ||
| let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기") | ||
| deleteAlertVC.modalPresentationStyle = .overFullScreen | ||
| let deleteAlertAction = UIAlertAction(title: "삭제하기", style: .destructive, handler: {(_: UIAlertAction!) in | ||
| self.present(deleteAlertVC, animated: false, completion: nil)}) | ||
|
|
||
| deleteAlertVC.rightButtonTapAction = { [weak self] in | ||
| deleteAlertVC.dismiss(animated: false) | ||
| self?.deleteRecord() | ||
| let hideLastCellSeparatorBoxSize = 79 | ||
| let items = ["수정하기", "삭제하기"] | ||
| let imageArray: [UIImage] = [ImageLiterals.icModify, ImageLiterals.icRemove] | ||
|
|
||
| let menu = DropDown().then { | ||
| $0.anchorView = moreButton | ||
| $0.backgroundColor = .w1 | ||
| $0.bottomOffset = CGPoint(x: -136, y: moreButton.bounds.height - 10) | ||
| $0.width = 170 | ||
| $0.cellHeight = 40 | ||
| $0.cornerRadius = 12 | ||
| $0.dismissMode = .onTap | ||
| $0.separatorColor = UIColor(hex: "#EBEBEB") | ||
| $0.dataSource = items | ||
| $0.textFont = .b3 | ||
| } | ||
|
|
||
| menu.customCellConfiguration = { (index: Index, _: String, cell: DropDownCell) -> Void in | ||
| let lastDividerLineRemove = UIView(frame: CGRect(origin: CGPoint(x: 0, y: hideLastCellSeparatorBoxSize), size: CGSize(width: 170, height: 10))) | ||
| lastDividerLineRemove.backgroundColor = .white | ||
| cell.separatorInset = .zero | ||
| cell.dropDownImage.image = imageArray[index] | ||
| cell.addSubview(lastDividerLineRemove) | ||
| } | ||
|
|
||
| let cancelAction = UIAlertAction(title: "닫기", style: .cancel, handler: nil) | ||
| dropDownTouchAction(menu: menu) | ||
|
Collaborator
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. 더 나은 코드를 향해 항상 수정하는 모습 너무 보기 좋아요 👍🏻 |
||
|
|
||
| [ editAction, deleteAlertAction, cancelAction ].forEach { alertController.addAction($0) } | ||
| present(alertController, animated: true, completion: nil) | ||
| menu.show() | ||
| } | ||
|
|
||
| @objc private func textFieldTextDidChange() { | ||
|
|
@@ -166,30 +178,28 @@ extension ActivityRecordDetailVC { | |
| } | ||
| } | ||
|
|
||
| @objc private func keyboardWillShow(_ notification: Notification) { | ||
| guard let userInfo = notification.userInfo, | ||
| let keyboardFrame = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { | ||
| return | ||
| @objc private func keyboardWillShow(_ sender: Notification) { // 키보드의 높이만큼 화면을 올려줍니다. | ||
| if let keyboardFrame: NSValue = sender.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue { | ||
| let keyboardRectangle = keyboardFrame.cgRectValue | ||
| let keyboardHeight = keyboardRectangle.height | ||
| self.view.frame.origin.y -= keyboardHeight | ||
| } | ||
|
|
||
| let contentInset = UIEdgeInsets( | ||
| top: 0.0, | ||
| left: 0.0, | ||
| bottom: keyboardFrame.size.height, | ||
| right: 0.0) | ||
| middleScorollView.contentInset = contentInset | ||
| middleScorollView.scrollIndicatorInsets = contentInset | ||
| } | ||
|
|
||
| @objc private func keyboardWillHide() { | ||
| let contentInset = UIEdgeInsets.zero | ||
| middleScorollView.contentInset = contentInset | ||
| middleScorollView.scrollIndicatorInsets = contentInset | ||
| @objc private func keyboardWillHide(_ sender: Notification) { // 키보드의 높이만큼 화면을 내려줍니다. | ||
| if let keyboardFrame: NSValue = sender.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue { | ||
| let keyboardRectangle = keyboardFrame.cgRectValue | ||
| let keyboardHeight = keyboardRectangle.height | ||
| self.view.frame.origin.y += keyboardHeight | ||
| } | ||
| } | ||
|
|
||
| @objc private func finishEditButtonDidTap() { | ||
| editRecordTitle() | ||
|
|
||
| // 키보드가 올라와 있다면 내려가는 코드 추가 | ||
| view.endEditing(true) | ||
|
|
||
| // 수정이 완료되면 팝업 뜨지 않음 | ||
| self.navibar.resetLeftButtonAction({ [weak self] in | ||
| self?.navigationController?.popViewController(animated: true) | ||
|
|
@@ -202,6 +212,7 @@ extension ActivityRecordDetailVC { | |
| make.leading.trailing.equalTo(view.safeAreaLayoutGuide) | ||
| make.bottom.equalTo(view.safeAreaLayoutGuide) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| @objc private func presentToQuitEditAlertVC() { | ||
|
|
@@ -245,7 +256,6 @@ extension ActivityRecordDetailVC { | |
|
|
||
| private func setAddTarget() { | ||
| self.moreButton.addTarget(self, action: #selector(moreButtonDidTap), for: .touchUpInside) | ||
| self.courseTitleTextField.addTarget(self, action: #selector(textFieldTextDidChange), for: .editingChanged) | ||
| self.finishEditButton.addTarget(self, action: #selector(finishEditButtonDidTap), for: .touchUpInside) | ||
| } | ||
|
|
||
|
|
@@ -307,8 +317,11 @@ extension ActivityRecordDetailVC { | |
|
|
||
| extension ActivityRecordDetailVC: UITextFieldDelegate { | ||
| func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
| textField.resignFirstResponder() | ||
| if textField == self.courseTitleTextField { | ||
| self.finishEditButtonDidTap() | ||
| if finishEditButton.isEnabled == true { | ||
|
Collaborator
Author
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.
|
||
| self.finishEditButtonDidTap() | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
@@ -419,7 +432,7 @@ extension ActivityRecordDetailVC { | |
|
|
||
| private func setEditMode() { | ||
| self.navibar.isHidden = false // true | ||
|
|
||
| mapImageView.snp.remakeConstraints { make in | ||
| make.top.equalToSuperview() | ||
| make.leading.trailing.equalTo(view.safeAreaLayoutGuide) | ||
|
|
@@ -431,13 +444,13 @@ extension ActivityRecordDetailVC { | |
| self.courseTitleTextField.text = self.courseTitleLabel.text | ||
|
|
||
| middleScorollView.addSubview(courseTitleTextField) | ||
|
|
||
| courseTitleTextField.snp.makeConstraints { make in | ||
| make.top.equalTo(mapImageView.snp.bottom).offset(27) | ||
| make.leading.trailing.equalToSuperview().inset(16) | ||
| make.height.equalTo(35) | ||
| } | ||
|
|
||
| self.finishEditButton.isHidden = false | ||
|
|
||
| firstHorizontalDivideLine.snp.remakeConstraints { make in | ||
|
|
@@ -461,9 +474,9 @@ extension ActivityRecordDetailVC { | |
| make.top.equalTo(secondHorizontalDivideLine.snp.bottom).offset(22) | ||
| make.centerX.equalToSuperview() | ||
| } | ||
|
|
||
| middleScorollView.addSubview(finishEditButton) | ||
|
|
||
| finishEditButton.snp.makeConstraints { make in | ||
| make.bottom.equalToSuperview().inset(30) | ||
| make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) | ||
|
|
@@ -518,6 +531,7 @@ extension ActivityRecordDetailVC { | |
| if 200..<300 ~= status { | ||
| print("제목 수정 성공") | ||
| self.showToast(message: "제목 수정이 완료되었어요") | ||
| self.finishEditButton.isEnabled = false | ||
| } | ||
| if status >= 400 { | ||
| print("400 error") | ||
|
|
@@ -530,3 +544,34 @@ extension ActivityRecordDetailVC { | |
| } | ||
| } | ||
| } | ||
| // MARK: - DropDown | ||
|
|
||
| extension ActivityRecordDetailVC { | ||
| private func dropDownTouchAction(menu: DropDown) { | ||
|
|
||
| DropDown.appearance().textColor = .g1 | ||
| DropDown.appearance().selectionBackgroundColor = .w1 | ||
| DropDown.appearance().shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.2) | ||
| DropDown.appearance().shadowOpacity = 1 | ||
| DropDown.appearance().shadowRadius = 10 | ||
|
|
||
| menu.selectionAction = { [unowned self] (_, item) in | ||
| menu.clearSelection() | ||
|
|
||
| switch item { | ||
| case "수정하기": | ||
| self.setEditMode() | ||
| case "삭제하기": | ||
| let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기") | ||
| deleteAlertVC.modalPresentationStyle = .overFullScreen | ||
| deleteAlertVC.rightButtonTapAction = { | ||
| deleteAlertVC.dismiss(animated: false) | ||
| self.deleteRecord() | ||
| } | ||
| self.present(deleteAlertVC, animated: false) | ||
| default: | ||
| self.showToast(message: "없는 명령어 입니다.") | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
@513sojin
마이페이지 ->
러닝 기록보시면 수정하기 누르고 제목을 수정하는 과정에서,텍스트 필드를 누르면 안 되고.. 텍스트 필드의 텍스트를 눌러야만 수정하기가 되더라고요..?
merge 전에도 똑같아서 생각나실때 보셔도 좋을 것 같아요!
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 부분 눌러야지만 수정되는지 모르겠네요 ,, 딱히 의도가 있을거 같지는 않은데 ㅠ
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.
흑흑.. 배포 전에 꼭 수정‼️ ‼️ ‼️ ‼️ ‼️ ‼️ ‼️ ‼️ ‼️