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

[FIX] #158 - 명함생성뷰 이미지피커 dismiss 동작 추가 #159

Merged
merged 2 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions NADA-iOS-forRelease/Resouces/Constants/Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ extension Notification.Name {
static let sendNewImage = Notification.Name("sendNewImage")
static let touchRequiredView = Notification.Name("touchRequiredView")
static let dismissRequiredBottomSheet = Notification.Name("dismissRequiredBottomSheet")
static let cancelImagePicker = Notification.Name("cancelImagePicker")
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ extension FrontCardCreationCollectionViewCell {
NotificationCenter.default.addObserver(self, selector: #selector(setCardBackgroundImage(notifiation:)), name: .sendNewImage, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(textFieldDidChange(_:)), name: UITextField.textDidChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(dismissBorderLine), name: .dismissRequiredBottomSheet, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(cancelImagePicker), name: .cancelImagePicker, object: nil)
}

/// front card 가 편집되었는지. 필수 항목이 다 입력되었는지 체크.
Expand Down Expand Up @@ -230,15 +231,17 @@ extension FrontCardCreationCollectionViewCell {
private func setMBTIText(notification: NSNotification) {
mbtiLabel.text = notification.object as? String
mbtiLabel.textColor = .primary

mbtiView.borderWidth = 0

checkFrontCradStatus()
}
@objc
private func setCardBackgroundImage(notifiation: NSNotification) {
cardBackgroundImage = notifiation.object as? UIImage
defaultImageIndex = 0
backgroundSettingCollectionView.reloadData()

checkFrontCradStatus()
}
@objc
private func textFieldDidChange(_ notification: Notification) {
Expand Down Expand Up @@ -301,6 +304,12 @@ extension FrontCardCreationCollectionViewCell {
birthView.layer.borderWidth = 0
mbtiView.layer.borderWidth = 0
}
@objc
private func cancelImagePicker() {
if cardBackgroundImage == nil {
backgroundSettingCollectionView.deselectItem(at: IndexPath.init(item: 0, section: 0), animated: true)
}
}
}

// MARK: - UICollectionViewDelegate
Expand All @@ -309,7 +318,11 @@ extension FrontCardCreationCollectionViewCell: UICollectionViewDelegate {
switch indexPath.item {
case 0:
NotificationCenter.default.post(name: .presentingImagePicker, object: nil)
defaultImageIndex = 0
if cardBackgroundImage == nil {
defaultImageIndex = nil
} else {
defaultImageIndex = 0
}
case 1:
defaultImageIndex = 1
case 2:
Expand Down
4 changes: 2 additions & 2 deletions NADA-iOS-forRelease/Sources/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
// window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.tabBar, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.tabBarViewController)
window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.splash, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.splashViewController)
window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.tabBar, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.tabBarViewController)
// window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.splash, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.splashViewController)
Comment on lines +25 to +26
Copy link
Member

Choose a reason for hiding this comment

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

감사합니다아아

// window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.login, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.loginViewController)
window?.makeKeyAndVisible()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class CardCreationPreviewViewController: UIViewController {
@IBAction func touchCompleteButton(_ sender: Any) {
guard let frontCardDataModel = frontCardDataModel, let backCardDataModel = backCardDataModel else { return }
cardCreationRequest = CardCreationRequest(userID: "", frontCard: frontCardDataModel, backCard: backCardDataModel)
guard let cardCreationRequest = cardCreationRequest else { return }
guard let cardCreationRequest = cardCreationRequest,
let cardBackgroundImage = cardBackgroundImage else { return }

cardCreationWithAPI(request: cardCreationRequest, image: cardBackgroundImage ?? UIImage())
cardCreationWithAPI(request: cardCreationRequest, image: cardBackgroundImage)
}
@IBAction func touchBackButton(_ sender: Any) {
navigationController?.popViewController(animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ extension CardCreationViewController {
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
imagePicker.delegate = self
imagePicker.modalPresentationStyle = .overFullScreen

present(imagePicker, animated: true, completion: nil)
}
Expand Down Expand Up @@ -423,4 +424,9 @@ extension CardCreationViewController: UIImagePickerControllerDelegate, UINavigat

picker.dismiss(animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
NotificationCenter.default.post(name: .cancelImagePicker, object: nil)

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