From e3f1623e562f1933f301570cc516fb192ec2b7e6 Mon Sep 17 00:00:00 2001 From: hyungyu Kim Date: Sun, 28 Nov 2021 02:21:46 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[ADD]=20#88=20-=20=EB=AA=85=ED=95=A8?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EB=B7=B0=EC=97=90=EC=84=9C=20=ED=94=BC?= =?UTF-8?q?=EC=BB=A4=EB=B7=B0=EB=A1=9C=20=EC=83=9D=EB=85=84=EC=9B=94?= =?UTF-8?q?=EC=9D=BC,=20mbti=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Descriptions - 주석삭제 - FrontCardCreationViewCell 에 estimatedItemSize 를 zero 으로 설정(스보 설정 대신) --- .../Resouces/Extensions/UIViewController+Extension.swift | 8 -------- .../FrontCardCreationCollectionViewCell.swift | 4 ++++ .../CreationCard/FrontCardCreationCollectionViewCell.xib | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift b/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift index d94312d9..020a6412 100644 --- a/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift +++ b/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift @@ -16,18 +16,10 @@ extension UIViewController { cancelAction: ((UIAlertAction) -> Void)? = nil, deleteAction: ((UIAlertAction) -> Void)?, completion: (() -> Void)? = nil) { - let alertViewController = UIAlertController(title: title, message: message, preferredStyle: .alert) - // FIXME: - 민재선배 아래주석 삭제해도 되나요?? - // alertViewController.setTitle(font: UIFont.boldSystemFont(ofSize: 17), color: UIColor.white) - // alertViewController.setMessage(font: UIFont.systemFont(ofSize: 13), color: UIColor.white) - // alertViewController.setTint(color: .mainBlue) - - // alertViewController.view.subviews.first?.subviews.first?.subviews.first?.backgroundColor = UIColor(red: 30/255, green: 30/255, blue: 30/255, alpha: 3/4) - let cancelAction = UIAlertAction(title: "취소", style: .cancel, handler: cancelAction) alertViewController.addAction(cancelAction) diff --git a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift index f3d7353d..97f1e649 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift @@ -59,6 +59,7 @@ extension FrontCardCreationCollectionViewCell { backgroundSettingCollectionView.backgroundColor = .background let collectionViewLayout = backgroundSettingCollectionView.collectionViewLayout as? UICollectionViewFlowLayout + collectionViewLayout?.estimatedItemSize = .zero collectionViewLayout?.scrollDirection = .horizontal let backgroundAttributeString = NSMutableAttributedString(string: "*명함의 배경을 선택해 주세요.") @@ -176,6 +177,9 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDelegateFlowLayou return UIEdgeInsets(top: 0, left: 26, bottom: 0, right: 26) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + return 0 + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { return 12 } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { diff --git a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.xib b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.xib index b0099cc2..bbe18b1b 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.xib +++ b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.xib @@ -36,7 +36,7 @@ - + From e5bda067041a4bfc5d607157cb7f752c6e3a0c19 Mon Sep 17 00:00:00 2001 From: MinjaeLee <2alswo7@khu.ac.kr> Date: Tue, 30 Nov 2021 21:36:36 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[FEAT]=20#91=20-=20UserDefault=EA=B0=92?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=8B=A4=ED=81=AC/=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=AA=A8=EB=93=9C=20=EC=84=A0=ED=83=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NADA-iOS-forRelease/Info.plist | 2 +- .../Resouces/Storyboards/More/More.storyboard | 49 +++++++++++++++++-- .../MoreList/MoreListTableViewCell.swift | 18 ------- .../Cells/MoreList/MoreListTableViewCell.xib | 10 ---- .../More/MoreViewController.swift | 40 +++++++++------ .../TabBar/TabBarViewController.swift | 25 ++++++++-- 6 files changed, 94 insertions(+), 50 deletions(-) diff --git a/NADA-iOS-forRelease/Info.plist b/NADA-iOS-forRelease/Info.plist index e677c70c..b68dc74d 100644 --- a/NADA-iOS-forRelease/Info.plist +++ b/NADA-iOS-forRelease/Info.plist @@ -3,7 +3,7 @@ UIUserInterfaceStyle - + Light UIAppFonts NotoSansCJKkr-Bold.otf diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard index 1310fb1d..b9a9d0b5 100644 --- a/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard +++ b/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard @@ -12,6 +12,9 @@ SpoqaHanSansNeo-Bold + + SpoqaHanSansNeo-Regular + @@ -41,11 +44,46 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,12 +100,14 @@ + + - + @@ -79,6 +119,9 @@ + + + diff --git a/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.swift index 1ff9b031..6eacf75e 100644 --- a/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.swift @@ -9,26 +9,12 @@ import UIKit class MoreListTableViewCell: UITableViewCell { - let myUserDefaults = UserDefaults.standard - @IBOutlet weak var titleLabel: UILabel! - @IBOutlet weak var modeSwitch: UISwitch! @IBOutlet weak var separatorView: UIView! override func awakeFromNib() { super.awakeFromNib() - // Initialization code - setModeBySwitch() - } - - @IBAction func modeChangeButton(_ sender: Any) { - myUserDefaults.set(modeSwitch.isOn, forKey: "switchState") - if #available(iOS 13, *) { - window!.overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light - } else { - window?.overrideUserInterfaceStyle = .light - } } static func nib() -> UINib { @@ -39,8 +25,4 @@ class MoreListTableViewCell: UITableViewCell { super.setSelected(selected, animated: animated) } - - func setModeBySwitch() { - modeSwitch.isOn = myUserDefaults.bool(forKey: "switchState") - } } diff --git a/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.xib b/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.xib index 5124b56d..0f87d056 100644 --- a/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.xib +++ b/NADA-iOS-forRelease/Sources/Cells/MoreList/MoreListTableViewCell.xib @@ -34,29 +34,19 @@ - - - - - - - - - - diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift index 180d7d4e..064a3e86 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift @@ -9,20 +9,37 @@ import UIKit class MoreViewController: UIViewController { - var firstItems = ["다크 모드"] - var secondItems = ["개인정보 처리방침", "서비스 이용약관", "Team NADA", "오픈소스 라이브러리"] - var thirdItems = ["로그아웃", "정보 초기화", "회원탈퇴"] + let defaults = UserDefaults.standard + + var firstItems = ["개인정보 처리방침", "서비스 이용약관", "Team NADA", "오픈소스 라이브러리"] + var secondItems = ["로그아웃", "정보 초기화", "회원탈퇴"] @IBOutlet weak var moreListTableView: UITableView! + @IBOutlet weak var darkModeHeaderView: UIView! + @IBOutlet weak var modeSwitch: UISwitch! override func viewDidLoad() { super.viewDidLoad() - + moreListTableView.register(MoreListTableViewCell.nib(), forCellReuseIdentifier: "MoreListTableViewCell") moreListTableView.delegate = self moreListTableView.dataSource = self + moreListTableView.tableHeaderView = darkModeHeaderView + + modeSwitch.isOn = defaults.bool(forKey: "darkModeState") + overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light + } + + @IBAction func darkModeChangeSwitch(_ sender: UISwitch) { + if #available(iOS 13, *) { + overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light + defaults.set(modeSwitch.isOn, forKey: "darkModeState") + } else { + overrideUserInterfaceStyle = .light + } } + } // MARK: - TableView Delegate @@ -39,18 +56,17 @@ extension MoreViewController: UITableViewDataSource { return firstItems.count } else if section == 1 { return secondItems.count - } else if section == 2 { - return thirdItems.count } else { return 0 } } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - if section == 2 { + if section == 0 { + return 5 + } else { return 0 } - return 5 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { @@ -63,14 +79,8 @@ extension MoreViewController: UITableViewDataSource { } } else if indexPath.section == 1 { serviceCell.titleLabel.text = secondItems[indexPath.row] - serviceCell.modeSwitch.isHidden = true - if indexPath.row == secondItems.count - 1 { - serviceCell.separatorView.isHidden = true - } - } else if indexPath.section == 2 { - serviceCell.titleLabel.text = thirdItems[indexPath.row] - serviceCell.modeSwitch.isHidden = true } + return serviceCell } } diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/TabBar/TabBarViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/TabBar/TabBarViewController.swift index 4c507f00..37cb340a 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/TabBar/TabBarViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/TabBar/TabBarViewController.swift @@ -8,11 +8,30 @@ import UIKit class TabBarViewController: UITabBarController { + + let appearance = UITabBarAppearance() override func viewDidLoad() { super.viewDidLoad() - - // Do any additional setup after loading the view. + + setupStyle() + } + + func setupStyle() { +// appearance.configureWithOpaqueBackground() +// appearance.shadowColor = UIColor.clear +// tabBar.standardAppearance = appearance +// +// if #available(iOS 15.0, *) { +// // set tabbar opacity +// tabBar.scrollEdgeAppearance = tabBar.standardAppearance +// } +// +// // set tabbar shadow +// tabBar.layer.masksToBounds = false +// tabBar.layer.shadowColor = UIColor.textBox.cgColor +// tabBar.layer.shadowOpacity = 0.3 +// tabBar.layer.shadowOffset = CGSize(width: 0, height: 0) +// tabBar.layer.shadowRadius = 6 } - } From fc8486a06eb537ff12dccf00dd6aa7c72b00e8f8 Mon Sep 17 00:00:00 2001 From: MinjaeLee <2alswo7@khu.ac.kr> Date: Tue, 30 Nov 2021 23:28:09 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[FEAT]=20#91=20-=20=EB=8B=A4=ED=81=AC/?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=ED=8A=B8=EB=8A=94=20=EC=9D=BC=EB=8B=A8=20?= =?UTF-8?q?=EC=8B=9C=EC=8A=A4=ED=85=9C=EC=9C=BC=EB=A1=9C=20=EB=B3=B4?= =?UTF-8?q?=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NADA-iOS-forRelease/Info.plist | 2 -- .../UIViewController+Extension.swift | 1 - .../Main/FrontViewController.swift | 2 +- .../More/MoreViewController.swift | 30 +++++++++++++------ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/NADA-iOS-forRelease/Info.plist b/NADA-iOS-forRelease/Info.plist index b68dc74d..baa72bcd 100644 --- a/NADA-iOS-forRelease/Info.plist +++ b/NADA-iOS-forRelease/Info.plist @@ -2,8 +2,6 @@ - UIUserInterfaceStyle - Light UIAppFonts NotoSansCJKkr-Bold.otf diff --git a/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift b/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift index f9a78b07..9ba4e9ae 100644 --- a/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift +++ b/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift @@ -9,7 +9,6 @@ import Foundation import UIKit extension UIViewController { - /// 취소+삭제 UIAlertController func makeCancelDeleteAlert(title: String, message: String, diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift index cde75efd..1d1563ec 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/Main/FrontViewController.swift @@ -55,7 +55,7 @@ class FrontViewController: UIViewController { setFrontList() setBackList() - + // TODO: - 서버 테스트 // cardListFetchWithAPI(userID: "nada", isList: false, offset: 0) } diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift index 064a3e86..22f109c5 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift @@ -6,6 +6,7 @@ // import UIKit +import SkeletonView class MoreViewController: UIViewController { @@ -27,19 +28,30 @@ class MoreViewController: UIViewController { moreListTableView.dataSource = self moreListTableView.tableHeaderView = darkModeHeaderView - modeSwitch.isOn = defaults.bool(forKey: "darkModeState") - overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light + // TODO: - 다크 모드 대응용 서버 코드 + // modeSwitch.isOn = defaults.bool(forKey: "darkModeState") + +// if let window = UIApplication.shared.windows.first { +// if #available(iOS 13.0, *) { +// window.overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light +// defaults.set(modeSwitch.isOn, forKey: "darkModeState") +// } else { +// window.overrideUserInterfaceStyle = .light +// } +// } } @IBAction func darkModeChangeSwitch(_ sender: UISwitch) { - if #available(iOS 13, *) { - overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light - defaults.set(modeSwitch.isOn, forKey: "darkModeState") - } else { - overrideUserInterfaceStyle = .light - } + // TODO: - 다크 모드 대응용 서버 코드 +// if let window = UIApplication.shared.windows.first { +// if #available(iOS 13.0, *) { +// window.overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light +// defaults.set(modeSwitch.isOn, forKey: "darkModeState") +// } else { +// window.overrideUserInterfaceStyle = .light +// } +// } } - } // MARK: - TableView Delegate From 7455b496d37f44f0d1a86bb39f650cfed4ceb530 Mon Sep 17 00:00:00 2001 From: MinjaeLee <2alswo7@khu.ac.kr> Date: Wed, 1 Dec 2021 08:32:53 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[FEAT]=20#91=20-=20=EB=8D=94=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EB=B7=B0=20=EB=8B=A4=ED=81=AC=20=EB=AA=A8=EB=93=9C?= =?UTF-8?q?=20=EC=A0=84=ED=99=98=20=EC=8A=A4=EC=9C=84=EC=B9=98=20=EC=85=80?= =?UTF-8?q?=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resouces/Storyboards/More/More.storyboard | 47 +------------------ .../More/MoreViewController.swift | 12 ++--- 2 files changed, 8 insertions(+), 51 deletions(-) diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard index b9a9d0b5..2219b576 100644 --- a/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard +++ b/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard @@ -12,9 +12,6 @@ SpoqaHanSansNeo-Bold - - SpoqaHanSansNeo-Regular - @@ -44,46 +41,11 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -100,8 +62,6 @@ - - @@ -119,9 +79,6 @@ - - - diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift index 22f109c5..f5428341 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift @@ -16,8 +16,8 @@ class MoreViewController: UIViewController { var secondItems = ["로그아웃", "정보 초기화", "회원탈퇴"] @IBOutlet weak var moreListTableView: UITableView! - @IBOutlet weak var darkModeHeaderView: UIView! - @IBOutlet weak var modeSwitch: UISwitch! +// @IBOutlet weak var darkModeHeaderView: UIView! +// @IBOutlet weak var modeSwitch: UISwitch! override func viewDidLoad() { super.viewDidLoad() @@ -26,7 +26,7 @@ class MoreViewController: UIViewController { moreListTableView.delegate = self moreListTableView.dataSource = self - moreListTableView.tableHeaderView = darkModeHeaderView + // moreListTableView.tableHeaderView = darkModeHeaderView // TODO: - 다크 모드 대응용 서버 코드 // modeSwitch.isOn = defaults.bool(forKey: "darkModeState") @@ -41,8 +41,8 @@ class MoreViewController: UIViewController { // } } - @IBAction func darkModeChangeSwitch(_ sender: UISwitch) { - // TODO: - 다크 모드 대응용 서버 코드 +// @IBAction func darkModeChangeSwitch(_ sender: UISwitch) { +// // TODO: - 다크 모드 대응용 서버 코드 // if let window = UIApplication.shared.windows.first { // if #available(iOS 13.0, *) { // window.overrideUserInterfaceStyle = modeSwitch.isOn == true ? .dark : .light @@ -51,7 +51,7 @@ class MoreViewController: UIViewController { // window.overrideUserInterfaceStyle = .light // } // } - } +// } } // MARK: - TableView Delegate From a5fb85d69f9d0965d9c3088acf36e2d03719d25f Mon Sep 17 00:00:00 2001 From: MinjaeLee <2alswo7@khu.ac.kr> Date: Wed, 1 Dec 2021 08:34:49 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[REFACTOR]=20#91=20-=20=EB=8D=94=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EB=B7=B0=20=EB=8B=A4=ED=81=AC=20=EB=AA=A8=EB=93=9C?= =?UTF-8?q?=20=EC=A0=84=ED=99=98=20=EC=8A=A4=EC=9C=84=EC=B9=98=20=EC=85=80?= =?UTF-8?q?=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ViewControllers/More/MoreViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift index f5428341..5eff4a53 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/More/MoreViewController.swift @@ -6,7 +6,6 @@ // import UIKit -import SkeletonView class MoreViewController: UIViewController { From de3d09aab2053eac1395c5b36742a3c28b9e4c86 Mon Sep 17 00:00:00 2001 From: hyungyu Kim Date: Wed, 1 Dec 2021 16:51:23 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[FEAT]=20#88=20-=20=EB=AA=85=ED=95=A8?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EB=B7=B0=EC=97=90=EC=84=9C=20=ED=94=BC?= =?UTF-8?q?=EC=BB=A4=EB=B7=B0=EB=A1=9C=20=EC=83=9D=EB=85=84=EC=9B=94?= =?UTF-8?q?=EC=9D=BC,=20mbti=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Descriptions - Notification Center 을 활용해서 바텀시트에서 데이터 전달 - SelectBirthBottomViewController: 생년월일 커스텀 바텀시트 뷰 - SelectMBTIBottomViewController: MBTI 커스텀 바텀시트 뷰 --- NADA-iOS-forRelease.xcodeproj/project.pbxproj | 20 ++- .../Resouces/Constants/Notification.swift | 7 +- .../FrontCardCreationCollectionViewCell.swift | 44 ++++- .../BackCardCreationDelegate.swift | 0 .../FrontCardCreationDelegate.swift | 0 .../SelectBirthBottomViewController.swift | 154 ++++++++++++++++ .../SelectMBTIBottomViewController.swift | 167 ++++++++++++++++++ .../CardCreationPreviewViewController.swift | 5 +- .../CardCreationViewController.swift | 16 ++ 9 files changed, 399 insertions(+), 14 deletions(-) rename NADA-iOS-forRelease/Sources/Protocols/{ => CardCreation}/BackCardCreationDelegate.swift (100%) rename NADA-iOS-forRelease/Sources/Protocols/{ => CardCreation}/FrontCardCreationDelegate.swift (100%) create mode 100644 NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectBirthBottomViewController.swift create mode 100644 NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectMBTIBottomViewController.swift diff --git a/NADA-iOS-forRelease.xcodeproj/project.pbxproj b/NADA-iOS-forRelease.xcodeproj/project.pbxproj index 9eb326a7..57e2b2aa 100644 --- a/NADA-iOS-forRelease.xcodeproj/project.pbxproj +++ b/NADA-iOS-forRelease.xcodeproj/project.pbxproj @@ -86,6 +86,8 @@ F87122762733046300A24E74 /* Card.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87122752733046300A24E74 /* Card.swift */; }; F871227827330A3800A24E74 /* CardCreationRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F871227727330A3800A24E74 /* CardCreationRequest.swift */; }; F8719DDB274F92E90081AD51 /* UITextField+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8719DDA274F92E90081AD51 /* UITextField+Extension.swift */; }; + F8915A22275728F20013D609 /* SelectBirthBottomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8915A20275728F20013D609 /* SelectBirthBottomViewController.swift */; }; + F8915A23275728F20013D609 /* SelectMBTIBottomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8915A21275728F20013D609 /* SelectMBTIBottomViewController.swift */; }; F8A9FE1A2743DC6B00BC60CE /* CardListInGroupRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A9FE192743DC6B00BC60CE /* CardListInGroupRequest.swift */; }; F8C310C0273A7360008EC5BA /* FrontCardCreationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C310BF273A7360008EC5BA /* FrontCardCreationDelegate.swift */; }; F8C83FAE272F99940009DF0D /* MoyaLoggerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C83FAD272F99940009DF0D /* MoyaLoggerPlugin.swift */; }; @@ -195,6 +197,8 @@ F87122752733046300A24E74 /* Card.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = ""; }; F871227727330A3800A24E74 /* CardCreationRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardCreationRequest.swift; sourceTree = ""; }; F8719DDA274F92E90081AD51 /* UITextField+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Extension.swift"; sourceTree = ""; }; + F8915A20275728F20013D609 /* SelectBirthBottomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectBirthBottomViewController.swift; sourceTree = ""; }; + F8915A21275728F20013D609 /* SelectMBTIBottomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectMBTIBottomViewController.swift; sourceTree = ""; }; F8A9FE192743DC6B00BC60CE /* CardListInGroupRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardListInGroupRequest.swift; sourceTree = ""; }; F8C310BF273A7360008EC5BA /* FrontCardCreationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrontCardCreationDelegate.swift; sourceTree = ""; }; F8C83FAD272F99940009DF0D /* MoyaLoggerPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoyaLoggerPlugin.swift; sourceTree = ""; }; @@ -380,6 +384,8 @@ 398413B6274A7A1E005550BC /* AddGroupBottomSheetViewController.swift */, 77703156275005AA002CBD19 /* CardResultBottomSheetViewController.swift */, 7713E8472752E2A900724C8B /* SelectGroupBottomSheetViewController.swift */, + F8915A20275728F20013D609 /* SelectBirthBottomViewController.swift */, + F8915A21275728F20013D609 /* SelectMBTIBottomViewController.swift */, ); path = BottomSheet; sourceTree = ""; @@ -518,6 +524,15 @@ path = Card; sourceTree = ""; }; + F8915A1F275713A10013D609 /* CardCreation */ = { + isa = PBXGroup; + children = ( + F8FC43B226C020B90033E151 /* BackCardCreationDelegate.swift */, + F8C310BF273A7360008EC5BA /* FrontCardCreationDelegate.swift */, + ); + path = CardCreation; + sourceTree = ""; + }; F8C83FAC272F998A0009DF0D /* Plugin */ = { isa = PBXGroup; children = ( @@ -677,8 +692,7 @@ F8FC439F26C01EFC0033E151 /* Protocols */ = { isa = PBXGroup; children = ( - F8FC43B226C020B90033E151 /* BackCardCreationDelegate.swift */, - F8C310BF273A7360008EC5BA /* FrontCardCreationDelegate.swift */, + F8915A1F275713A10013D609 /* CardCreation */, ); path = Protocols; sourceTree = ""; @@ -977,7 +991,9 @@ F822E7A92709CEB60020452C /* Notification.swift in Sources */, F8C83FC5272FA2940009DF0D /* CardAPI.swift in Sources */, 7729171F2743D604001593E0 /* CardsInGroupResponse.swift in Sources */, + F8915A22275728F20013D609 /* SelectBirthBottomViewController.swift in Sources */, F8FC438626C01CDD0033E151 /* AppDelegate.swift in Sources */, + F8915A23275728F20013D609 /* SelectMBTIBottomViewController.swift in Sources */, F8C83FB8272F9E3F0009DF0D /* UtilAPI.swift in Sources */, F8FC438826C01CDD0033E151 /* SceneDelegate.swift in Sources */, 39288E12273F52B20072F403 /* CardListLookUpRequest.swift in Sources */, diff --git a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift index 33925e7d..e0fe84a1 100644 --- a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift +++ b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift @@ -8,9 +8,10 @@ import Foundation extension Notification.Name { - // delegate 패턴으로 대체 -// static let frontCardtextFieldIsEmpty = Notification.Name("frontCardtextFieldIsEmpty") -// static let backCardtextFieldIsEmpty = Notification.Name("backCardtextFieldIsEmpty") static let deleteTabBar = NSNotification.Name("deleteTabBar") static let expressTabBar = NSNotification.Name("expressTabBar") + + // MARK: - Card Creation + static let frontCardBirth = Notification.Name("frontCardBirth") + static let frontCardMBTI = Notification.Name("frontCardMBTI") } diff --git a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift index 97f1e649..2a82a019 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift @@ -9,12 +9,17 @@ import UIKit class FrontCardCreationCollectionViewCell: UICollectionViewCell { + // MARK: - Protocols + + public weak var frontCardCreationDelegate: FrontCardCreationDelegate? + // MARK: - Properties private let backgroundList = ["img", "img", "img", "img", "img"] private var requiredTextFieldList = [UITextField]() private var optionalTextFieldList = [UITextField]() - public weak var frontCardCreationDelegate: FrontCardCreationDelegate? + public var presentingBirthBottomVCClosure: (() -> Void)? + public var presentingMBTIBottomVCClosure: (() -> Void)? // MARK: - @IBOutlet Properties @@ -44,6 +49,7 @@ class FrontCardCreationCollectionViewCell: UICollectionViewCell { setUI() registerCell() textFieldDelegate() + setNotification() } } @@ -97,7 +103,7 @@ extension FrontCardCreationCollectionViewCell { NSAttributedString.Key.foregroundColor: UIColor.quaternary ]) - instagramIDTextField.attributedPlaceholder = NSAttributedString(string: "Instagram", attributes: [ + instagramIDTextField.attributedPlaceholder = NSAttributedString(string: "Instagram (@ 제외)", attributes: [ NSAttributedString.Key.foregroundColor: UIColor.quaternary ]) linkURLTextField.attributedPlaceholder = NSAttributedString(string: "URL (Github, Blog)", attributes: [ @@ -147,9 +153,29 @@ extension FrontCardCreationCollectionViewCell { _ = requiredTextFieldList.map { $0.delegate = self } _ = optionalTextFieldList.map { $0.delegate = self } } + private func setNotification() { + NotificationCenter.default.addObserver(self, selector: #selector(setBirthTextField(notification:)), name: .frontCardBirth, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(setMBTITextField(notification:)), name: .frontCardMBTI, object: nil) + } static func nib() -> UINib { return UINib(nibName: Const.Xib.frontCardCreationCollectionViewCell, bundle: Bundle(for: FrontCardCreationCollectionViewCell.self)) } + + // MARK: - @objc Methods + + @objc + private func setBirthTextField(notification: NSNotification) { + birthTextField.text = notification.object as? String + + birthTextField.borderWidth = 0 + } + + @objc + private func setMBTITextField(notification: NSNotification) { + mbtiTextField.text = notification.object as? String + + mbtiTextField.borderWidth = 0 + } } // MARK: - UICollectionViewDelegate @@ -190,9 +216,16 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDelegateFlowLayou // MARK: - UITextFieldDelegate extension FrontCardCreationCollectionViewCell: UITextFieldDelegate { func textFieldDidBeginEditing(_ textField: UITextField) { - textField.borderWidth = 1 - textField.borderColor = .tertiary - textField.becomeFirstResponder() + if textField == birthTextField { + textField.endEditing(true) + presentingBirthBottomVCClosure?() + } else if textField == mbtiTextField { + textField.endEditing(true) + presentingMBTIBottomVCClosure?() + } else { + textField.borderWidth = 1 + textField.borderColor = .tertiary + } } func textFieldDidEndEditing(_ textField: UITextField) { frontCardCreationDelegate?.frontCardCreation(endEditing: true) @@ -215,6 +248,7 @@ extension FrontCardCreationCollectionViewCell: UITextFieldDelegate { } else { frontCardCreationDelegate?.frontCardCreation(requiredInfo: false) } + textField.resignFirstResponder() textField.borderWidth = 0 } func textFieldShouldReturn(_ textField: UITextField) -> Bool { diff --git a/NADA-iOS-forRelease/Sources/Protocols/BackCardCreationDelegate.swift b/NADA-iOS-forRelease/Sources/Protocols/CardCreation/BackCardCreationDelegate.swift similarity index 100% rename from NADA-iOS-forRelease/Sources/Protocols/BackCardCreationDelegate.swift rename to NADA-iOS-forRelease/Sources/Protocols/CardCreation/BackCardCreationDelegate.swift diff --git a/NADA-iOS-forRelease/Sources/Protocols/FrontCardCreationDelegate.swift b/NADA-iOS-forRelease/Sources/Protocols/CardCreation/FrontCardCreationDelegate.swift similarity index 100% rename from NADA-iOS-forRelease/Sources/Protocols/FrontCardCreationDelegate.swift rename to NADA-iOS-forRelease/Sources/Protocols/CardCreation/FrontCardCreationDelegate.swift diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectBirthBottomViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectBirthBottomViewController.swift new file mode 100644 index 00000000..2de5e31f --- /dev/null +++ b/NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectBirthBottomViewController.swift @@ -0,0 +1,154 @@ +// +// SelectBirthBottomViewController.swift +// NADA-iOS-forRelease +// +// Created by kimhyungyu on 2021/11/30. +// + +import UIKit + +class SelectBirthBottomSheetViewController: CommonBottomSheetViewController { + + // MARK: - Properties + + private let yearList: [String] = [Int](1950...2021).map { String($0) }.reversed() + private let monthList: [String] = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"] + private let dayList: [String] = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"] + private var year = String() + private var month = String() + private var day = String() + private var selectedBirth = String() + + // MARK: - Components + + private let birthPicker: UIPickerView = { + let pickerView = UIPickerView() + + return pickerView + }() + + private let doneButton: UIButton = { + let button = UIButton() + button.setImage(UIImage(named: "btnMainDone"), for: .normal) + button.addTarget(self, action: #selector(dismissToCardCreationViewController), for: .touchUpInside) + + return button + }() + + // MARK: - View Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + + setupUI() + } +} + +// MARK: - Extensions + +extension SelectBirthBottomSheetViewController { + private func setupUI() { + view.addSubview(birthPicker) + view.addSubview(doneButton) + + selectedBirth = yearList[0] + "/" + monthList[0] + "/" + dayList[0] + + birthPicker.delegate = self + birthPicker.dataSource = self + + setupLayout() + } + private func setupLayout() { + birthPicker.selectedRow(inComponent: 0) + birthPicker.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + birthPicker.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: -20), + birthPicker.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor), + birthPicker.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16), + birthPicker.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16) + ]) + + doneButton.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + doneButton.topAnchor.constraint(equalTo: birthPicker.bottomAnchor, constant: 0), + doneButton.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor), + doneButton.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 24), + doneButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -24) + ]) + } + + // MARK: - @objc Methods + + @objc func dismissToCardCreationViewController() { + NotificationCenter.default.post(name: .frontCardBirth, object: selectedBirth) + dismiss(animated: true, completion: nil) + } + +} + +extension SelectBirthBottomSheetViewController: UIPickerViewDelegate, UIPickerViewDataSource { + func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 3 + } + + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + if component == 0 { + return yearList.count + } else if component == 1 { + return monthList.count + } else { + return dayList.count + } + } + + func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { + let label = (view as? UILabel) ?? UILabel() + + label.textAlignment = .center + + if component == 0 { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: yearList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: yearList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } else if component == 1 { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: monthList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: monthList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } else if component == 2 { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: dayList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: dayList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } + + return label + } + + func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + pickerView.reloadAllComponents() + + if component == 0 { + year = yearList[row] + } else if component == 1 { + month = monthList[row] + } else if component == 2 { + day = dayList[row] + } + year = year.isEmpty ? yearList[0] : year + month = month.isEmpty ? monthList[0] : month + day = day.isEmpty ? dayList[0] : day + selectedBirth = year + "/" + month + "/" + day + } + + func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { + return 44 + } +} diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectMBTIBottomViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectMBTIBottomViewController.swift new file mode 100644 index 00000000..72f7d310 --- /dev/null +++ b/NADA-iOS-forRelease/Sources/ViewControllers/BottomSheet/SelectMBTIBottomViewController.swift @@ -0,0 +1,167 @@ +// +// SelectMBTIBottomViewController.swift +// NADA-iOS-forRelease +// +// Created by kimhyungyu on 2021/12/01. +// + +import UIKit + +class SelectMBTIBottmViewController: CommonBottomSheetViewController { + + // MARK: - Properties + + private let firstList: [String] = ["E", "I"] + private let secondList: [String] = ["N", "S"] + private let thirdList: [String] = ["T", "F"] + private let fourthList: [String] = ["J", "P"] + private var first = String() + private var second = String() + private var third = String() + private var fourth = String() + private var selectedMBTI = String() + + // MARK: - Components + + private let mbtiPicker: UIPickerView = { + let pickerView = UIPickerView() + + return pickerView + }() + + private let doneButton: UIButton = { + let button = UIButton() + button.setImage(UIImage(named: "btnMainDone"), for: .normal) + button.addTarget(self, action: #selector(dismissToCardCreationViewController), for: .touchUpInside) + + return button + }() + + // MARK: - View Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + + setupUI() + } + + // MARK: - Methods + + // UI 세팅 작업 + private func setupUI() { + view.addSubview(mbtiPicker) + view.addSubview(doneButton) + + selectedMBTI = firstList[0] + secondList[0] + thirdList[0] + fourthList[0] + + mbtiPicker.delegate = self + mbtiPicker.dataSource = self + + setupLayout() + } + + // 레이아웃 세팅 + private func setupLayout() { + mbtiPicker.selectedRow(inComponent: 0) + mbtiPicker.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + mbtiPicker.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: -20), + mbtiPicker.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor) + ]) + + doneButton.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + doneButton.topAnchor.constraint(equalTo: mbtiPicker.bottomAnchor, constant: 0), + doneButton.centerXAnchor.constraint(equalTo: bottomSheetView.centerXAnchor) + ]) + } + + @objc func dismissToCardCreationViewController() { + NotificationCenter.default.post(name: .frontCardMBTI, object: selectedMBTI) + dismiss(animated: true, completion: nil) + } + +} + +extension SelectMBTIBottmViewController: UIPickerViewDelegate, UIPickerViewDataSource { + func numberOfComponents(in pickerView: UIPickerView) -> Int { + return 4 + } + + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + if component == 0 { + return firstList.count + } else if component == 1 { + return secondList.count + } else if component == 2 { + return thirdList.count + } else { + return fourthList.count + } + } + + func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { + let label = (view as? UILabel) ?? UILabel() + + label.textAlignment = .center + + if component == 0 { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: firstList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: firstList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } else if component == 1 { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: secondList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: secondList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } else if component == 2 { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: thirdList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: thirdList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } else { + if pickerView.selectedRow(inComponent: component) == row { + label.attributedText = NSAttributedString(string: fourthList[row], attributes: [NSAttributedString.Key.font: UIFont.textBold01, NSAttributedString.Key.foregroundColor: UIColor.mainColorNadaMain]) + + } else { + label.attributedText = NSAttributedString(string: fourthList[row], attributes: [NSAttributedString.Key.font: UIFont.textRegular03, NSAttributedString.Key.foregroundColor: UIColor.quaternary]) + } + } + return label + } + + func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + if component == 0 { + first = firstList[row] + } else if component == 1 { + second = secondList[row] + } else if component == 2 { + third = thirdList[row] + } else if component == 3 { + fourth = fourthList[row] + } + + first = first.isEmpty ? firstList[0] : first + second = second.isEmpty ? secondList[0] : second + third = third.isEmpty ? thirdList[0] : third + fourth = fourth.isEmpty ? fourthList[0] : fourth + + selectedMBTI = first + second + third + fourth + pickerView.reloadAllComponents() + } + + func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { + return 44 + } +// + func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat { + return CGFloat(pickerView.frame.size.width / 4) + } +} diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationPreviewViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationPreviewViewController.swift index 89dcf46e..d188a29f 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationPreviewViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationPreviewViewController.swift @@ -33,7 +33,7 @@ class CardCreationPreviewViewController: UIViewController { cardCreationRequest = CardCreationRequest(userID: "", frontCard: frontCardDataModel, backCard: backCardDataModel) guard let cardCreationRequest = cardCreationRequest else { return } // TODO: - 갤러리 추가/이미지 코드 추가 - cardCreationWithAPI(request: cardCreationRequest, image: UIImage(systemName: "card")!) + cardCreationWithAPI(request: cardCreationRequest, image: UIImage(named: "card")!) } @IBAction func touchBackButton(_ sender: Any) { navigationController?.popViewController(animated: true) @@ -78,9 +78,6 @@ extension CardCreationPreviewViewController { private func setFrontCardWith() { guard let frontCard = FrontCardCell.nib().instantiate(withOwner: self, options: nil).first as? FrontCardCell else { return } - // FIXME: - @IBDesignables err - // guard let frontCard = Bundle(for: FrontCardCell.self).loadNibNamed(Const.Xib.frontCardCell, owner: self, options: nil)?.first as? FrontCardCell else { return } - frontCard.frame = CGRect(x: 0, y: 0, width: cardView.frame.width, height: cardView.frame.height) // FIXME: - 갤러리 추가/주석해제 // guard let frontCardDataModel = frontCardDataModel else { return } diff --git a/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationViewController.swift b/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationViewController.swift index de393469..8d26fec3 100644 --- a/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationViewController.swift +++ b/NADA-iOS-forRelease/Sources/ViewControllers/CardCreation/CardCreationViewController.swift @@ -38,6 +38,8 @@ class CardCreationViewController: UIViewController { private var currentIndex = 0 private var frontCard: FrontCardDataModel? private var backCard: BackCardDataModel? + private var mbtiText: String? + private var birthText: String? // MARK: - @IBOutlet Properties @@ -301,6 +303,20 @@ extension CardCreationViewController: UICollectionViewDataSource { return UICollectionViewCell() } frontCreationCell.frontCardCreationDelegate = self + frontCreationCell.presentingBirthBottomVCClosure = { + let nextVC = SelectBirthBottomSheetViewController() + .setTitle("생년월일") + .setHeight(355) + nextVC.modalPresentationStyle = .overFullScreen + self.present(nextVC, animated: false, completion: nil) + } + frontCreationCell.presentingMBTIBottomVCClosure = { + let nextVC = SelectMBTIBottmViewController() + .setTitle("MBTI") + .setHeight(355) + nextVC.modalPresentationStyle = .overFullScreen + self.present(nextVC, animated: false, completion: nil) + } return frontCreationCell } else if indexPath.item == 1 { From 5aa93e8d29ebc2c61b07c46539deccccebaca407 Mon Sep 17 00:00:00 2001 From: hyungyu Kim Date: Thu, 2 Dec 2021 13:14:51 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[FEAT]=20#103=20-=20image=20picker=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20=EB=AA=85=ED=95=A8=EB=B0=B0?= =?UTF-8?q?=EA=B2=BD=20=EA=B3=A0=EB=A5=B4=EA=B8=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Descriptions - FrontCardCell 불투명 뷰 추가 - CardInGroupCell 불투명 뷰 추가 - 이미지피커뷰 추가 및 적용 - 배경 선택도 필수로 추가 --- NADA-iOS-forRelease/Info.plist | 19 ---- .../Resouces/Constants/Notification.swift | 2 + .../Cells/CardCell/FrontCardCell.swift | 19 ++++ .../Sources/Cells/CardCell/FrontCardCell.xib | 15 ++- .../BackCardCreationCollectionViewCell.swift | 12 ++- .../BackgroundCollectionViewCell.swift | 13 ++- .../BackgroundCollectionViewCell.xib | 22 ++++- .../FrontCardCreationCollectionViewCell.swift | 96 +++++++++++++------ .../CardInGroupCollectionViewCell.xib | 8 ++ .../CardCreationPreviewViewController.swift | 14 +-- .../CardCreationViewController.swift | 36 ++++++- 11 files changed, 186 insertions(+), 70 deletions(-) diff --git a/NADA-iOS-forRelease/Info.plist b/NADA-iOS-forRelease/Info.plist index 6d12c879..8301cb5a 100644 --- a/NADA-iOS-forRelease/Info.plist +++ b/NADA-iOS-forRelease/Info.plist @@ -10,8 +10,6 @@ Spoqa Han Sans Neo Bold.otf Spoqa Han Sans Neo Regular.otf - LSApplicationCategoryType - NSAppTransportSecurity NSAllowsArbitraryLoads @@ -35,23 +33,8 @@ 1.0 CFBundleVersion 1 - LSApplicationCategoryType - LSRequiresIPhoneOS - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - UIAppFonts - - NotoSansCJKkr-Bold.otf - NotoSansCJKkr-Medium.otf - NotoSansCJKkr-Regular.otf - Spoqa Han Sans Neo Bold.otf - Spoqa Han Sans Neo Regular.otf - UIApplicationSceneManifest UIApplicationSupportsMultipleScenes @@ -90,7 +73,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - UIUserInterfaceStyle - diff --git a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift index e0fe84a1..059dfc39 100644 --- a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift +++ b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift @@ -14,4 +14,6 @@ extension Notification.Name { // MARK: - Card Creation static let frontCardBirth = Notification.Name("frontCardBirth") static let frontCardMBTI = Notification.Name("frontCardMBTI") + static let presentingImagePicker = Notification.Name("presentingImagePicker") + static let sendNewImage = Notification.Name("sendNewImage") } diff --git a/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift b/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift index 5522f8c8..594dc0c6 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift @@ -73,4 +73,23 @@ extension FrontCardCell { self.instagramIDLabel.text = instagramID self.linkURLLabel.text = linkURL } + + // FIXME: - UIImage 로 넘어올때. 나중에 어떻게 사용할지 정해야함. + func initCell(_ backgroundImage: UIImage?, + _ cardTitle: String, + _ cardDescription: String, + _ userName: String, + _ birth: String, + _ mbti: String, + _ instagramID: String, + _ linkURL: String) { + self.backgroundImageView.image = backgroundImage ?? UIImage() + self.titleLabel.text = cardTitle + self.descriptionLabel.text = cardDescription + self.userNameLabel.text = userName + self.birthLabel.text = birth + self.mbtiLabel.text = mbti + self.instagramIDLabel.text = instagramID + self.linkURLLabel.text = linkURL + } } diff --git a/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.xib b/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.xib index 5ac3e9e4..3a4d2c8a 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.xib +++ b/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.xib @@ -4,7 +4,6 @@ - @@ -25,6 +24,15 @@ + + + + + + + + + + diff --git a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift index 2a82a019..df77d9b7 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift @@ -18,6 +18,9 @@ class FrontCardCreationCollectionViewCell: UICollectionViewCell { private let backgroundList = ["img", "img", "img", "img", "img"] private var requiredTextFieldList = [UITextField]() private var optionalTextFieldList = [UITextField]() + private var cardBackgroundImage: UIImage? + private var defaultImageIndex: Int? + public var presentingBirthBottomVCClosure: (() -> Void)? public var presentingMBTIBottomVCClosure: (() -> Void)? @@ -156,6 +159,32 @@ extension FrontCardCreationCollectionViewCell { private func setNotification() { NotificationCenter.default.addObserver(self, selector: #selector(setBirthTextField(notification:)), name: .frontCardBirth, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(setMBTITextField(notification:)), name: .frontCardMBTI, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(setCardBackgroundImage(notifiation:)), name: .sendNewImage, object: nil) + } + + /// front card 가 편집되었는지. 필수 항목이 다 입력되었는지 체크. + private func checkFrontCradStatus() { + frontCardCreationDelegate?.frontCardCreation(endEditing: true) + if cardTitleTextField.hasText && + userNameTextField.hasText && + birthTextField.hasText && + mbtiTextField.hasText && + defaultImageIndex != nil { + frontCardCreationDelegate?.frontCardCreation(requiredInfo: true) + frontCardCreationDelegate?.frontCardCreation(withRequired: [ + "defaultImageIndex": String(defaultImageIndex ?? -1), + "title": cardTitleTextField.text ?? "", + "name": userNameTextField.text ?? "", + "birthDate": birthTextField.text ?? "", + "mbti": mbtiTextField.text ?? "" + ], withOptional: [ + "instagram": instagramIDTextField.text ?? "", + "linkURL": linkURLTextField.text ?? "", + "description": descriptionTextField.text ?? "" + ]) + } else { + frontCardCreationDelegate?.frontCardCreation(requiredInfo: false) + } } static func nib() -> UINib { return UINib(nibName: Const.Xib.frontCardCreationCollectionViewCell, bundle: Bundle(for: FrontCardCreationCollectionViewCell.self)) @@ -169,17 +198,42 @@ extension FrontCardCreationCollectionViewCell { birthTextField.borderWidth = 0 } - @objc private func setMBTITextField(notification: NSNotification) { mbtiTextField.text = notification.object as? String mbtiTextField.borderWidth = 0 } + @objc + private func setCardBackgroundImage(notifiation: NSNotification) { + cardBackgroundImage = notifiation.object as? UIImage + backgroundSettingCollectionView.reloadData() + } } // MARK: - UICollectionViewDelegate -extension FrontCardCreationCollectionViewCell: UICollectionViewDelegate { } +extension FrontCardCreationCollectionViewCell: UICollectionViewDelegate { + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + + switch indexPath.item { + case 0: + NotificationCenter.default.post(name: .presentingImagePicker, object: nil) + defaultImageIndex = 0 + case 1: + defaultImageIndex = 1 + case 2: + defaultImageIndex = 2 + case 3: + defaultImageIndex = 3 + case 4: + defaultImageIndex = 4 + default: + return + } + checkFrontCradStatus() + } +} // MARK: - UICollectionViewDataSource extension FrontCardCreationCollectionViewCell: UICollectionViewDataSource { @@ -191,8 +245,14 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDataSource { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Const.Xib.backgroundCollectionViewCell, for: indexPath) as? BackgroundCollectionViewCell else { return UICollectionViewCell() } - cell.initCell(image: backgroundList[indexPath.item]) - + switch indexPath.item { + case 0: + cell.initCell(image: cardBackgroundImage ?? UIImage(), isFirst: true) + default: + // FIXME: - 기본 명함 배경 넘겨주면 수정. +// guard let image = UIImage(systemName: backgroundList[indexPath.item]) else { return UICollectionViewCell() } + cell.initCell(image: UIImage(), isFirst: false) + } return cell } } @@ -216,38 +276,20 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDelegateFlowLayou // MARK: - UITextFieldDelegate extension FrontCardCreationCollectionViewCell: UITextFieldDelegate { func textFieldDidBeginEditing(_ textField: UITextField) { - if textField == birthTextField { + switch textField { + case birthTextField: textField.endEditing(true) presentingBirthBottomVCClosure?() - } else if textField == mbtiTextField { + case mbtiTextField: textField.endEditing(true) presentingMBTIBottomVCClosure?() - } else { + default: textField.borderWidth = 1 textField.borderColor = .tertiary } } func textFieldDidEndEditing(_ textField: UITextField) { - frontCardCreationDelegate?.frontCardCreation(endEditing: true) - if cardTitleTextField.hasText && - userNameTextField.hasText && - birthTextField.hasText && - mbtiTextField.hasText { - frontCardCreationDelegate?.frontCardCreation(requiredInfo: true) - frontCardCreationDelegate?.frontCardCreation(withRequired: [ - "defaultImage": String(0), - "title": cardTitleTextField.text ?? "", - "name": userNameTextField.text ?? "", - "birthDate": birthTextField.text ?? "", - "mbti": mbtiTextField.text ?? "" - ], withOptional: [ - "instagram": instagramIDTextField.text ?? "", - "linkURL": linkURLTextField.text ?? "", - "description": descriptionTextField.text ?? "" - ]) - } else { - frontCardCreationDelegate?.frontCardCreation(requiredInfo: false) - } + checkFrontCradStatus() textField.resignFirstResponder() textField.borderWidth = 0 } diff --git a/NADA-iOS-forRelease/Sources/Cells/GroupCell/CardInGroupCollectionViewCell.xib b/NADA-iOS-forRelease/Sources/Cells/GroupCell/CardInGroupCollectionViewCell.xib index e2f72212..8f68f63a 100644 --- a/NADA-iOS-forRelease/Sources/Cells/GroupCell/CardInGroupCollectionViewCell.xib +++ b/NADA-iOS-forRelease/Sources/Cells/GroupCell/CardInGroupCollectionViewCell.xib @@ -32,6 +32,10 @@ + + + +