From 580369ff7daac4a401ec5f2a6d399b43c467242d Mon Sep 17 00:00:00 2001 From: k2645 Date: Wed, 4 Dec 2024 19:45:49 +0900 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20MHPolaroid=20AutoLayout=20=EC=9E=AC?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MHPresentation/Source/Design/MHPolaroidPhotoView.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift index 8d43fae9..2600deeb 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift @@ -64,8 +64,11 @@ final class MHPolaroidPhotoView: UIView { private func configureConstraints() { photoImageView.setAnchor(top: topAnchor, constantTop: 25, - width: 280, height: 210) - photoImageView.setCenterX(view: self) + leading: leadingAnchor, constantLeading: 17, + trailing: trailingAnchor, constantTrailing: 17) + NSLayoutConstraint.activate([ + photoImageView.heightAnchor.constraint(equalTo: photoImageView.widthAnchor, multiplier: 0.75) + ]) captionLabel.setAnchor(top: photoImageView.bottomAnchor, constantTop: 12, leading: photoImageView.leadingAnchor) From c8bdb7f53da3d8761facbb0cad00fd8b71aa1642 Mon Sep 17 00:00:00 2001 From: k2645 Date: Wed, 4 Dec 2024 21:34:17 +0900 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20polaroid=20label=20trailing=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=B0=8F=20caption=20=EA=B8=80=EC=9E=90?= =?UTF-8?q?=EC=88=98=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Design/MHPolaroidPhotoView.swift | 3 ++- .../EditPhoto/EditPhotoViewController.swift | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift index 2600deeb..e50e2f79 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Design/MHPolaroidPhotoView.swift @@ -71,7 +71,8 @@ final class MHPolaroidPhotoView: UIView { ]) captionLabel.setAnchor(top: photoImageView.bottomAnchor, constantTop: 12, - leading: photoImageView.leadingAnchor) + leading: photoImageView.leadingAnchor, + trailing: photoImageView.trailingAnchor) creationDateLabel.setAnchor(bottom: bottomAnchor, constantBottom: 7, trailing: trailingAnchor, constantTrailing: 12) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift index a188f197..a357a4d2 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/EditPhoto/EditPhotoViewController.swift @@ -100,7 +100,7 @@ final class EditPhotoViewController: UIViewController { configureNavigationBar() configureAddSubView() configureConstraints() - configureButtonAction() + configureAction() } override func viewWillAppear(_ animated: Bool) { @@ -213,7 +213,7 @@ final class EditPhotoViewController: UIViewController { dividedLine2.setBottom(anchor: editButtonStackView.topAnchor, constant: 11) captionTextField.setAnchor( leading: view.leadingAnchor, constantLeading: 13, - trailing: view.trailingAnchor, + trailing: view.trailingAnchor, constantTrailing: 13, height: 30 ) captionTextFieldBottomConstraint = captionTextField.bottomAnchor.constraint( @@ -269,18 +269,26 @@ final class EditPhotoViewController: UIViewController { ) } - // MARK: - Add Button Action - private func configureButtonAction() { + private func configureAction() { let rotateButtonAction = UIAction { [weak self] _ in guard let self else { return } let image = self.photoImageView.image self.photoImageView.image = image?.rotate(radians: .pi / 2) } + rotateButton.addAction(rotateButtonAction, for: .touchUpInside) + let drawButtonAction = UIAction { _ in // TODO: - Draw Action } - rotateButton.addAction(rotateButtonAction, for: .touchUpInside) drawButton.addAction(drawButtonAction, for: .touchUpInside) + + let textFieldAction = UIAction { [weak self] _ in + guard let self else { return } + if self.captionTextField.text?.count ?? 0 > 50 { + self.captionTextField.text = String(self.captionTextField.text?.prefix(50) ?? "") + } + } + captionTextField.addAction(textFieldAction, for: .editingChanged) } // MARK: - Keyboard Appear & Hide From 5635243caeb6f67efa8a6333f746f8697c1f9322 Mon Sep 17 00:00:00 2001 From: k2645 Date: Wed, 4 Dec 2024 22:19:47 +0900 Subject: [PATCH 3/7] =?UTF-8?q?fix:=20Local=EC=97=94=20=EC=97=86=EA=B3=A0?= =?UTF-8?q?=20iCloud=EC=97=90=20=EC=A1=B4=EC=9E=AC=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B6=88=EB=9F=AC=EC=99=80?= =?UTF-8?q?=EC=A7=80=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - isNetworkAccessAllowed 옵션 설정 --- .../CustomAlbum/View/CustomAlbumViewController.swift | 1 + .../CustomAlbum/ViewModel/LocalPhotoManager.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift index 87385c30..73d748d6 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift @@ -229,6 +229,7 @@ final class CustomAlbumViewController: UIViewController { navigationController?.show(imagePicker, sender: nil) } } + private func moveToEditPhotoView(image: UIImage?, creationDate: Date) { guard let photoSelectCompletionHandler else { return } var editPhotoViewController: EditPhotoViewController diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift index fb9fedcb..33afe90c 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift @@ -4,10 +4,11 @@ import Photos actor LocalPhotoManager { static let shared = LocalPhotoManager() - private let imageManager = PHImageManager() + private let imageManager = PHCachingImageManager() private let imageRequestOptions: PHImageRequestOptions = { let options = PHImageRequestOptions() options.isSynchronous = true + options.isNetworkAccessAllowed = true return options }() @@ -29,6 +30,13 @@ actor LocalPhotoManager { resultHandler: { image, _ in Task { await completion(image) } }) + + imageManager.startCachingImages( + for: [asset], + targetSize: cellSize, + contentMode: .aspectFill, + options: nil + ) } func requestVideoURL( From 395ba3d5daa4058818ebea0168445cf63a0461ce Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 5 Dec 2024 01:15:57 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EA=B0=80?= =?UTF-8?q?=EB=8F=85=EC=84=B1=20=EC=A6=9D=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/CustomAlbumViewController.swift | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift index 73d748d6..8f5f9237 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift @@ -68,10 +68,10 @@ final class CustomAlbumViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + bind() setup() configureConstraints() configureNavigationBar() - bind() checkThumbnailAuthorization() } @@ -81,6 +81,32 @@ final class CustomAlbumViewController: UIViewController { configureNavigationAppearance() } + // MARK: - Binding + private func bind() { + let output = viewModel.transform(input: input.eraseToAnyPublisher()) + + output.receive(on: DispatchQueue.main) + .sink { [weak self] event in + switch event { + case .fetchAssets: + self?.albumCollectionView.reloadData() + case .changedAssets(let changes): + self?.albumCollectionView.performBatchUpdates { + if let inserted = changes.insertedIndexes, !inserted.isEmpty { + self?.albumCollectionView.insertItems( + at: inserted.map({ IndexPath(item: $0 + 1, section: 0) }) + ) + } + if let removed = changes.removedIndexes, !removed.isEmpty { + self?.albumCollectionView.deleteItems( + at: removed.map({ IndexPath(item: $0 + 1, section: 0) }) + ) + } + } + } + }.store(in: &cancellables) + } + // MARK: - Setup & Configure private func setup() { view.backgroundColor = .baseBackground @@ -99,7 +125,6 @@ final class CustomAlbumViewController: UIViewController { } private func configureNavigationBar() { - // TODO: - 추후 삭제 필요 navigationController?.navigationBar.isHidden = false if mediaType == .image { navigationItem.title = "사진 선택" @@ -139,33 +164,6 @@ final class CustomAlbumViewController: UIViewController { navigationController?.navigationBar.scrollEdgeAppearance = navigationBarAppearance } - // MARK: - Binding - private func bind() { - let output = viewModel.transform(input: input.eraseToAnyPublisher()) - - output.receive(on: DispatchQueue.main) - .sink { [weak self] event in - switch event { - case .fetchAssets: - self?.albumCollectionView.reloadData() - case .changedAssets(let changes): - self?.albumCollectionView.performBatchUpdates { - if let inserted = changes.insertedIndexes, !inserted.isEmpty { - self?.albumCollectionView.insertItems( - at: inserted.map({ IndexPath(item: $0 + 1, section: 0) }) - ) - } - if let removed = changes.removedIndexes, !removed.isEmpty { - self?.albumCollectionView.deleteItems( - at: removed.map({ IndexPath(item: $0 + 1, section: 0) }) - ) - } - } - } - } - .store(in: &cancellables) - } - // MARK: - Media private func checkThumbnailAuthorization() { let authorization = PHPhotoLibrary.authorizationStatus() @@ -282,7 +280,8 @@ extension CustomAlbumViewController: UICollectionViewDelegate { private func handleImageSelection(with asset: PHAsset) { Task { await LocalPhotoManager.shared.requestThumbnailImage(with: asset) { [weak self] image in - guard let self = self, let image = image else { return } + guard let self, + let image else { return } self.moveToEditPhotoView(image: image, creationDate: asset.creationDate ?? .now) } } From 99711c8365370f674eecfd130899b23e393385cd Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 5 Dec 2024 01:46:38 +0900 Subject: [PATCH 5/7] =?UTF-8?q?fix:=20=EB=B9=A0=EB=A5=B4=EA=B2=8C=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EB=82=B4=EB=A6=B4=EC=8B=9C=20?= =?UTF-8?q?=EC=82=AC=EC=A7=84=20=EB=B0=B0=EC=97=B4=20=EC=9D=B4=EC=83=81?= =?UTF-8?q?=ED=95=B4=EC=A7=80=EB=8A=94=20=EB=B2=84=EA=B7=B8=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 --- .../CustomAlbum/View/CustomAlbumCollectionViewCell.swift | 1 + .../Source/CustomAlbum/View/CustomAlbumViewController.swift | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumCollectionViewCell.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumCollectionViewCell.swift index 98c0969e..2e06c669 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumCollectionViewCell.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumCollectionViewCell.swift @@ -9,6 +9,7 @@ final class CustomAlbumCollectionViewCell: UICollectionViewCell { return imageView }() + var representedAssetIdentifier: String? // MARK: - Initialize override init(frame: CGRect) { diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift index 8f5f9237..1019fec6 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/View/CustomAlbumViewController.swift @@ -322,10 +322,13 @@ extension CustomAlbumViewController: UICollectionViewDataSource { cell.setPhoto(.photo) } else { guard let asset = viewModel.photoAsset?[indexPath.item - 1] else { return cell } + cell.representedAssetIdentifier = asset.localIdentifier let cellSize = cell.bounds.size Task { await LocalPhotoManager.shared.requestThumbnailImage(with: asset, cellSize: cellSize) { image in - cell.setPhoto(image) + if cell.representedAssetIdentifier == asset.localIdentifier { + cell.setPhoto(image) + } } } } From 502e5787a246ecdb806ee245acca02f767b97726 Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 5 Dec 2024 02:03:29 +0900 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=EC=82=AC=EC=A7=84=20=EB=91=90=20?= =?UTF-8?q?=EB=B2=88=20=EB=B6=88=EB=9F=AC=EC=99=80=EC=A7=80=EB=8A=94=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/CustomAlbum/ViewModel/LocalPhotoManager.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift index 33afe90c..8b7c5f40 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/CustomAlbum/ViewModel/LocalPhotoManager.swift @@ -9,6 +9,7 @@ actor LocalPhotoManager { let options = PHImageRequestOptions() options.isSynchronous = true options.isNetworkAccessAllowed = true + options.deliveryMode = .highQualityFormat return options }() From 709f6e1a9a008d0b17bfede3d86da396a088ef87 Mon Sep 17 00:00:00 2001 From: k2645 Date: Thu, 5 Dec 2024 02:13:13 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=EC=B1=85=20=EC=BB=A4=EB=B2=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/BookCover/ViewModel/ModifyBookCoverViewModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/BookCover/ViewModel/ModifyBookCoverViewModel.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/BookCover/ViewModel/ModifyBookCoverViewModel.swift index a8c571d8..06b341ec 100644 --- a/MemorialHouse/MHPresentation/MHPresentation/Source/BookCover/ViewModel/ModifyBookCoverViewModel.swift +++ b/MemorialHouse/MHPresentation/MHPresentation/Source/BookCover/ViewModel/ModifyBookCoverViewModel.swift @@ -128,6 +128,7 @@ final class ModifyBookCoverViewModel: ViewModelType { return } let newBookCover = BookCover( + id: bookID, order: bookOrder, title: bookTitle, imageData: bookImageData,