diff --git a/NADA-iOS-forRelease.xcodeproj/project.pbxproj b/NADA-iOS-forRelease.xcodeproj/project.pbxproj index 4f7ee76d..cdd7a0cb 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..059dfc39 100644 --- a/NADA-iOS-forRelease/Resouces/Constants/Notification.swift +++ b/NADA-iOS-forRelease/Resouces/Constants/Notification.swift @@ -8,9 +8,12 @@ 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") + static let presentingImagePicker = Notification.Name("presentingImagePicker") + static let sendNewImage = Notification.Name("sendNewImage") } diff --git a/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift b/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift index b197231c..10548a0d 100644 --- a/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift +++ b/NADA-iOS-forRelease/Resouces/Extensions/UIViewController+Extension.swift @@ -9,14 +9,12 @@ import Foundation import UIKit extension UIViewController { - /// 취소+삭제 UIAlertController func makeCancelDeleteAlert(title: String, message: String, cancelAction: ((UIAlertAction) -> Void)? = nil, deleteAction: ((UIAlertAction) -> Void)?, completion: (() -> Void)? = nil) { - let alertViewController = UIAlertController(title: title, message: message, preferredStyle: .alert) diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/CardCreation/CardCreationPreview.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/CardCreation/CardCreationPreview.storyboard index 902b7ceb..ddf4a4fd 100644 --- a/NADA-iOS-forRelease/Resouces/Storyboards/CardCreation/CardCreationPreview.storyboard +++ b/NADA-iOS-forRelease/Resouces/Storyboards/CardCreation/CardCreationPreview.storyboard @@ -25,6 +25,7 @@ + diff --git a/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard b/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard index 1310fb1d..2219b576 100644 --- a/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard +++ b/NADA-iOS-forRelease/Resouces/Storyboards/More/More.storyboard @@ -41,10 +41,10 @@ - + - + @@ -67,7 +67,7 @@ - + diff --git a/NADA-iOS-forRelease/Sources/Cells/CardCell/BackCardCell.swift b/NADA-iOS-forRelease/Sources/Cells/CardCell/BackCardCell.swift index 0c665bf7..3c236fcc 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CardCell/BackCardCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CardCell/BackCardCell.swift @@ -88,4 +88,40 @@ extension BackCardCell { self.secondTmiLabel.text = secondTmi self.thirdTmiLabel.text = thirdTmi } + + // FIXME: - UIImage 로 넘어올때. 나중에 어떻게 사용할지 정해야함. + func initCell(_ backgroundImage: UIImage?, + _ isMintImage: Bool, + _ isNoMintImage: Bool, + _ isSojuImage: Bool, + _ isBeerImage: Bool, + _ isPourImage: Bool, + _ isPutSauceImage: Bool, + _ isYangnyumImage: Bool, + _ isFriedImage: Bool, + _ firstTmi: String, + _ secondTmi: String, + _ thirdTmi: String) { + + self.backgroundImageView.image = backgroundImage ?? UIImage() + self.mintImageView.image = isMintImage == true ? + UIImage(named: "iconTasteOnMincho") : UIImage(named: "iconTasteOffMincho") + self.noMintImageView.image = isNoMintImage == true ? + UIImage(named: "iconTasteOnBanmincho") : UIImage(named: "iconTasteOffBanmincho") + self.sojuImageView.image = isSojuImage == true ? + UIImage(named: "iconTasteOnSoju") : UIImage(named: "iconTasteOffSoju") + self.beerImageView.image = isBeerImage == true ? + UIImage(named: "iconTasteOnBeer") : UIImage(named: "iconTasteOffBeer") + self.pourEatImageView.image = isPourImage == true ? + UIImage(named: "iconTasteOnBumeok") : UIImage(named: "iconTasteOffBumeok") + self.putSauceEatImageView.image = isPutSauceImage == true ? + UIImage(named: "iconTasteOnZzik") : UIImage(named: "iconTasteOffZzik") + self.sauceChickenImageView.image = isYangnyumImage == true ? + UIImage(named: "iconTasteOnSeasoned") : UIImage(named: "iconTasteOffSeasoned") + self.friedChickenImageView.image = isFriedImage == true ? + UIImage(named: "iconTasteOnFried") : UIImage(named: "iconTasteOffFried") + self.firstTmiLabel.text = firstTmi + self.secondTmiLabel.text = secondTmi + self.thirdTmiLabel.text = thirdTmi + } } diff --git a/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift b/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift index 5522f8c8..de513571 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CardCell/FrontCardCell.swift @@ -17,9 +17,7 @@ class FrontCardCell: CardCell { @IBOutlet weak var userNameLabel: UILabel! @IBOutlet weak var birthLabel: UILabel! @IBOutlet weak var mbtiLabel: UILabel! - @IBOutlet weak var instagramImageView: UIImageView! @IBOutlet weak var instagramIDLabel: UILabel! - @IBOutlet weak var linkURLImageView: UIImageView! @IBOutlet weak var linkURLLabel: UILabel! // MARK: - Life Cycle @@ -52,6 +50,7 @@ extension FrontCardCell { instagramIDLabel.textColor = .white linkURLLabel.font = .textRegular04 linkURLLabel.textColor = .white + linkURLLabel.numberOfLines = 2 } func initCell(_ backgroundImage: String, @@ -65,12 +64,31 @@ extension FrontCardCell { if let bgImage = UIImage(named: backgroundImage) { self.backgroundImageView.image = bgImage } - 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 + titleLabel.text = cardTitle + descriptionLabel.text = cardDescription + userNameLabel.text = userName + birthLabel.text = birth + mbtiLabel.text = mbti + instagramIDLabel.text = instagramID + linkURLLabel.text = linkURL + } + + // FIXME: - UIImage 로 넘어올때. 나중에 어떻게 사용할지 정해야함. + func initCell(_ backgroundImage: UIImage?, + _ cardTitle: String, + _ cardDescription: String, + _ userName: String, + _ birth: String, + _ mbti: String, + _ instagramID: String, + _ linkURL: String) { + backgroundImageView.image = backgroundImage ?? UIImage() + titleLabel.text = cardTitle + descriptionLabel.text = cardDescription + userNameLabel.text = userName + birthLabel.text = birth + mbtiLabel.text = mbti + instagramIDLabel.text = instagramID + 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..0ee47127 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 f3d7353d..40f007a1 100644 --- a/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift +++ b/NADA-iOS-forRelease/Sources/Cells/CreationCard/FrontCardCreationCollectionViewCell.swift @@ -9,12 +9,20 @@ 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? + private var cardBackgroundImage: UIImage? + private var defaultImageIndex: Int? + + public var presentingBirthBottomVCClosure: (() -> Void)? + public var presentingMBTIBottomVCClosure: (() -> Void)? // MARK: - @IBOutlet Properties @@ -44,6 +52,7 @@ class FrontCardCreationCollectionViewCell: UICollectionViewCell { setUI() registerCell() textFieldDelegate() + setNotification() } } @@ -59,6 +68,7 @@ extension FrontCardCreationCollectionViewCell { backgroundSettingCollectionView.backgroundColor = .background let collectionViewLayout = backgroundSettingCollectionView.collectionViewLayout as? UICollectionViewFlowLayout + collectionViewLayout?.estimatedItemSize = .zero collectionViewLayout?.scrollDirection = .horizontal let backgroundAttributeString = NSMutableAttributedString(string: "*명함의 배경을 선택해 주세요.") @@ -96,7 +106,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: [ @@ -146,13 +156,84 @@ 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) + 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)) } + + // 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 + } + @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 { @@ -164,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 } } @@ -176,6 +263,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 { @@ -186,31 +276,21 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDelegateFlowLayou // MARK: - UITextFieldDelegate extension FrontCardCreationCollectionViewCell: UITextFieldDelegate { func textFieldDidBeginEditing(_ textField: UITextField) { - textField.borderWidth = 1 - textField.borderColor = .tertiary - textField.becomeFirstResponder() + switch textField { + case birthTextField: + textField.endEditing(true) + presentingBirthBottomVCClosure?() + case mbtiTextField: + textField.endEditing(true) + presentingMBTIBottomVCClosure?() + 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 } func textFieldShouldReturn(_ textField: UITextField) -> Bool { 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 @@ - + 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 @@ + + + +