Skip to content

Commit

Permalink
Merge pull request #40 from dlwogus0128/feat/#37-NicknameEditorVC-UI-구현
Browse files Browse the repository at this point in the history
[Feat] #37 - NicknameEditorVC UI 구현
  • Loading branch information
dlwogus0128 authored Jan 5, 2023
2 parents 2e158fa + 60fd825 commit 67a7ccc
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 3 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 @@ -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 */; };
Expand Down Expand Up @@ -113,6 +114,7 @@
A3BC2F392963D0ED00198261 /* ActivityRecordInfoTVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordInfoTVC.swift; sourceTree = "<group>"; };
A3BC2F3C296468E500198261 /* UploadedCourseInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoModel.swift; sourceTree = "<group>"; };
A3BC2F3E2964706100198261 /* UploadedCourseInfoCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoCVC.swift; sourceTree = "<group>"; };
A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameEditorVC.swift; sourceTree = "<group>"; };
CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertVC.swift; sourceTree = "<group>"; };
CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunTrackingVC.swift; sourceTree = "<group>"; };
CE14677729658C7200DCEA1B /* Stopwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stopwatch.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -429,6 +431,7 @@
children = (
A3BC2F292962C39F00198261 /* InfoVC */,
CEEC6B3F2961C55000D00E1E /* MyPageVC.swift */,
A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */,
);
path = VC;
sourceTree = "<group>";
Expand Down Expand Up @@ -966,6 +969,7 @@
DA20D84B296697C600F1581F /* UploadResultViewController.swift in Sources */,
DA20D8432966977D00F1581F /* SearchResultViewController.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 */,
Expand Down
19 changes: 16 additions & 3 deletions Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/MyPageVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -145,6 +147,12 @@ extension MyPageVC {
let uploadedCourseInfoVC = UploadedCourseInfoVC()
self.navigationController?.pushViewController(uploadedCourseInfoVC, animated: true)
}

private func pushToNicknameEditorVC() {
let nicknameEditorVC = NicknameEditorVC()
nicknameEditorVC.modalPresentationStyle = .overFullScreen
self.present(nicknameEditorVC, animated: false)
}
}

// MARK: - @objc Function
Expand All @@ -161,9 +169,14 @@ extension MyPageVC {
}

@objc
private func uploadedCourseRecordInfoView() {
private func touchUpUploadedCourseRecordInfoView() {
pushToUploadedCourseInfoVC()
}

@objc
private func touchUpNicknameEditorView() {
pushToNicknameEditorVC()
}
}

// MARK: - UI & Layout
Expand Down
133 changes: 133 additions & 0 deletions Runnect-iOS/Runnect-iOS/Presentation/MyPage/VC/NicknameEditorVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
//
// NicknameEditorVC.swift
// Runnect-iOS
//
// Created by 몽이 누나 on 2023/01/05.
//

import UIKit
import SnapKit
import Then

final 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.resignFirstResponder()
$0.text = nil
$0.textColor = .g1
$0.font = .b6
$0.attributedPlaceholder = NSAttributedString(
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<UITouch>, 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)
}
}

extension NicknameEditorVC {

// MARK: - Layout Helpers

private func setUI() {
editorContentView.backgroundColor = .w1
horizontalDivideLine.backgroundColor = .g3
}

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.centerX.equalToSuperview()
make.width.equalTo(nickNameTextField.snp.width)
make.height.equalTo(0.5)
}
}
}

// MARK: - UITextFieldDelegate

extension NicknameEditorVC: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == self.nickNameTextField {
self.dismiss(animated: false)
}
return true
}
}

0 comments on commit 67a7ccc

Please sign in to comment.