Skip to content

Commit

Permalink
Merge pull request #143 from dlwogus0128/chore/#141-자잘한-수정-사항
Browse files Browse the repository at this point in the history
[Chore] #141 - 자잘한 수정 사항
  • Loading branch information
dlwogus0128 authored May 17, 2023
2 parents c83aa13 + 8b621c5 commit 2501203
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 118 deletions.
4 changes: 4 additions & 0 deletions Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
A3C2CAD329E4F77C00EC525B /* TermsOfServiceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3C2CAD229E4F77C00EC525B /* TermsOfServiceVC.swift */; };
A3C2CAD529E4F85400EC525B /* PersonalInfoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3C2CAD429E4F85400EC525B /* PersonalInfoVC.swift */; };
A3C2CAD729E53B2900EC525B /* RNAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3C2CAD629E53B2900EC525B /* RNAlertVC.swift */; };
A3C38FED2A13212300FF196D /* SetInfoLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3C38FEC2A13212300FF196D /* SetInfoLayout.swift */; };
A3D1A77929CF03D200DD54EC /* AuthRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3D1A77829CF03D200DD54EC /* AuthRouter.swift */; };
A3D1A77E29CF09B600DD54EC /* SignInResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3D1A77D29CF09B600DD54EC /* SignInResponseDto.swift */; };
A3D1A78029CF142E00DD54EC /* UserManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3D1A77F29CF142E00DD54EC /* UserManager.swift */; };
Expand Down Expand Up @@ -175,6 +176,7 @@
A3C2CAD229E4F77C00EC525B /* TermsOfServiceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServiceVC.swift; sourceTree = "<group>"; };
A3C2CAD429E4F85400EC525B /* PersonalInfoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonalInfoVC.swift; sourceTree = "<group>"; };
A3C2CAD629E53B2900EC525B /* RNAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNAlertVC.swift; sourceTree = "<group>"; };
A3C38FEC2A13212300FF196D /* SetInfoLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetInfoLayout.swift; sourceTree = "<group>"; };
A3D1A77829CF03D200DD54EC /* AuthRouter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthRouter.swift; sourceTree = "<group>"; };
A3D1A77D29CF09B600DD54EC /* SignInResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInResponseDto.swift; sourceTree = "<group>"; };
A3D1A77F29CF142E00DD54EC /* UserManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -363,6 +365,7 @@
A3BC2F2C2962C3F200198261 /* ActivityRecordInfoVC.swift */,
A3BC2F2E2962C40A00198261 /* UploadedCourseInfoVC.swift */,
A3DB8C462A0B64830081AF2D /* ActivityRecordDetailVC.swift */,
A3C38FEC2A13212300FF196D /* SetInfoLayout.swift */,
);
path = InfoVC;
sourceTree = "<group>";
Expand Down Expand Up @@ -1396,6 +1399,7 @@
CE21C02C299E601000F62AF5 /* ScrapRouter.swift in Sources */,
A3D1A78029CF142E00DD54EC /* UserManager.swift in Sources */,
A3D1A77929CF03D200DD54EC /* AuthRouter.swift in Sources */,
A3C38FED2A13212300FF196D /* SetInfoLayout.swift in Sources */,
CE6655D4295D865B00C64E12 /* Publisher+UIControl.swift in Sources */,
CE0D9FD329648DA300CEB5CD /* CustomAlertVC.swift in Sources */,
CEB841702963360800BF8080 /* CountDownVC.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ enum NaviType {
case titleWithLeftButton // 뒤로가기 버튼 + 중앙 타이틀
case search // 검색창
case report // 신고
case editModeForTitleWithLeftButton // 수정하기 페이지일 때
}

final class CustomNavigationBar: UIView {
Expand All @@ -38,7 +37,7 @@ final class CustomNavigationBar: UIView {

private let leftTitleLabel = UILabel()
private let centerTitleLabel = UILabel()
private let leftButton = UIButton()
let leftButton = UIButton()
private let rightButton = UIButton()
private let reportButton = UIButton()
private let textField = UITextField()
Expand Down Expand Up @@ -72,14 +71,7 @@ extension CustomNavigationBar {

private func setAddTarget(_ type: NaviType) {
self.naviType = type

switch type {
case .editModeForTitleWithLeftButton:
self.leftButton.addTarget(self, action: #selector(presentToQuitEditAlertVC), for: .touchUpInside)
default:
self.leftButton.addTarget(self, action: #selector(popToPreviousVC), for: .touchUpInside)
}

self.leftButton.addTarget(self, action: #selector(popToPreviousVC), for: .touchUpInside)
self.rightButton.addTarget(self, action: #selector(searchLocation), for: .touchUpInside)
self.reportButton.addTarget(self, action: #selector(reportLocation), for: .touchUpInside)
}
Expand Down Expand Up @@ -181,19 +173,6 @@ extension CustomNavigationBar {
}
}

@objc private func presentToQuitEditAlertVC() {
guard let vc = vc else { return }
let quitEditAlertVC = RNAlertVC(description: "러닝 기록 수정을 종료할까요?\n종료 시 수정 내용이 반영되지 않아요.")

quitEditAlertVC.rightButtonTapAction = { [weak self] in
quitEditAlertVC.dismiss(animated: false)
vc.navigationController?.popViewController(animated: true)
}

quitEditAlertVC.modalPresentationStyle = .overFullScreen
self.vc?.present(quitEditAlertVC, animated: false, completion: nil)
}

@objc private func searchLocation() {
guard let text = textField.text else { return }
self.hideKeyboard()
Expand All @@ -202,7 +181,6 @@ extension CustomNavigationBar {

@objc private func reportLocation() {
self.reportButtonClosure?()

}

@objc private func rightButtonDidTap() {
Expand Down Expand Up @@ -242,8 +220,6 @@ extension CustomNavigationBar {
case .report:
reportButton.setImage(ImageLiterals.icArrowBack, for: .normal)
reportButton.isHidden = false
case .editModeForTitleWithLeftButton:
setTitleWithLeftButton()
}
}

Expand All @@ -266,8 +242,6 @@ extension CustomNavigationBar {
setSearchLayout()
case .report:
setReportButtonLayout()
case .editModeForTitleWithLeftButton:
setTitleWithLeftButtonLayout()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct MyPageDto: Codable {
// MARK: - User

struct User: Codable {
let email: String
let nickname, latestStamp: String
let level, levelPercent: Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ final class ActivityRecordDetailVC: UIViewController {
private let recordProvider = Providers.recordProvider

private var recordId: Int?

private var isEditMode: Bool = false


private let courseTitleMaxLength = 20

// MARK: - UI Components
Expand All @@ -45,6 +43,7 @@ final class ActivityRecordDetailVC: UIViewController {
}

private let courseTitleTextField = UITextField().then {
$0.resignFirstResponder()
$0.attributedPlaceholder = NSAttributedString(
string: "글 제목",
attributes: [.font: UIFont.h4, .foregroundColor: UIColor.g3]
Expand All @@ -68,23 +67,23 @@ final class ActivityRecordDetailVC: UIViewController {

private let secondHorizontalDivideLine = UIView()

private lazy var recordDistanceLabel = setGreyTitle().then {
private lazy var recordDistanceLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "거리"
}

private lazy var recordRunningTimeLabel = setGreyTitle().then {
private lazy var recordRunningTimeLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "이동 시간"
}

private lazy var recordAveragePaceLabel = setGreyTitle().then {
private lazy var recordAveragePaceLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "평균 페이스"
}

private lazy var recordDistanceValueLabel = setBlackTitle()
private lazy var recordDistanceValueLabel = SetInfoLayout.makeBlackTitleLabel()

private lazy var recordRunningTimeValueLabel = setBlackTitle()
private lazy var recordRunningTimeValueLabel = SetInfoLayout.makeBlackTitleLabel()

private lazy var recordAveragePaceValueLabel = setBlackTitle()
private lazy var recordAveragePaceValueLabel = SetInfoLayout.makeBlackTitleLabel()

private lazy var recordDistanceStackView = setDetailInfoStakcView(title: recordDistanceLabel, value: recordDistanceValueLabel)

Expand All @@ -110,11 +109,13 @@ final class ActivityRecordDetailVC: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
courseTitleTextField.delegate = self
hideTabBar(wantsToHide: true)
setNavigationBar()
setUI()
setLayout()
setAddTarget()
self.view = view
self.setKeyboardNotification()
self.setTapGesture()
}
Expand All @@ -127,20 +128,19 @@ extension ActivityRecordDetailVC {
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let editAction = UIAlertAction(title: "수정하기", style: .default, handler: {(_: UIAlertAction!) in
// 수정 모드일 때
self.isEditMode = true
self.setEditMode()
})
let deleteVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기")
deleteVC.modalPresentationStyle = .overFullScreen
let deleteAction = UIAlertAction(title: "삭제하기", style: .destructive, handler: {(_: UIAlertAction!) in
self.present(deleteVC, animated: false, completion: nil)})
let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기")
deleteAlertVC.modalPresentationStyle = .overFullScreen
let deleteAlertAction = UIAlertAction(title: "삭제하기", style: .destructive, handler: {(_: UIAlertAction!) in
self.present(deleteAlertVC, animated: false, completion: nil)})

deleteVC.rightButtonTapAction = { [weak self] in
deleteVC.dismiss(animated: false)
deleteAlertVC.rightButtonTapAction = { [weak self] in
deleteAlertVC.dismiss(animated: false)
self?.deleteRecord()
}

[ editAction, deleteAction ].forEach { alertController.addAction($0) }
[ editAction, deleteAlertAction ].forEach { alertController.addAction($0) }
present(alertController, animated: true, completion: nil)
}

Expand All @@ -151,8 +151,13 @@ extension ActivityRecordDetailVC {

if text == self.courseTitleLabel.text {
self.finishEditButton.isEnabled = false
} else {
// 수정이 된 상태라면 팝업을 띄워주기
self.navibar.resetLeftButtonAction({ [weak self] in
//self?.navibar.leftButton.addTarget(self, action: #selector(self?.presentToQuitEditAlertVC), for: .touchUpInside)
self?.presentToQuitEditAlertVC()
}, .titleWithLeftButton)
}

if text.count > courseTitleMaxLength {
let index = text.index(text.startIndex, offsetBy: courseTitleMaxLength)
let newString = text[text.startIndex..<index]
Expand Down Expand Up @@ -183,6 +188,32 @@ extension ActivityRecordDetailVC {

@objc private func finishEditButtonDidTap() {
editRecordTitle()
showToast(message: "제목 수정이 완료되었어요")

// 수정이 완료되면 팝업 뜨지 않음
self.navibar.resetLeftButtonAction({ [weak self] in
self?.navigationController?.popViewController(animated: true)
}, .titleWithLeftButton)

self.navibar.isHidden = false

middleScorollView.snp.makeConstraints { make in
make.top.equalTo(navibar.snp.bottom)
make.leading.trailing.equalTo(view.safeAreaLayoutGuide)
make.bottom.equalTo(view.safeAreaLayoutGuide)
}
}

@objc private func presentToQuitEditAlertVC() {
let quitEditAlertVC = RNAlertVC(description: "러닝 기록 수정을 종료할까요?\n종료 시 수정 내용이 반영되지 않아요.")

quitEditAlertVC.rightButtonTapAction = { [weak self] in
quitEditAlertVC.dismiss(animated: false)
self?.navigationController?.popViewController(animated: true)
}

quitEditAlertVC.modalPresentationStyle = .overFullScreen
self.present(quitEditAlertVC, animated: false, completion: nil)
}
}

Expand Down Expand Up @@ -245,20 +276,6 @@ extension ActivityRecordDetailVC {
label.attributedText = attributedString
}

private func setBlackTitle() -> UILabel {
let label = UILabel()
label.textColor = .g1
label.font = .h3
return label
}

private func setGreyTitle() -> UILabel {
let label = UILabel()
label.textColor = .g2
label.font = .b4
return label
}

// 키보드가 올라오면 scrollView 위치 조정
private func setKeyboardNotification() {
NotificationCenter.default.addObserver(
Expand All @@ -280,6 +297,21 @@ extension ActivityRecordDetailVC {
tap.cancelsTouchesInView = false
view.addGestureRecognizer(tap)
}

func popUpVC() {
self.navigationController?.popViewController(animated: true)
}
}

// MARK: - UITextFieldDelegate

extension ActivityRecordDetailVC: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == self.courseTitleTextField {
self.finishEditButtonDidTap()
}
return true
}
}

// MARK: - Layout Helpers
Expand Down Expand Up @@ -387,23 +419,8 @@ extension ActivityRecordDetailVC {
}

private func setEditMode() {
self.navibar.isHidden = true

let editNavibar = CustomNavigationBar(self, type: .editModeForTitleWithLeftButton)

view.addSubview(editNavibar)

editNavibar.snp.makeConstraints { make in
make.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
make.height.equalTo(48)
}

middleScorollView.snp.makeConstraints { make in
make.top.equalTo(editNavibar.snp.bottom)
make.leading.trailing.equalTo(view.safeAreaLayoutGuide)
make.bottom.equalTo(view.safeAreaLayoutGuide)
}

self.navibar.isHidden = false // true

mapImageView.snp.remakeConstraints { make in
make.top.equalToSuperview()
make.leading.trailing.equalTo(view.safeAreaLayoutGuide)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ final class ActivityRecordInfoTVC: UITableViewCell {
$0.clipsToBounds = true
}

private lazy var activityRecordTitleLabel = setBlackTitle()
private lazy var activityRecordPlaceLabel = setGreyTitle()

private lazy var activityRecordVirticalBarLabel = setGreyTitle().then {
private lazy var activityRecordTitleLabel = SetInfoLayout.makeBlackSmallTitleLabel()
private lazy var activityRecordPlaceLabel = SetInfoLayout.makeGreyTitleLabel()
private lazy var activityRecordVirticalBarLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "|"
}

private lazy var activityRecordDateLabel = setGreyTitle()
private lazy var activityRecordDateLabel = SetInfoLayout.makeGreySmailTitleLabel()

private lazy var activityRecordSubTitleStackView = UIStackView(arrangedSubviews: [activityRecordPlaceLabel, activityRecordVirticalBarLabel, activityRecordDateLabel]).then {
$0.axis = .horizontal
$0.spacing = 4
$0.spacing = 6
}

private lazy var activityRecordMainInfoStackView = UIStackView(arrangedSubviews: [activityRecordTitleLabel, activityRecordSubTitleStackView]).then {
Expand All @@ -53,19 +52,19 @@ final class ActivityRecordInfoTVC: UITableViewCell {
$0.spacing = 7
}

private lazy var activityRecordTotalDistanceValueLabel = setBlackTitle()
private lazy var activityRecordRunningTimeValueLabel = setBlackTitle()
private lazy var activityRecordAveragePaceValueLabel = setBlackTitle()
private lazy var activityRecordTotalDistanceValueLabel = SetInfoLayout.makeBlackSmallTitleLabel()
private lazy var activityRecordRunningTimeValueLabel = SetInfoLayout.makeBlackSmallTitleLabel()
private lazy var activityRecordAveragePaceValueLabel = SetInfoLayout.makeBlackSmallTitleLabel()

private lazy var activityRecordTotalDistanceLabel = setGreyTitle().then {
private lazy var activityRecordTotalDistanceLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "총 거리"
}

private lazy var activityRecordRunningTimeLabel = setGreyTitle().then {
private lazy var activityRecordRunningTimeLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "이동 시간"
}

private lazy var activityRecordAveragePaceLabel = setGreyTitle().then {
private lazy var activityRecordAveragePaceLabel = SetInfoLayout.makeGreySmailTitleLabel().then {
$0.text = "평균 페이스"
}

Expand Down Expand Up @@ -160,20 +159,6 @@ extension ActivityRecordInfoTVC {
return stackView
}

func setBlackTitle() -> UILabel {
let label = UILabel()
label.textColor = .g1
label.font = .h5
return label
}

func setGreyTitle() -> UILabel {
let label = UILabel()
label.textColor = .g2
label.font = .b8
return label
}

func setLineDot(view: UIView) {
let borderLayer = CAShapeLayer()
borderLayer.strokeColor = UIColor.g4.cgColor
Expand Down
Loading

0 comments on commit 2501203

Please sign in to comment.