From 850dfe2742c3ac7e7b076727d77c9becf6e21207 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Thu, 5 Jan 2023 12:23:29 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[Feat]=20#37=20-=20NicknameEditorVC=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runnect-iOS.xcodeproj/project.pbxproj | 4 +++ .../MyPage/VC/NicknameEditorVC.swift | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 2ee617f1..4699267f 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ A3BC2F3A2963D0ED00198261 /* ActivityRecordInfoTVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F392963D0ED00198261 /* ActivityRecordInfoTVC.swift */; }; A3BC2F3D296468E500198261 /* UploadedCourseInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F3C296468E500198261 /* UploadedCourseInfoModel.swift */; }; A3BC2F3F2964706100198261 /* UploadedCourseInfoCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F3E2964706100198261 /* UploadedCourseInfoCVC.swift */; }; + A3BC2F4129667A0D00198261 /* NicknameEditorVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */; }; CE0D9FD329648DA300CEB5CD /* CustomAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */; }; CE146770296568DC00DCEA1B /* RunTrackingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */; }; CE14677829658C7200DCEA1B /* Stopwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14677729658C7200DCEA1B /* Stopwatch.swift */; }; @@ -106,6 +107,7 @@ A3BC2F392963D0ED00198261 /* ActivityRecordInfoTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordInfoTVC.swift; sourceTree = ""; }; A3BC2F3C296468E500198261 /* UploadedCourseInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoModel.swift; sourceTree = ""; }; A3BC2F3E2964706100198261 /* UploadedCourseInfoCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoCVC.swift; sourceTree = ""; }; + A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameEditorVC.swift; sourceTree = ""; }; CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertVC.swift; sourceTree = ""; }; CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunTrackingVC.swift; sourceTree = ""; }; CE14677729658C7200DCEA1B /* Stopwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stopwatch.swift; sourceTree = ""; }; @@ -409,6 +411,7 @@ children = ( A3BC2F292962C39F00198261 /* InfoVC */, CEEC6B3F2961C55000D00E1E /* MyPageVC.swift */, + A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */, ); path = VC; sourceTree = ""; @@ -930,6 +933,7 @@ A3BC2F322962E0DB00198261 /* GoalRewardInfoModel.swift in Sources */, CEC2A68C2962AE1B00160BF7 /* RNStartMarker.swift in Sources */, CE5875A4296015D2005D967E /* Encodable+.swift in Sources */, + A3BC2F4129667A0D00198261 /* NicknameEditorVC.swift in Sources */, CE14677A2965A80700DCEA1B /* CustomBottomSheetVC.swift in Sources */, CEEC6B4B2961D89700D00E1E /* CustomNavigationBar.swift in Sources */, CE17F02D2961BBA100E1DED0 /* ColorLiterals.swift in Sources */, diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift new file mode 100644 index 00000000..0cf0b90d --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift @@ -0,0 +1,29 @@ +// +// NicknameEditorVC.swift +// Runnect-iOS +// +// Created by 몽이 누나 on 2023/01/05. +// + +import UIKit + +class NicknameEditorVC: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} From b9d526dde231a8c8f3cfa2fde95b266efda37bb7 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:18:24 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[Feat]=20#37=20-=20NicknameEditor=20?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=9E=A1=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyPage/VC/NicknameEditorVC.swift | 76 ++++++++++++++++--- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift index 0cf0b90d..591cbae3 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift @@ -6,24 +6,78 @@ // import UIKit +import SnapKit +import Then class NicknameEditorVC: UIViewController { + // MARK: - UI Components + + private let editorContentView = UIView().then { + $0.layer.cornerRadius = 10 + } + + private let nickNameEditLabel = UILabel().then { + $0.text = "닉네임 수정" + $0.textColor = .g1 + $0.font = .h5 + } + + private let nickNameTextField = UITextField().then { + $0.text = nil + $0.textColor = .g1 + $0.font = .b6 + $0.attributedPlaceholder = NSAttributedString( + string: "닉네임을 입력하세요", + attributes: [NSAttributedString.Key.foregroundColor = .g2, NSAttributedString.Key.font = .b6] + ) + } + + private let horizontalDivideLine = UIView() + + // MARK: - View Life Cycle + override func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .black.withAlphaComponent(0.8) + setUI() + setLayout() + } +} - // Do any additional setup after loading the view. +extension NicknameEditorVC { + + // MARK: - Layout Helpers + + private func setUI() { + editorContentView.backgroundColor = .blue + horizontalDivideLine.backgroundColor = .g3 } - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. + private func setLayout() { + view.addSubview(editorContentView) + + editorContentView.snp.makeConstraints { make in + make.centerY.equalToSuperview() + make.leading.trailing.equalTo(view.safeAreaLayoutGuide).inset(16) + make.height.equalTo(111) + } + + editorContentView.addSubviews(nickNameEditLabel, nickNameTextField, horizontalDivideLine) + + nickNameEditLabel.snp.makeConstraints { make in + make.top.leading.equalToSuperview().offset(24) + } + + nickNameTextField.snp.makeConstraints { make in + make.top.equalTo(nickNameEditLabel.snp.bottom).offset(20) + make.leading.trailing.equalToSuperview().inset(24) + } + + horizontalDivideLine.snp.makeConstraints { make in + make.top.equalTo(nickNameTextField.snp.bottom).offset(10) + make.width.equalTo(nickNameTextField.snp.width) + make.height.equalTo(0.5) + } } - */ - } From 721cdc97b2582e1745fa4108bc5d27a8feeb1f24 Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:53:03 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[Feat]=20#37=20-=20myProfileEditButton=20?= =?UTF-8?q?=ED=84=B0=EC=B9=98=20=EC=9D=B8=ED=84=B0=EB=9E=99=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/MyPage/VC/MyPageVC.swift | 18 +++++++++++++++--- .../MyPage/VC/NicknameEditorVC.swift | 6 +++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift index 597713e6..9a932d38 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift @@ -30,7 +30,7 @@ final class MyPageVC: UIViewController { $0.font = .h4 } - private let myProfileEditButton = UIButton(type: .system).then { + private lazy var myProfileEditButton = UIButton(type: .system).then { $0.setImage(ImageLiterals.icEdit, for: .normal) $0.setTitle("수정하기", for: .normal) $0.titleLabel?.font = .b7 @@ -40,6 +40,8 @@ final class MyPageVC: UIViewController { $0.layer.borderColor = UIColor.m2.cgColor $0.layer.cornerRadius = 14 $0.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 4) + let tap = UITapGestureRecognizer(target: self, action: #selector(self.touchUpNicknameEditorView)) + $0.addGestureRecognizer(tap) } private let myRunningLevelLavel = UILabel().then { @@ -76,7 +78,7 @@ final class MyPageVC: UIViewController { } private lazy var uploadedCourseInfoView = makeInfoView(title: "업로드한 코스").then { - let tap = UITapGestureRecognizer(target: self, action: #selector(self.uploadedCourseRecordInfoView)) + let tap = UITapGestureRecognizer(target: self, action: #selector(self.touchUpUploadedCourseRecordInfoView)) $0.addGestureRecognizer(tap) } @@ -145,6 +147,11 @@ extension MyPageVC { let uploadedCourseInfoVC = UploadedCourseInfoVC() self.navigationController?.pushViewController(uploadedCourseInfoVC, animated: true) } + + private func pushToNicknameEditorVC() { + let nicknameEditorVC = NicknameEditorVC() + self.navigationController?.pushViewController(nicknameEditorVC, animated: false) + } } // MARK: - @objc Function @@ -161,9 +168,14 @@ extension MyPageVC { } @objc - private func uploadedCourseRecordInfoView() { + private func touchUpUploadedCourseRecordInfoView() { pushToUploadedCourseInfoVC() } + + @objc + private func touchUpNicknameEditorView() { + pushToNicknameEditorVC() + } } // MARK: - UI & Layout diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift index 591cbae3..4c653c2f 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift @@ -28,8 +28,7 @@ class NicknameEditorVC: UIViewController { $0.textColor = .g1 $0.font = .b6 $0.attributedPlaceholder = NSAttributedString( - string: "닉네임을 입력하세요", - attributes: [NSAttributedString.Key.foregroundColor = .g2, NSAttributedString.Key.font = .b6] + string: "닉네임을 입력하세요" ) } @@ -50,7 +49,7 @@ extension NicknameEditorVC { // MARK: - Layout Helpers private func setUI() { - editorContentView.backgroundColor = .blue + editorContentView.backgroundColor = .w1 horizontalDivideLine.backgroundColor = .g3 } @@ -76,6 +75,7 @@ extension NicknameEditorVC { horizontalDivideLine.snp.makeConstraints { make in make.top.equalTo(nickNameTextField.snp.bottom).offset(10) + make.centerX.equalToSuperview() make.width.equalTo(nickNameTextField.snp.width) make.height.equalTo(0.5) } From 2cecff7a38ef3c26d4ee428834deb82ad41ac70c Mon Sep 17 00:00:00 2001 From: dlwogus0128 <79050615+dlwogus0128@users.noreply.github.com> Date: Thu, 5 Jan 2023 15:11:59 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[Feat]=20#37=20-=20view=20=ED=84=B0?= =?UTF-8?q?=EC=B9=98=20=EC=8B=9C=20dismiss=20=EB=B0=8F=20=ED=82=A4?= =?UTF-8?q?=EB=B3=B4=EB=93=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/MyPage/VC/MyPageVC.swift | 3 +- .../MyPage/VC/NicknameEditorVC.swift | 58 +++++++++++++++++-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift index 9a932d38..9b22f539 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift @@ -150,7 +150,8 @@ extension MyPageVC { private func pushToNicknameEditorVC() { let nicknameEditorVC = NicknameEditorVC() - self.navigationController?.pushViewController(nicknameEditorVC, animated: false) + nicknameEditorVC.modalPresentationStyle = .overFullScreen + self.present(nicknameEditorVC, animated: false) } } diff --git a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift index 4c653c2f..eda672ee 100644 --- a/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift +++ b/Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift @@ -9,8 +9,8 @@ import UIKit import SnapKit import Then -class NicknameEditorVC: UIViewController { - +final class NicknameEditorVC: UIViewController { + // MARK: - UI Components private let editorContentView = UIView().then { @@ -24,23 +24,62 @@ class NicknameEditorVC: UIViewController { } private let nickNameTextField = UITextField().then { + $0.resignFirstResponder() $0.text = nil $0.textColor = .g1 $0.font = .b6 $0.attributedPlaceholder = NSAttributedString( - string: "닉네임을 입력하세요" + string: "닉네임을 입력하세요", + attributes: [NSAttributedString.Key.foregroundColor: UIColor.g2, NSAttributedString.Key.font: UIFont.b6] ) + $0.keyboardType = .webSearch } private let horizontalDivideLine = UIView() // MARK: - View Life Cycle - + override func viewDidLoad() { super.viewDidLoad() + self.tabBarController?.tabBar.isHidden = true + nickNameTextField.delegate = self + isTextExist(textField: nickNameTextField) view.backgroundColor = .black.withAlphaComponent(0.8) setUI() setLayout() + showKeyboard() + } +} + +// MARK: - Method + +extension NicknameEditorVC { + + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + super.touchesBegan(touches, with: event) + if let touch = touches.first, touch.view == self.view { + dismiss(animated: false) + } + } + + func showKeyboard() { + self.nickNameTextField.becomeFirstResponder() + } + + func isTextExist(textField: UITextField) { + if textField.text == nil { + textField.enablesReturnKeyAutomatically = false + } else { + textField.enablesReturnKeyAutomatically = true + } + } +} + +// MARK: - @objc Function + +extension NicknameEditorVC { + @objc private func popToPreviousVC() { + self.navigationController?.popViewController(animated: true) } } @@ -81,3 +120,14 @@ extension NicknameEditorVC { } } } + +// MARK: - UITextFieldDelegate + +extension NicknameEditorVC: UITextFieldDelegate { + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + if textField == self.nickNameTextField { + self.dismiss(animated: false) + } + return true + } +}