From 068f8a4e9ce70110cff19099d113bcfb8ab9c549 Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 7 Nov 2024 00:36:40 +0900 Subject: [PATCH 1/7] =?UTF-8?q?chore:=20EditPhoto=20=EB=94=94=EB=A0=89?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MHApplication.xcodeproj/project.pbxproj | 4 +++ .../MHPresentation.xcodeproj/project.pbxproj | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/MemorialHouse/MHApplication/MHApplication.xcodeproj/project.pbxproj b/MemorialHouse/MHApplication/MHApplication.xcodeproj/project.pbxproj index a4a959f6..f6560aaf 100644 --- a/MemorialHouse/MHApplication/MHApplication.xcodeproj/project.pbxproj +++ b/MemorialHouse/MHApplication/MHApplication.xcodeproj/project.pbxproj @@ -277,6 +277,8 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = MHApplication/Resource/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "기록소"; + INFOPLIST_KEY_NSCameraUsageDescription = "기록소는 카메라 권한을 필요로 합니다. 허용 안 함 시 일부 기능이 동작하지 않을 수 있습니다."; + INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "기록소는 사진 권한을 필요로 합니다. 허용 안 함 시 일부 기능이 동작하지 않을 수 있습니다."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; @@ -310,6 +312,8 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = MHApplication/Resource/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "기록소"; + INFOPLIST_KEY_NSCameraUsageDescription = "기록소는 카메라 권한을 필요로 합니다. 허용 안 함 시 일부 기능이 동작하지 않을 수 있습니다."; + INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "기록소는 사진 권한을 필요로 합니다. 허용 안 함 시 일부 기능이 동작하지 않을 수 있습니다."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; diff --git a/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj b/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj index e92caa37..4efe7b6e 100644 --- a/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj +++ b/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 0E7F291B2CDB530E007D4F2B /* UILabel+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */; }; 0E7F291D2CDB53B5007D4F2B /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */; }; 0E7F291F2CDB5D66007D4F2B /* Colors.xcassets in Headers */ = {isa = PBXBuildFile; fileRef = 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */; settings = {ATTRIBUTES = (Public, ); }; }; + A8A32C512CDBB9360078B4F6 /* EditPhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C502CDBB9360078B4F6 /* EditPhotoViewController.swift */; }; + A8A32C532CDBB9980078B4F6 /* CustomAlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */; }; + A8A32C572CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */; }; CE9AEBAB2CD7B51D00F8471D /* MHDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE9AEBAA2CD7B51D00F8471D /* MHDomain.framework */; }; CE9AEBFA2CD7BA2000F8471D /* MHCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE9AEBF92CD7BA2000F8471D /* MHCore.framework */; }; DB382CC52CD9B22E000D7689 /* MHFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB382CC42CD9B22E000D7689 /* MHFoundation.framework */; }; @@ -23,6 +26,9 @@ 0E7F29182CDB52D4007D4F2B /* UIFont+Ownglyph.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Ownglyph.swift"; sourceTree = ""; }; 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+Style.swift"; sourceTree = ""; }; 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; + A8A32C502CDBB9360078B4F6 /* EditPhotoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditPhotoViewController.swift; sourceTree = ""; }; + A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlbumViewController.swift; sourceTree = ""; }; + A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlbumCollectionViewCell.swift; sourceTree = ""; }; CE9AEB992CD7B4F200F8471D /* MHPresentation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MHPresentation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CE9AEBAA2CD7B51D00F8471D /* MHDomain.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MHDomain.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CE9AEBF92CD7BA2000F8471D /* MHCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MHCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -56,6 +62,7 @@ 0E7F28E62CDA6B63007D4F2B /* Source */ = { isa = PBXGroup; children = ( + A8A32C4F2CDBB91C0078B4F6 /* EditPhoto */, 0E7F29172CDB52CC007D4F2B /* Extensions */, ); path = Source; @@ -78,6 +85,32 @@ path = Extensions; sourceTree = ""; }; + A8A32C4F2CDBB91C0078B4F6 /* EditPhoto */ = { + isa = PBXGroup; + children = ( + A8A32C542CDBBA730078B4F6 /* View */, + A8A32C552CDBBA800078B4F6 /* ViewModel */, + ); + path = EditPhoto; + sourceTree = ""; + }; + A8A32C542CDBBA730078B4F6 /* View */ = { + isa = PBXGroup; + children = ( + A8A32C502CDBB9360078B4F6 /* EditPhotoViewController.swift */, + A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */, + A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */, + ); + path = View; + sourceTree = ""; + }; + A8A32C552CDBBA800078B4F6 /* ViewModel */ = { + isa = PBXGroup; + children = ( + ); + path = ViewModel; + sourceTree = ""; + }; CE9AEB8F2CD7B4F200F8471D = { isa = PBXGroup; children = ( @@ -224,6 +257,9 @@ buildActionMask = 2147483647; files = ( 0E7F29192CDB52DE007D4F2B /* UIFont+Ownglyph.swift in Sources */, + A8A32C572CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift in Sources */, + A8A32C532CDBB9980078B4F6 /* CustomAlbumViewController.swift in Sources */, + A8A32C512CDBB9360078B4F6 /* EditPhotoViewController.swift in Sources */, 0E7F291B2CDB530E007D4F2B /* UILabel+Style.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From 26d04575394cb50d10d0ededf696bfaa0f4e5e5b Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 7 Nov 2024 00:37:42 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=EC=95=A8=EB=B2=94=20layout=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/CustomAlbumCollectionViewCell.swift | 49 +++++++++++ .../View/CustomAlbumViewController.swift | 88 +++++++++++++++++++ .../View/EditPhotoViewController.swift | 7 ++ 3 files changed, 144 insertions(+) create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift new file mode 100644 index 00000000..eaf36ee8 --- /dev/null +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift @@ -0,0 +1,49 @@ +import UIKit + +final class CustomAlbumCollectionViewCell: UICollectionViewCell { + // MARK: - Properties + static let id = "CustomAlbumCollectionViewCell" + private let photoImageView = UIImageView(image: nil) + var representedAssetIdentifier: String? + + // MARK: - Initialize + override init(frame: CGRect) { + super.init(frame: frame) + + setup() + configureConstraints() + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + + setup() + configureConstraints() + } + + override func prepareForReuse() { + super.prepareForReuse() + + photoImageView.image = nil + } + + // MARK: - Setup & Configure + private func setup() { + photoImageView.translatesAutoresizingMaskIntoConstraints = false + } + + private func configureConstraints() { + contentView.addSubview(photoImageView) + NSLayoutConstraint.activate([ + photoImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + photoImageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), + photoImageView.topAnchor.constraint(equalTo: contentView.topAnchor), + photoImageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor) + ]) + } + + // MARK: - Set Cell Image + func setPhoto(_ photo: UIImage?) { + photoImageView.image = photo + } +} diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift new file mode 100644 index 00000000..b9069c3c --- /dev/null +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift @@ -0,0 +1,88 @@ +import UIKit +import Photos + +final class CustomAlbumViewController: UIViewController { + // MARK: - Properties + private var asset: PHFetchResult? + private let imageManager = PHCachingImageManager() + private lazy var cellSize = (self.view.bounds.inset(by: self.view.safeAreaInsets).width - 20) / 3 + private lazy var albumCollectionView: UICollectionView = { + let flowLayout = UICollectionViewFlowLayout() + flowLayout.itemSize = CGSize(width: self.cellSize, height: self.cellSize) + flowLayout.minimumLineSpacing = 10 + flowLayout.minimumInteritemSpacing = 10 + flowLayout.scrollDirection = .vertical + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout) + collectionView.translatesAutoresizingMaskIntoConstraints = false + + return collectionView + }() + + // MARK: - Initialize + required init?(coder: NSCoder) { + super.init(coder: coder) + } + + override func viewDidLoad() { + super.viewDidLoad() + + setup() + configureConstraints() + } + + // MARK: - Setup & Configure + private func setup() { + let fetchOptions = PHFetchOptions() + fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)] + + asset = PHAsset.fetchAssets(with: fetchOptions) + albumCollectionView.delegate = self + albumCollectionView.dataSource = self + albumCollectionView.register( + CustomAlbumCollectionViewCell.self, + forCellWithReuseIdentifier: CustomAlbumCollectionViewCell.id + ) + } + + private func configureConstraints() { + view.addSubview(albumCollectionView) + + NSLayoutConstraint.activate([ + albumCollectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), + albumCollectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), + albumCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + albumCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor) + ]) + } +} + +// MARK: - UICollectionViewDelegate, UICollectionViewDataSource +extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return asset?.count ?? 0 + } + + func collectionView( + _ collectionView: UICollectionView, + cellForItemAt indexPath: IndexPath + ) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell( + withReuseIdentifier: CustomAlbumCollectionViewCell.id, + for: indexPath + ) as? CustomAlbumCollectionViewCell else { return UICollectionViewCell() } + + guard let asset = asset?[indexPath.item] else { return cell } + cell.representedAssetIdentifier = asset.localIdentifier + imageManager.requestImage( + for: asset, + targetSize: CGSize(width: cellSize, height: cellSize), + contentMode: .aspectFill, options: nil + ) { image, _ in + if cell.representedAssetIdentifier == asset.localIdentifier { + cell.setPhoto(image) + } + } + + return cell + } +} diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift new file mode 100644 index 00000000..81c508f0 --- /dev/null +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift @@ -0,0 +1,7 @@ +import UIKit + +final class EditPhotoViewController: UIViewController { + override func viewDidLoad() { + super.viewDidLoad() + } +} From 31a0493b939b35f88bb51621fde66f305938613f Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 7 Nov 2024 22:21:39 +0900 Subject: [PATCH 3/7] =?UTF-8?q?chore:=20EditPhotoView=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EB=B0=8F=20=EB=94=94=EB=A0=89=ED=86=A0=EB=A6=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MHPresentation.xcodeproj/project.pbxproj | 26 +++---------------- .../View/EditPhotoViewController.swift | 7 ----- 2 files changed, 3 insertions(+), 30 deletions(-) delete mode 100644 MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift diff --git a/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj b/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj index 4efe7b6e..0e83160f 100644 --- a/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj +++ b/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 0E7F291B2CDB530E007D4F2B /* UILabel+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */; }; 0E7F291D2CDB53B5007D4F2B /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */; }; 0E7F291F2CDB5D66007D4F2B /* Colors.xcassets in Headers */ = {isa = PBXBuildFile; fileRef = 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */; settings = {ATTRIBUTES = (Public, ); }; }; - A8A32C512CDBB9360078B4F6 /* EditPhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C502CDBB9360078B4F6 /* EditPhotoViewController.swift */; }; A8A32C532CDBB9980078B4F6 /* CustomAlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */; }; A8A32C572CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */; }; CE9AEBAB2CD7B51D00F8471D /* MHDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE9AEBAA2CD7B51D00F8471D /* MHDomain.framework */; }; @@ -26,7 +25,6 @@ 0E7F29182CDB52D4007D4F2B /* UIFont+Ownglyph.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Ownglyph.swift"; sourceTree = ""; }; 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+Style.swift"; sourceTree = ""; }; 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; - A8A32C502CDBB9360078B4F6 /* EditPhotoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditPhotoViewController.swift; sourceTree = ""; }; A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlbumViewController.swift; sourceTree = ""; }; A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlbumCollectionViewCell.swift; sourceTree = ""; }; CE9AEB992CD7B4F200F8471D /* MHPresentation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MHPresentation.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -62,7 +60,7 @@ 0E7F28E62CDA6B63007D4F2B /* Source */ = { isa = PBXGroup; children = ( - A8A32C4F2CDBB91C0078B4F6 /* EditPhoto */, + A8A32C5C2CDCEBD60078B4F6 /* CustomAlbum */, 0E7F29172CDB52CC007D4F2B /* Extensions */, ); path = Source; @@ -85,30 +83,13 @@ path = Extensions; sourceTree = ""; }; - A8A32C4F2CDBB91C0078B4F6 /* EditPhoto */ = { + A8A32C5C2CDCEBD60078B4F6 /* CustomAlbum */ = { isa = PBXGroup; children = ( - A8A32C542CDBBA730078B4F6 /* View */, - A8A32C552CDBBA800078B4F6 /* ViewModel */, - ); - path = EditPhoto; - sourceTree = ""; - }; - A8A32C542CDBBA730078B4F6 /* View */ = { - isa = PBXGroup; - children = ( - A8A32C502CDBB9360078B4F6 /* EditPhotoViewController.swift */, A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */, A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */, ); - path = View; - sourceTree = ""; - }; - A8A32C552CDBBA800078B4F6 /* ViewModel */ = { - isa = PBXGroup; - children = ( - ); - path = ViewModel; + path = CustomAlbum; sourceTree = ""; }; CE9AEB8F2CD7B4F200F8471D = { @@ -259,7 +240,6 @@ 0E7F29192CDB52DE007D4F2B /* UIFont+Ownglyph.swift in Sources */, A8A32C572CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift in Sources */, A8A32C532CDBB9980078B4F6 /* CustomAlbumViewController.swift in Sources */, - A8A32C512CDBB9360078B4F6 /* EditPhotoViewController.swift in Sources */, 0E7F291B2CDB530E007D4F2B /* UILabel+Style.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift deleted file mode 100644 index 81c508f0..00000000 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/EditPhotoViewController.swift +++ /dev/null @@ -1,7 +0,0 @@ -import UIKit - -final class EditPhotoViewController: UIViewController { - override func viewDidLoad() { - super.viewDidLoad() - } -} From a9985f0f84159a484b229a3de6fbcf936f90bfe1 Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 7 Nov 2024 22:23:31 +0900 Subject: [PATCH 4/7] =?UTF-8?q?design:=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PhotoImage.imageset/Camera_duotone.png | Bin 0 -> 463 bytes .../PhotoImage.imageset/Camera_duotone@2x.png | Bin 0 -> 835 bytes .../PhotoImage.imageset/Camera_duotone@3x.png | Bin 0 -> 1236 bytes .../PhotoImage.imageset/Contents.json | 23 ++++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone.png create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone@2x.png create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone@3x.png create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Contents.json diff --git a/MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone.png b/MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone.png new file mode 100644 index 0000000000000000000000000000000000000000..2801c66a99d18320e671b6931035e26e526be173 GIT binary patch literal 463 zcmeAS@N?(olHy`uVBq!ia0vp^t{}|81|(&AwKahhXMsm#F#`j)FbFd;%$g$s6l5$8 za(7}_cTVOdki(Mh=CakAlWFl$0U*48j zWo?a$@BezCe5LTt3Ci4xH#6T&W#9jmccJXx+^c)iPc5}$FPR&>?`ocysHb!Fy?guH zzezaxmGo~YTe&iJ0O>g4{^8JeY*opPtD_Fk*7xmIFzHECnO;)?;>Z-?%`AHFus z`o?)NP0LQHE>hG((A8t%VyeqySMGB#G?7ZVXLRAP3C+)MQhGy tOVz3U;g+BHp2l6}SKxgM3}P7g_m26ikoak-$XqRukf*Dk%Q~loCICxkxzhju literal 0 HcmV?d00001 diff --git a/MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone@2x.png b/MemorialHouse/MHPresentation/MHPresentation/Resource/Colors.xcassets/PhotoImage.imageset/Camera_duotone@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..97e936a81b3a07ce06777144faa9372acec9f5aa GIT binary patch literal 835 zcmeAS@N?(olHy`uVBq!ia0vp^T_DWC1|&<{FQot}&H|6fVg?2=RS;(M3{v?36l5$8 za(7}_cTVOdki(Mh=3pHMC1hd4t(k>MoUWW^_jn(Ew&^#C zN~~1n-ajwDEUio#Xb~>3%t(eWe)_jci{1W9bJ;(yt~ogSaNU&!w%wNB-M6e>KW{b=gyme=YuF6MFv`yS=QnkHz-&n=bqO{Aqma%VD{M>T2tC>(;%qEzHc+?Ca~> zS6>-ZcklQdujnea=7XOPp0}M}@GI?0{<_oW6{Lbs`&sVk{uevF;h$)6mY&!7?H?U; zPY3V$`~QdOys76uZj#Y|zo#trzaHZ*zPkCJj{XV1)&B5uxc%eP9y+-%HUIyxs`w+Y z^G|fu^zRb`o>fk{KJol&53S;WY0C5WE3Z7WG+pB7lD$SkQ>@ROJNM|vkBSl*|2=Eh ztvhz=lvhqp&XHfgs!BrDE0q)-HM2DM`1sryclytrdiVZ)dD(PTjs7+37tEPI|MVtgwJb}&saRWE2e+rJX?yzNL&36ns@VZi_tHKrnD=De z?AfyeS7v!`cC@s#oVg>YX1>+DnI_9-s-I(LCH)L>Di@vs*BT_H*MP{7JK#O-!K#DDQnlReX**4>wKMA?*eyy z(b`&awe?V#iS3NLcklMLwzgKRsPc<_pXqtoQF1+-y^7A`3118)&K)sp{$V8_biG#X zZ1oo1K-6l5$8 za(7}_cTVOdki(Mh=2U??6~aUxu89U+gIbwFQfU7xy#DV-nF#0KKA{$=i;e3 z*|}@Kz0Xf8OVeip+C(7MzYsUu2mQD`9sKfkN3`@}cZqDzyBqZ- z+5GhUUBWz%ZZ9~$_|mks8vRM8ll5zjn?L{f_}F44E90yw+k|v{BtJv`Z9Q~fPx|JlQvJl3V}uKu3) zRe;lfI`^f;t`$ZG{`2i(txVce3yd7Rb$DzIAHFPdtm=`S$K$*0zc%xfwQLVx8YN!1 z5pYoQSB#FD4e!%+7Z>J#v$_B6TUo&T4-4F?w=EeR zV-H<+Xj9vrW14#1_v=dU3aJz9^S7pcT`7B^RNaPmPt{kgV;|n#-Mv8WVdjEs5zqG@ zTT$@Zr$S0%wUWf=E2=i>5q;Gw+$*Fk%HPF&_$oY)?c98O`Q#lnKZ^qTKbTDTU2x3c zTHO3nRU6)(P{E?ZGG96TnRmWV>nS`RA(|J<>CbHWY-jOvzbjK1ujZ}>+J5uatyN*Q z&#b*cPC5Ci`2D@TD-wIkr4(#@Q@={?a=KDCopC;=f3oww@&(VVd0u=9YM0Z!H_!O~ zq}oZYi!IAe=_Q11irT}l_ZHhszXd+Y*F zV4ix#&rhi}e|~(tA9_P_!kml~&&_`>`1es Date: Thu, 7 Nov 2024 22:27:13 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=EC=95=A8=EB=B2=94=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20=EC=A0=91=EA=B7=BC=20?= =?UTF-8?q?=EB=B0=8F=20=EC=95=A8=EB=B2=94=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=84=98=EC=96=B4=EA=B0=80=EB=8A=94=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomAlbumCollectionViewCell.swift | 15 +++- .../CustomAlbumViewController.swift | 75 +++++++++++++++---- 2 files changed, 72 insertions(+), 18 deletions(-) rename MemorialHouse/MHPresentation/MHPresentation/Source/{EditPhoto/View => CustomAlbum}/CustomAlbumCollectionViewCell.swift (75%) rename MemorialHouse/MHPresentation/MHPresentation/Source/{EditPhoto/View => CustomAlbum}/CustomAlbumViewController.swift (51%) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift similarity index 75% rename from MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift rename to MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift index eaf36ee8..341e3b39 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumCollectionViewCell.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift @@ -3,8 +3,14 @@ import UIKit final class CustomAlbumCollectionViewCell: UICollectionViewCell { // MARK: - Properties static let id = "CustomAlbumCollectionViewCell" - private let photoImageView = UIImageView(image: nil) - var representedAssetIdentifier: String? + private let photoImageView: UIImageView = { + let imageView = UIImageView(image: nil) + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.contentMode = .scaleAspectFill + imageView.clipsToBounds = true + + return imageView + }() // MARK: - Initialize override init(frame: CGRect) { @@ -21,15 +27,16 @@ final class CustomAlbumCollectionViewCell: UICollectionViewCell { configureConstraints() } + // MARK: - PrepareForReuse override func prepareForReuse() { super.prepareForReuse() photoImageView.image = nil } - // MARK: - Setup & Configure + // MARK: - Configure private func setup() { - photoImageView.translatesAutoresizingMaskIntoConstraints = false + contentView.backgroundColor = .lightGray } private func configureConstraints() { diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift similarity index 51% rename from MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift rename to MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift index b9069c3c..7d44b4a4 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/View/CustomAlbumViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift @@ -3,14 +3,16 @@ import Photos final class CustomAlbumViewController: UIViewController { // MARK: - Properties - private var asset: PHFetchResult? + private var imageAsset: PHFetchResult? private let imageManager = PHCachingImageManager() - private lazy var cellSize = (self.view.bounds.inset(by: self.view.safeAreaInsets).width - 20) / 3 + private let imagePicker = UIImagePickerController() + private lazy var albumCollectionView: UICollectionView = { let flowLayout = UICollectionViewFlowLayout() - flowLayout.itemSize = CGSize(width: self.cellSize, height: self.cellSize) + let cellSize = (self.view.bounds.inset(by: self.view.safeAreaInsets).width - 10) / 3 + flowLayout.itemSize = CGSize(width: cellSize, height: cellSize) flowLayout.minimumLineSpacing = 10 - flowLayout.minimumInteritemSpacing = 10 + flowLayout.minimumInteritemSpacing = 5 flowLayout.scrollDirection = .vertical let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout) collectionView.translatesAutoresizingMaskIntoConstraints = false @@ -35,7 +37,8 @@ final class CustomAlbumViewController: UIViewController { let fetchOptions = PHFetchOptions() fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)] - asset = PHAsset.fetchAssets(with: fetchOptions) + imageAsset = PHAsset.fetchAssets(with: fetchOptions) + imagePicker.delegate = self albumCollectionView.delegate = self albumCollectionView.dataSource = self albumCollectionView.register( @@ -54,12 +57,24 @@ final class CustomAlbumViewController: UIViewController { albumCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor) ]) } + + // MARK: - Open Camera + private func openCamera() { + if (UIImagePickerController.isSourceTypeAvailable(.camera)) { + imagePicker.sourceType = .camera + navigationController?.pushViewController(imagePicker, animated: true) + } else { + // TODO: - 카메라 접근 권한 Alert + print("카메라에 접근할 수 없습니다.") + } + } } // MARK: - UICollectionViewDelegate, UICollectionViewDataSource extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return asset?.count ?? 0 + guard let imageAsset else { return 1 } + return imageAsset.count + 1 } func collectionView( @@ -71,18 +86,50 @@ extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewD for: indexPath ) as? CustomAlbumCollectionViewCell else { return UICollectionViewCell() } - guard let asset = asset?[indexPath.item] else { return cell } - cell.representedAssetIdentifier = asset.localIdentifier - imageManager.requestImage( - for: asset, - targetSize: CGSize(width: cellSize, height: cellSize), - contentMode: .aspectFill, options: nil - ) { image, _ in - if cell.representedAssetIdentifier == asset.localIdentifier { + if indexPath.item == 0 { + cell.setPhoto(.photo) + } else { + guard let asset = imageAsset?[indexPath.item - 1] else { return cell } + let cellSize = cell.bounds.size + imageManager.requestImage( + for: asset, + targetSize: cellSize, + contentMode: .aspectFill, + options: nil + ) { image, _ in cell.setPhoto(image) } } return cell } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + if indexPath.item == 0 { + self.openCamera() + } else { + guard let asset = self.imageAsset?[indexPath.item - 1] else { return } + imageManager.requestImage( + for: asset, + targetSize: .zero, + contentMode: .default, + options: nil + ) { image, _ in + // TODO: - 이미지 편집 뷰 로 이동 + } + } + } +} + +// MARK: - UIImagePickerControllerDelegate, UINavigationControllerDelegate +extension CustomAlbumViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + func imagePickerController( + _ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any] + ) { + if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { + // TODO: - 이미지 편집 뷰로 이동 + } + dismiss(animated: true, completion: nil) + } } From bb854654111a10bcd2485718ace4c6dd747d086a Mon Sep 17 00:00:00 2001 From: k2645 Date: Fri, 8 Nov 2024 20:09:41 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20CollectionViewCell=EC=9D=98=20ident?= =?UTF-8?q?ifier=EB=A5=BC=20=ED=91=9C=ED=98=84=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20extension=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MHPresentation.xcodeproj/project.pbxproj | 4 ++++ .../Extensions/UICollectionViewCell+Identifier.swift | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 MemorialHouse/MHPresentation/MHPresentation/Source/Extensions/UICollectionViewCell+Identifier.swift diff --git a/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj b/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj index c27ac117..adc982ed 100644 --- a/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj +++ b/MemorialHouse/MHPresentation/MHPresentation.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 0E7F291B2CDB530E007D4F2B /* UILabel+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */; }; 0E7F291D2CDB53B5007D4F2B /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */; }; 0E7F291F2CDB5D66007D4F2B /* Colors.xcassets in Headers */ = {isa = PBXBuildFile; fileRef = 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */; settings = {ATTRIBUTES = (Public, ); }; }; + A840E5932CDE266F002A1C94 /* UICollectionViewCell+Identifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = A840E5922CDE266F002A1C94 /* UICollectionViewCell+Identifier.swift */; }; A8A32C532CDBB9980078B4F6 /* CustomAlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */; }; A8A32C572CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */; }; A8A32C592CDC98D40078B4F6 /* OwnglyphBerry.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A8A32C582CDC98D40078B4F6 /* OwnglyphBerry.ttf */; }; @@ -25,6 +26,7 @@ 0E7F29182CDB52D4007D4F2B /* UIFont+Ownglyph.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Ownglyph.swift"; sourceTree = ""; }; 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+Style.swift"; sourceTree = ""; }; 0E7F291C2CDB53B5007D4F2B /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; + A840E5922CDE266F002A1C94 /* UICollectionViewCell+Identifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionViewCell+Identifier.swift"; sourceTree = ""; }; A8A32C522CDBB9980078B4F6 /* CustomAlbumViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlbumViewController.swift; sourceTree = ""; }; A8A32C562CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlbumCollectionViewCell.swift; sourceTree = ""; }; A8A32C582CDC98D40078B4F6 /* OwnglyphBerry.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = OwnglyphBerry.ttf; sourceTree = ""; }; @@ -80,6 +82,7 @@ children = ( 0E7F291A2CDB5302007D4F2B /* UILabel+Style.swift */, 0E7F29182CDB52D4007D4F2B /* UIFont+Ownglyph.swift */, + A840E5922CDE266F002A1C94 /* UICollectionViewCell+Identifier.swift */, ); path = Extensions; sourceTree = ""; @@ -242,6 +245,7 @@ 0E7F29192CDB52DE007D4F2B /* UIFont+Ownglyph.swift in Sources */, A8A32C572CDBBB500078B4F6 /* CustomAlbumCollectionViewCell.swift in Sources */, A8A32C532CDBB9980078B4F6 /* CustomAlbumViewController.swift in Sources */, + A840E5932CDE266F002A1C94 /* UICollectionViewCell+Identifier.swift in Sources */, 0E7F291B2CDB530E007D4F2B /* UILabel+Style.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Extensions/UICollectionViewCell+Identifier.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Extensions/UICollectionViewCell+Identifier.swift new file mode 100644 index 00000000..b45b361c --- /dev/null +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Extensions/UICollectionViewCell+Identifier.swift @@ -0,0 +1,7 @@ +import UIKit + +extension UICollectionViewCell { + static var identifier: String { + String(describing: self) + } +} From 1cd66b01ef1b0b04211633c77c8a4049df275cb2 Mon Sep 17 00:00:00 2001 From: k2645 Date: Fri, 8 Nov 2024 20:11:30 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=EC=BD=94=EB=93=9C=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=20=EB=B0=98=EC=98=81=20-=20Cell=EC=9D=98=20identifier=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20-=20UICollectionViewDelegate=EC=99=80=20UI?= =?UTF-8?q?CollectionViewDataSource=20=ED=94=84=EB=A1=9C=ED=86=A0=EC=BD=9C?= =?UTF-8?q?=20extension=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomAlbumCollectionViewCell.swift | 1 - .../CustomAlbumViewController.swift | 58 ++++++++++--------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift index 341e3b39..f8506a17 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumCollectionViewCell.swift @@ -2,7 +2,6 @@ import UIKit final class CustomAlbumCollectionViewCell: UICollectionViewCell { // MARK: - Properties - static let id = "CustomAlbumCollectionViewCell" private let photoImageView: UIImageView = { let imageView = UIImageView(image: nil) imageView.translatesAutoresizingMaskIntoConstraints = false diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift index 7d44b4a4..ddfa62a5 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/CustomAlbumViewController.swift @@ -20,11 +20,7 @@ final class CustomAlbumViewController: UIViewController { return collectionView }() - // MARK: - Initialize - required init?(coder: NSCoder) { - super.init(coder: coder) - } - + // MARK: - ViewDidLoad override func viewDidLoad() { super.viewDidLoad() @@ -43,7 +39,7 @@ final class CustomAlbumViewController: UIViewController { albumCollectionView.dataSource = self albumCollectionView.register( CustomAlbumCollectionViewCell.self, - forCellWithReuseIdentifier: CustomAlbumCollectionViewCell.id + forCellWithReuseIdentifier: CustomAlbumCollectionViewCell.identifier ) } @@ -65,14 +61,38 @@ final class CustomAlbumViewController: UIViewController { navigationController?.pushViewController(imagePicker, animated: true) } else { // TODO: - 카메라 접근 권한 Alert - print("카메라에 접근할 수 없습니다.") } } } -// MARK: - UICollectionViewDelegate, UICollectionViewDataSource -extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewDataSource { - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { +// MARK: - UICollectionViewDelegate +extension CustomAlbumViewController: UICollectionViewDelegate { + func collectionView( + _ collectionView: UICollectionView, + didSelectItemAt indexPath: IndexPath + ) { + if indexPath.item == 0 { + self.openCamera() + } else { + guard let asset = self.imageAsset?[indexPath.item - 1] else { return } + imageManager.requestImage( + for: asset, + targetSize: .zero, + contentMode: .default, + options: nil + ) { image, _ in + // TODO: - 이미지 편집 뷰 로 이동 + } + } + } +} + +// MARK: - UICollectionViewDataSource +extension CustomAlbumViewController: UICollectionViewDataSource { + func collectionView( + _ collectionView: UICollectionView, + numberOfItemsInSection section: Int + ) -> Int { guard let imageAsset else { return 1 } return imageAsset.count + 1 } @@ -82,7 +102,7 @@ extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewD cellForItemAt indexPath: IndexPath ) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell( - withReuseIdentifier: CustomAlbumCollectionViewCell.id, + withReuseIdentifier: CustomAlbumCollectionViewCell.identifier, for: indexPath ) as? CustomAlbumCollectionViewCell else { return UICollectionViewCell() } @@ -103,22 +123,6 @@ extension CustomAlbumViewController: UICollectionViewDelegate, UICollectionViewD return cell } - - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - if indexPath.item == 0 { - self.openCamera() - } else { - guard let asset = self.imageAsset?[indexPath.item - 1] else { return } - imageManager.requestImage( - for: asset, - targetSize: .zero, - contentMode: .default, - options: nil - ) { image, _ in - // TODO: - 이미지 편집 뷰 로 이동 - } - } - } } // MARK: - UIImagePickerControllerDelegate, UINavigationControllerDelegate