Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 명함 선택 시 사진 영역 수정 (#333) #445

Merged
merged 7 commits into from
Apr 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import UIKit

import YPImagePicker

class CardCreationViewController: UIViewController {

// MARK: - Properties
Expand Down Expand Up @@ -40,9 +42,11 @@ class CardCreationViewController: UIViewController {
private var backCard: BackCardDataModel?
private var mbtiText: String?
private var birthText: String?
private var newImage: UIImage?
private var backgroundImage: UIImage?
private var tasteInfo: [TasteInfo]?

// private lazy var selectedImage: [YPMediaItem] = []

private let cardType: CardType = .basic

// MARK: - @IBOutlet Properties
Expand Down Expand Up @@ -83,7 +87,7 @@ class CardCreationViewController: UIViewController {

nextVC.frontCardDataModel = frontCard
nextVC.backCardDataModel = backCard
nextVC.cardBackgroundImage = newImage
nextVC.cardBackgroundImage = backgroundImage
nextVC.tasteInfo = tasteInfo
navigationController?.pushViewController(nextVC, animated: true)
}
Expand Down Expand Up @@ -203,16 +207,48 @@ extension CardCreationViewController {
}
@objc
private func presentToImagePicker() {
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
imagePicker.delegate = self
imagePicker.modalPresentationStyle = .overFullScreen
var config = YPImagePickerConfiguration()
config.screens = [.library]
config.startOnScreen = .library
config.library.isSquareByDefault = false
config.showsPhotoFilters = false
config.shouldSaveNewPicturesToAlbum = false
config.showsCrop = .rectangle(ratio: 0.6)
config.colors.tintColor = .mainColorNadaMain

let imagePicker = YPImagePicker(configuration: config)
imagePicker.imagePickerDelegate = self

imagePicker.didFinishPicking { [weak self] items, cancelled in
guard let self = self else { return }

if cancelled {
NotificationCenter.default.post(name: .cancelImagePicker, object: nil)
}

if let photo = items.singlePhoto {
backgroundImage = photo.image
NotificationCenter.default.post(name: .sendNewImage, object: backgroundImage)
}
imagePicker.dismiss(animated: true)
}

imagePicker.modalPresentationStyle = .overFullScreen
present(imagePicker, animated: true, completion: nil)
}
}

// MARK: - YPImagePickerDelegate
extension CardCreationViewController: YPImagePickerDelegate {
func imagePickerHasNoItemsInLibrary(_ picker: YPImagePicker) {
self.makeOKAlert(title: "", message: "가져올 수 있는 사진이 없습니다.")
}

func shouldAddToSelection(indexPath: IndexPath, numSelections: Int) -> Bool {
return true
}
}

// MARK: - UICollectionViewDelegate
extension CardCreationViewController: UICollectionViewDelegate {
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
Expand Down Expand Up @@ -337,22 +373,6 @@ extension CardCreationViewController: BackCardCreationDelegate {
}
}

extension CardCreationViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
newImage = editedImage
}
NotificationCenter.default.post(name: .sendNewImage, object: newImage)

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

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

// MARK: - API methods

extension CardCreationViewController {
Expand Down
3 changes: 2 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ target 'NADA-iOS-forRelease' do
pod 'Moya/RxSwift'
pod 'FlexLayout'
pod 'PinLayout'
pod 'RxGesture'
pod 'RxGesture'
pod 'YPImagePicker'
end
40 changes: 26 additions & 14 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ PODS:
- GoogleUtilities/Environment
- "GoogleUtilities/NSData+zlib (7.11.1)"
- IQKeyboardManagerSwift (6.5.11)
- KakaoSDKAuth (2.14.0):
- KakaoSDKCommon (= 2.14.0)
- KakaoSDKCommon (2.14.0):
- KakaoSDKCommon/Common (= 2.14.0)
- KakaoSDKCommon/Network (= 2.14.0)
- KakaoSDKCommon/Common (2.14.0)
- KakaoSDKCommon/Network (2.14.0):
- KakaoSDKAuth (2.15.0):
- KakaoSDKCommon (= 2.15.0)
- KakaoSDKCommon (2.15.0):
- KakaoSDKCommon/Common (= 2.15.0)
- KakaoSDKCommon/Network (= 2.15.0)
- KakaoSDKCommon/Common (2.15.0)
- KakaoSDKCommon/Network (2.15.0):
- Alamofire (~> 5.1)
- KakaoSDKCommon/Common (= 2.14.0)
- KakaoSDKUser (2.14.0):
- KakaoSDKAuth (= 2.14.0)
- KakaoSDKCommon/Common (= 2.15.0)
- KakaoSDKUser (2.15.0):
- KakaoSDKAuth (= 2.15.0)
- Kingfisher (7.6.2)
- lottie-ios (4.1.3)
- Moya (15.0.0):
Expand All @@ -45,6 +45,7 @@ PODS:
- NVActivityIndicatorView/Base (5.1.1)
- PinLayout (1.10.4)
- PromisesObjC (2.2.0)
- PryntTrimmerView (4.0.2)
- RxCocoa (6.5.0):
- RxRelay (= 6.5.0)
- RxSwift (= 6.5.0)
Expand All @@ -56,9 +57,13 @@ PODS:
- RxSwift (6.5.0)
- SkeletonView (1.30.4)
- SnapKit (5.6.0)
- SteviaLayout (4.7.3)
- SwiftLint (0.51.0)
- Then (3.0.0)
- VerticalCardSwiper (2.3.1)
- YPImagePicker (5.2.1):
- PryntTrimmerView (= 4.0.2)
- SteviaLayout (= 4.7.3)

DEPENDENCIES:
- Firebase/DynamicLinks
Expand All @@ -81,6 +86,7 @@ DEPENDENCIES:
- SwiftLint
- Then
- VerticalCardSwiper
- YPImagePicker

SPEC REPOS:
trunk:
Expand All @@ -101,15 +107,18 @@ SPEC REPOS:
- NVActivityIndicatorView
- PinLayout
- PromisesObjC
- PryntTrimmerView
- RxCocoa
- RxGesture
- RxRelay
- RxSwift
- SkeletonView
- SnapKit
- SteviaLayout
- SwiftLint
- Then
- VerticalCardSwiper
- YPImagePicker

SPEC CHECKSUMS:
Alamofire: 4e95d97098eacb88856099c4fc79b526a299e48c
Expand All @@ -120,25 +129,28 @@ SPEC CHECKSUMS:
FlexLayout: 8010187077ecf09710cdf0e9c8ffe2c9b92ec5db
GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749
IQKeyboardManagerSwift: c7955c0bdbf7b2eb29bb7daaa44e3d90f55a9a85
KakaoSDKAuth: 8fca87815de22062a23297983f327613b087b8bb
KakaoSDKCommon: 0ce638f7a2e49704943c0b74a087a9f8067bba1c
KakaoSDKUser: 2ca18314ce72e6690f76cb1f6f9fbc771d31a803
KakaoSDKAuth: 0fe5cf1756e8a9f66f8fc77826061aafa93034f3
KakaoSDKCommon: 89d863b7f34398e6fb93a0acb28a204908551a39
KakaoSDKUser: a997ca5c4c18ece2ab30646ff74841bc29d4399d
Kingfisher: 6c5449c6450c5239166510ba04afe374a98afc4f
lottie-ios: d0954d3150061f662ed0adf96ef98d7421864c47
Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee
NVActivityIndicatorView: 1f6c5687f1171810aa27a3296814dc2d7dec3667
PinLayout: f8a677ce0cd1cfe96b58435d029b4ceb4ce9c04c
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
PryntTrimmerView: 6a43cc90df5d99addeabd33d4ba09b1365322130
RxCocoa: 94f817b71c07517321eb4f9ad299112ca8af743b
RxGesture: f3efb47ed2d26a8082f7b660d4a59970e275a7f8
RxRelay: 1de1523e604c72b6c68feadedd1af3b1b4d0ecbd
RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
SkeletonView: 5a050f6411e697abd4cda0a8d767013399dccd69
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
SteviaLayout: c2ecdcff57d44e38fd2f65e54ad52aeae28ca0c4
SwiftLint: 1b7561918a19e23bfed960e40759086e70f4dba5
Then: 844265ae87834bbe1147d91d5d41a404da2ec27d
VerticalCardSwiper: 68df635b354500f86934ea044ade37a264c044c6
YPImagePicker: f36043210c10b0783034eb1947d6e06e31c461e4

PODFILE CHECKSUM: 4f8083405fc2c8c3395baf17cf92037c6ff0eab7
PODFILE CHECKSUM: 6aac9570b93049853d9fa383fd5b608dbdbcd63d

COCOAPODS: 1.12.0