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

[FEAT] #142 - 그룹명 변경 기능 구현 #143

Merged
merged 6 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ disabled_rules:
- nesting
- function_parameter_count
- function_body_length
- cyclomatic_complexity
- file_length
Comment on lines +7 to +8
Copy link
Member

Choose a reason for hiding this comment

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

추가할 때 다같이 한번 이야기해봐요!
저번에 제가 swift lint 같이 쓰던 팀원은 저보다 경험이 좀 더 많은데 최대한 추가하지 않으려고 하더라구요 분명 cyclomatic_complexity 도 클린코딩을 추구하면서 리펙하면 워닝을해결할 수 있을거에요..!!

file_length 는 400줄 워닝일텐데 아마 서버 로직 옮기면 400을 넘기지는 않을거에요..! 일단 여기에 추가하고 나중에 swift lint 도 만져봅시다..!

Copy link
Member Author

Choose a reason for hiding this comment

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

넵넵 알겠습니다!!

excluded:
- Pods
- NADA-iOS-forRelease/Sources/AppDelegate.swift
Expand Down
4 changes: 4 additions & 0 deletions NADA-iOS-forRelease.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
39288E12273F52B20072F403 /* CardListLookUpRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39288E11273F52B20072F403 /* CardListLookUpRequest.swift */; };
392F7FB4274621F1008CDBF5 /* MoreListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 392F7FB2274621F1008CDBF5 /* MoreListTableViewCell.swift */; };
392F7FB5274621F1008CDBF5 /* MoreListTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 392F7FB3274621F1008CDBF5 /* MoreListTableViewCell.xib */; };
39317D2227646F8E00D87166 /* GroupNameEditBottomSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39317D2127646F8E00D87166 /* GroupNameEditBottomSheetViewController.swift */; };
39369935274A4FCB00684420 /* NotoSansCJKkr-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 39369930274A4FCB00684420 /* NotoSansCJKkr-Bold.otf */; };
39369936274A4FCB00684420 /* NotoSansCJKkr-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 39369931274A4FCB00684420 /* NotoSansCJKkr-Regular.otf */; };
39369937274A4FCB00684420 /* NotoSansCJKkr-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 39369932274A4FCB00684420 /* NotoSansCJKkr-Medium.otf */; };
Expand Down Expand Up @@ -143,6 +144,7 @@
39288E11273F52B20072F403 /* CardListLookUpRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardListLookUpRequest.swift; sourceTree = "<group>"; };
392F7FB2274621F1008CDBF5 /* MoreListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoreListTableViewCell.swift; sourceTree = "<group>"; };
392F7FB3274621F1008CDBF5 /* MoreListTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MoreListTableViewCell.xib; sourceTree = "<group>"; };
39317D2127646F8E00D87166 /* GroupNameEditBottomSheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupNameEditBottomSheetViewController.swift; sourceTree = "<group>"; };
39369930274A4FCB00684420 /* NotoSansCJKkr-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSansCJKkr-Bold.otf"; sourceTree = "<group>"; };
39369931274A4FCB00684420 /* NotoSansCJKkr-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSansCJKkr-Regular.otf"; sourceTree = "<group>"; };
39369932274A4FCB00684420 /* NotoSansCJKkr-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSansCJKkr-Medium.otf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -480,6 +482,7 @@
39D88B6A274600B100A72164 /* CommonBottomSheetViewController.swift */,
77DFB870274F92F9000CD36F /* AddWithIdBottomSheetViewController.swift */,
398413B6274A7A1E005550BC /* AddGroupBottomSheetViewController.swift */,
39317D2127646F8E00D87166 /* GroupNameEditBottomSheetViewController.swift */,
77703156275005AA002CBD19 /* CardResultBottomSheetViewController.swift */,
7713E8472752E2A900724C8B /* SelectGroupBottomSheetViewController.swift */,
F8915A20275728F20013D609 /* SelectBirthBottomViewController.swift */,
Expand Down Expand Up @@ -1087,6 +1090,7 @@
buildActionMask = 2147483647;
files = (
F87122762733046300A24E74 /* Card.swift in Sources */,
39317D2227646F8E00D87166 /* GroupNameEditBottomSheetViewController.swift in Sources */,
F84BAF9D26FDB417004CA335 /* CardCreationViewController.swift in Sources */,
F8C83FCB272FA32C0009DF0D /* GroupService.swift in Sources */,
F858079E2700354E00872484 /* BackgroundCollectionViewCell.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extension Const {
static let onboardingViewController = "OnboardingViewController"
static let openSourceViewController = "OpenSourceViewController"
static let teamNADAViewController = "TeamNADAViewController"
static let groupNameEditBottomSheetViewController = "GroupNameEditBottomSheetViewController"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ import UIKit

class GroupEditTableViewCell: UITableViewCell {

// MARK: - Properties
weak var delegate: GroupEditViewDelegate?

// MARK: - @IBOutlet Properties
@IBOutlet weak var titleLabel: UILabel!

// MARK: - View Life Cycle
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code

setupGestureRecognizer()
}

// MARK: - Functions
static func nib() -> UINib {
return UINib(nibName: "GroupEditTableViewCell", bundle: nil)
}
Expand All @@ -30,3 +37,23 @@ class GroupEditTableViewCell: UITableViewCell {
titleLabel.text = title
}
}

// MARK: - Extensions
extension GroupEditTableViewCell {

private func setupGestureRecognizer() {
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(labelClicked))
titleLabel.addGestureRecognizer(tapGestureRecognizer)
titleLabel.isUserInteractionEnabled = true
}

@objc private func labelClicked(_ tapRecognizer: UITapGestureRecognizer) {
delegate?.presentToGroupNameEdit(self.titleLabel)
}

}

// MARK: - Protocol
protocol GroupEditViewDelegate: AnyObject {
func presentToGroupNameEdit(_ sender: UILabel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ class CommonBottomSheetViewController: UIViewController {
self.dimmedBackView.alpha = 0.0
self.view.layoutIfNeeded()
self.bottomSheetCoverView.isHidden = false
}) { _ in
}, completion: { _ in
if self.presentingViewController != nil {
self.dismiss(animated: false, completion: nil)
}
}
})
Comment on lines +189 to +193
Copy link
Member

Choose a reason for hiding this comment

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

이것도 워닝 해결이죵? 굳입니다!

}

// 바텀 시트 사라지고 바로 다시 다음 바텀 시트 올라오는 애니메이션
Expand All @@ -202,7 +202,7 @@ class CommonBottomSheetViewController: UIViewController {
self.dimmedBackView.alpha = 0.0
self.view.layoutIfNeeded()
self.bottomSheetCoverView.isHidden = false
}) { _ in
}, completion: { _ in
if self.presentingViewController != nil {
guard let presentingVC = self.presentingViewController else { return }
self.dismiss(animated: false) {
Expand All @@ -211,7 +211,7 @@ class CommonBottomSheetViewController: UIViewController {
presentingVC.present(nextVC, animated: false, completion: nil)
}
}
}
})
}

func hideBottomSheetAndPresentVC(nextViewController: UIViewController) {
Expand All @@ -222,7 +222,7 @@ class CommonBottomSheetViewController: UIViewController {
self.dimmedBackView.alpha = 0.0
self.view.layoutIfNeeded()
self.bottomSheetCoverView.isHidden = false
}) { _ in
}, completion: { _ in
if self.presentingViewController != nil {
guard let presentingVC = self.presentingViewController else { return }
self.dismiss(animated: false) {
Expand All @@ -231,7 +231,7 @@ class CommonBottomSheetViewController: UIViewController {
presentingVC.present(nextVC, animated: true, completion: nil)
}
}
}
})
}

// UITapGestureRecognizer 연결 함수 부분
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//
// GroupNameEditBottomSheetViewController.swift
// NADA-iOS-forRelease
//
// Created by 민 on 2021/12/11.
//

import UIKit
import IQKeyboardManagerSwift

class GroupNameEditBottomSheetViewController: CommonBottomSheetViewController, UITextFieldDelegate {
Copy link
Member

Choose a reason for hiding this comment

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

슬랙봤어여! 기디결정에 따라서 수정할수도 있을텐데 화이팅입니다!


// MARK: - Properties

// 넘어온 그룹 이름 데이터를 받는 변수 선언
var text: String = ""

// 그룹 추가 텍스트 필드
private let addGroupTextField: UITextField = {
let textField = UITextField()
textField.borderStyle = .none
textField.cornerRadius = 10
textField.backgroundColor = .textBox
textField.attributedPlaceholder = NSAttributedString(string: "변경할 그룹명을 입력하세요.", attributes: [.foregroundColor: UIColor.quaternary, .font: UIFont.textRegular04])
textField.returnKeyType = .done
textField.setLeftPaddingPoints(12)
textField.setRightPaddingPoints(12)

return textField
}()

private let checkImageView: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(named: "iconDone")

return imageView
}()

private let explainLabel: UILabel = {
let label = UILabel()
label.text = "새로운 그룹은 최대 4개까지만 등록 가능합니다."
label.textColor = .mainColorButtonText
label.font = .textRegular05

return label
}()

// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()

setupUI()
addGroupTextField.delegate = self
IQKeyboardManager.shared.shouldResignOnTouchOutside = false
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

self.addGroupTextField.becomeFirstResponder()
}

// MARK: - @Functions
// UI 세팅 작업
private func setupUI() {
view.addSubview(addGroupTextField)
view.addSubview(checkImageView)
view.addSubview(explainLabel)

setupLayout()

addGroupTextField.text = text
}

// 레이아웃 세팅
private func setupLayout() {
addGroupTextField.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
addGroupTextField.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 20),
addGroupTextField.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 24),
addGroupTextField.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -24),
addGroupTextField.heightAnchor.constraint(equalToConstant: 45)
])

checkImageView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
checkImageView.topAnchor.constraint(equalTo: addGroupTextField.bottomAnchor, constant: 7),
checkImageView.leadingAnchor.constraint(equalTo: addGroupTextField.leadingAnchor, constant: 4),
checkImageView.widthAnchor.constraint(equalToConstant: 16),
checkImageView.heightAnchor.constraint(equalToConstant: 16)
])

explainLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
explainLabel.topAnchor.constraint(equalTo: addGroupTextField.bottomAnchor, constant: 8),
explainLabel.leadingAnchor.constraint(equalTo: checkImageView.trailingAnchor, constant: 5)
])
}
}

extension GroupNameEditBottomSheetViewController {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
hideBottomSheetAndGoBack()
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class CardHarmonyViewController: UIViewController {
self.dimmedBackView.alpha = 0.0
self.view.layoutIfNeeded()
self.popUpView.isHidden = true
}) { _ in
}, completion: { _ in
if self.presentingViewController != nil {
self.dismiss(animated: false, completion: nil)
}
}
})
}

var percentageColor: UIColor?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import UIKit

class GroupEditViewController: UIViewController {

class GroupEditViewController: UIViewController, GroupEditViewDelegate {
// MARK: - Properties
var cardItems = ["SOPT", "동아리", "학교", "NADA NADA NADA NADA NADA"]

Expand All @@ -32,11 +32,30 @@ class GroupEditViewController: UIViewController {

@IBAction func presentToAddGroupBottom(_ sender: UIButton) {
let nextVC = AddGroupBottomSheetViewController()
.setTitle("그룹 추가")
.setHeight(184)
.setTitle("그룹 추가")
.setHeight(184)
nextVC.modalPresentationStyle = .overFullScreen
self.present(nextVC, animated: false, completion: nil)
}
}

// MARK: - Extensions
extension GroupEditViewController {

func presentToGroupNameEdit(_ sender: UILabel) {
let contentView = sender.superview
guard let cell = contentView?.superview as? UITableViewCell else { return }
let index = groupEditTableView.indexPath(for: cell)

let nextVC = GroupNameEditBottomSheetViewController()
.setTitle("그룹명 변경")
.setHeight(184)
nextVC.modalPresentationStyle = .overFullScreen
nextVC.text = cardItems[index!.row]
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
Member Author

Choose a reason for hiding this comment

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

맞네욥!!! 좋은 피드백 감사합니당 ^__^


self.present(nextVC, animated: false, completion: nil)
}

}

// MARK: - TableView Delegate
Expand All @@ -51,7 +70,7 @@ extension GroupEditViewController: UITableViewDelegate {
self.makeCancelDeleteAlert(title: "그룹 삭제", message: "해당 그룹에 있던 명함은\n미분류 그룹으로 이동합니다.", cancelAction: { _ in
// 취소 눌렀을 때 액션이 들어갈 부분
}, deleteAction: { _ in
//
//
})
})
deleteAction.backgroundColor = .red
Expand All @@ -61,6 +80,7 @@ extension GroupEditViewController: UITableViewDelegate {

return swipeActions
}

}

// MARK: - TableView DataSource
Expand All @@ -73,6 +93,7 @@ extension GroupEditViewController: UITableViewDataSource {
guard let serviceCell = tableView.dequeueReusableCell(withIdentifier: Const.Xib.groupEditTableViewCell, for: indexPath) as? GroupEditTableViewCell else { return UITableViewCell() }

serviceCell.initData(title: cardItems[indexPath.row])
serviceCell.delegate = self

return serviceCell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extension LoginViewController {
} else {
print("loginWithKakaoTalk() success.")

UserApi.shared.me() {(user, error) in
UserApi.shared.me {(user, error) in
if let error = error {
print(error)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SplashViewController: UIViewController {
// Do any additional setup after loading the view.
}


/*
// MARK: - Navigation

Expand Down