Skip to content

Commit

Permalink
[FEAT] #128 - mbti, 생년월일 바텀시트 dismiss 수정 및 명함 배경 추가
Browse files Browse the repository at this point in the history
- 피커뷰 코드 정리(조건문 수정)
- 명함 배경 선택 테두리 색 변경(메인나다색으로)
-  카드 불투명도 0.4->0.2변경
- 명함 기본배경 설정
  • Loading branch information
hyun99999 committed Dec 10, 2021
1 parent 9a1e117 commit 6290951
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"images" : [
{
"scale" : "1x",
"idiom" : "universal",
"filename" : "imgCardBg01.png",
"idiom" : "universal"
"scale" : "1x"
},
{
"idiom" : "universal",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"images" : [
{
"scale" : "1x",
"filename" : "imgCardBg06.png",
"idiom" : "universal"
"idiom" : "universal",
"scale" : "1x"
},
{
"scale" : "2x",
"idiom" : "universal",
"scale" : "2x",
"filename" : "imgCardBg06@2x.png"
},
{
"scale" : "3x",
"filename" : "imgCardBg06@3x.png",
"idiom" : "universal",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"images" : [
{
"filename" : "imgCardBg07.png",
"scale" : "1x",
"idiom" : "universal",
"scale" : "1x"
"filename" : "imgCardBg07.png"
},
{
"filename" : "imgCardBg07@2x.png",
"idiom" : "universal",
"scale" : "2x"
"scale" : "2x",
"idiom" : "universal"
},
{
"filename" : "imgCardBg07@3x.png",
"scale" : "3x",
"idiom" : "universal"
"idiom" : "universal",
"filename" : "imgCardBg07@3x.png"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<view alpha="0.40000000000000002" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Q9H-oG-tzn">
<view alpha="0.20000000000000001" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Q9H-oG-tzn">
<rect key="frame" x="0.0" y="0.0" width="327" height="540"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<userDefinedRuntimeAttributes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<view alpha="0.40000000000000002" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="S8I-Fv-fkf">
<view alpha="0.20000000000000001" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="S8I-Fv-fkf">
<rect key="frame" x="0.0" y="0.0" width="327" height="540"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<userDefinedRuntimeAttributes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ class BackgroundCollectionViewCell: UICollectionViewCell {

extension BackgroundCollectionViewCell {
private func setUI() {
bgView.backgroundColor = .tertiary
bgView.backgroundColor = .mainColorNadaMain
bgView.isHidden = true
bgView.layer.cornerRadius = bgViewCornerRadius

opacityView.layer.cornerRadius = imageviewCornerRadius
imageView.layer.cornerRadius = imageviewCornerRadius
imageView.contentMode = .scaleAspectFill
}
func initCell(image: UIImage, isFirst: Bool) {
imageView.image = image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FrontCardCreationCollectionViewCell: UICollectionViewCell {

// MARK: - Properties

private let backgroundList = ["img", "img", "img", "img", "img"]
private let backgroundList = ["", "imageDefaultBg01", "imageDefaultBg02", "imageDefaultBg03", "imageDefaultBg04", "imageDefaultBg05", "imageDefaultBg06", "imageDefaultBg07"]
private var requiredTextFieldList = [UITextField]()
private var optionalTextFieldList = [UITextField]()
private var cardBackgroundImage: UIImage?
Expand Down Expand Up @@ -176,17 +176,19 @@ extension FrontCardCreationCollectionViewCell {
} else {
frontCardCreationDelegate?.frontCardCreation(requiredInfo: false)
}
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 ?? ""
])
if let defaultImageIndex = defaultImageIndex {
frontCardCreationDelegate?.frontCardCreation(withRequired: [
"defaultImageIndex": String(defaultImageIndex),
"title": cardTitleTextField.text ?? "",
"name": userNameTextField.text ?? "",
"birthDate": birthTextField.text ?? "",
"mbti": mbtiTextField.text ?? ""
], withOptional: [
"instagram": instagramIDTextField.text ?? "",
"linkURL": linkURLTextField.text ?? "",
"description": descriptionTextField.text ?? ""
])
}
}
static func nib() -> UINib {
return UINib(nibName: Const.Xib.frontCardCreationCollectionViewCell, bundle: Bundle(for: FrontCardCreationCollectionViewCell.self))
Expand Down Expand Up @@ -261,6 +263,12 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDelegate {
defaultImageIndex = 3
case 4:
defaultImageIndex = 4
case 5:
defaultImageIndex = 5
case 6:
defaultImageIndex = 6
case 7:
defaultImageIndex = 7
default:
return
}
Expand All @@ -282,9 +290,8 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDataSource {
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)
guard let image = UIImage(named: backgroundList[indexPath.item]) else { return UICollectionViewCell() }
cell.initCell(image: image, isFirst: false)
}
return cell
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="card" translatesAutoresizingMaskIntoConstraints="NO" id="nFQ-dL-nGf">
<rect key="frame" x="0.0" y="0.0" width="156" height="258"/>
</imageView>
<view alpha="0.40000000000000002" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9V6-ba-Kga">
<view alpha="0.20000000000000001" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9V6-ba-Kga">
<rect key="frame" x="0.0" y="0.0" width="156" height="258"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CardCreationPreviewViewController: UIViewController {
public var frontCardDataModel: FrontCardDataModel?
public var backCardDataModel: BackCardDataModel?
public var cardBackgroundImage: UIImage?
public var defaultImageIndex: Int?

private var isFront = true
private var cardCreationRequest: CardCreationRequest?
Expand All @@ -28,6 +29,7 @@ class CardCreationPreviewViewController: UIViewController {
super.viewDidLoad()

setUI()
setBackgroundImage()
setFrontCard()
setGestureRecognizer()
}
Expand Down Expand Up @@ -94,6 +96,25 @@ extension CardCreationPreviewViewController {
swipeRightGestureRecognizer.direction = .right
self.cardView.addGestureRecognizer(swipeRightGestureRecognizer)
}
private func setBackgroundImage() {
if frontCardDataModel?.defaultImage == 0 {
return
} else if frontCardDataModel?.defaultImage == 1 {
cardBackgroundImage = UIImage(named: "imgCardBg01")
} else if frontCardDataModel?.defaultImage == 2 {
cardBackgroundImage = UIImage(named: "imgCardBg02")
} else if frontCardDataModel?.defaultImage == 3 {
cardBackgroundImage = UIImage(named: "imgCardBg03")
} else if frontCardDataModel?.defaultImage == 4 {
cardBackgroundImage = UIImage(named: "imgCardBg04")
} else if frontCardDataModel?.defaultImage == 5 {
cardBackgroundImage = UIImage(named: "imgCardBg05")
} else if frontCardDataModel?.defaultImage == 6 {
cardBackgroundImage = UIImage(named: "imgCardBg06")
} else {
cardBackgroundImage = UIImage(named: "imgCardBg07")
}
}

// MARK: - @objc Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class CardCreationViewController: UIViewController {
private var mbtiText: String?
private var birthText: String?
private var newImage: UIImage?
private var defaultImageIndex: Int?

// MARK: - @IBOutlet Properties

Expand Down Expand Up @@ -90,7 +89,7 @@ class CardCreationViewController: UIViewController {
}
@IBAction func pushToCardCompletionView(_ sender: Any) {
guard let nextVC = UIStoryboard.init(name: Const.Storyboard.Name.cardCreationPreview, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.cardCreationPreviewViewController) as? CardCreationPreviewViewController else { return }

nextVC.frontCardDataModel = frontCard
nextVC.backCardDataModel = backCard
nextVC.cardBackgroundImage = newImage
Expand Down Expand Up @@ -149,13 +148,13 @@ extension CardCreationViewController {
// TODO: - QA/iOS 13 테스트. selected 설정.
completeButton.layer.cornerRadius = 15

completeButton.setTitle("완료", for: .normal)
completeButton.setTitle("완료", for: .normal)
completeButton.setTitleColor(.white, for: .normal)
completeButton.setBackgroundImage(UIImage(named: "enableButtonBackground"), for: .normal)

completeButton.setTitle("완료", for: .disabled)
completeButton.setTitleColor(.white, for: .disabled)
completeButton.setBackgroundImage(UIImage(named: "disableButtonBackground"), for: .disabled)
completeButton.setBackgroundImage(UIImage(named: "enableButtonBackground"), for: .normal)
completeButton.setTitle("완료", for: .disabled)
completeButton.setTitleColor(.white, for: .disabled)
completeButton.setBackgroundImage(UIImage(named: "disableButtonBackground"), for: .disabled)
}

let cardCreationCollectionViewlayout = cardCreationCollectionView.collectionViewLayout as? UICollectionViewFlowLayout
Expand Down Expand Up @@ -379,7 +378,7 @@ extension CardCreationViewController: FrontCardCreationDelegate {
isEditingMode = valid
}
func frontCardCreation(withRequired requiredInfo: [String: String], withOptional optionalInfo: [String: String]) {
frontCard = FrontCardDataModel(defaultImage: Int(requiredInfo["defaultImage"] ?? "-1") ?? -1,
frontCard = FrontCardDataModel(defaultImage: Int(requiredInfo["defaultImageIndex"] ?? "-1") ?? -1,
title: requiredInfo["title"] ?? "",
name: requiredInfo["name"] ?? "",
birthDate: requiredInfo["birthDate"] ?? "",
Expand Down Expand Up @@ -419,13 +418,9 @@ extension CardCreationViewController: UIImagePickerControllerDelegate, UINavigat
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
newImage = editedImage
} else if let originalImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
newImage = originalImage
}
if let cropImage = info[UIImagePickerController.InfoKey.cropRect] as? UIImage {
newImage = cropImage
}
NotificationCenter.default.post(name: .sendNewImage, object: newImage)

picker.dismiss(animated: true, completion: nil)
}
}

0 comments on commit 6290951

Please sign in to comment.