From 0e42acc7cf66abe35f5c0a0098ad52617db2a13d Mon Sep 17 00:00:00 2001 From: kth1210 Date: Sun, 14 Jan 2024 11:36:55 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix=20#383:=20=EC=88=98=EC=A0=95=20->=20?= =?UTF-8?q?=EC=B7=A8=EC=86=8C=20=EC=8B=9C=20=EB=8B=A4=EC=8B=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=ED=99=94=EB=A9=B4=EC=9C=BC=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=ED=95=A0=20=EC=88=98=20=EC=97=86=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 화면 이동 시 isEdit을 초기화하는 코드 추가 --- .../TimelineDetailScene/VC/TimelineDetailVC.swift | 2 +- .../ViewModel/TimelineDetailViewModel.swift | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/VC/TimelineDetailVC.swift b/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/VC/TimelineDetailVC.swift index 15edcb0..990ddeb 100644 --- a/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/VC/TimelineDetailVC.swift +++ b/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/VC/TimelineDetailVC.swift @@ -235,7 +235,6 @@ private extension TimelineDetailVC { viewModel.state .map(\.isEdit) .filter { $0 } - .removeDuplicates() .withUnretained(self) .sink { owner, _ in let timelineDetailInfo = owner.viewModel.currentState.timelineDetailInfo @@ -246,6 +245,7 @@ private extension TimelineDetailVC { timelineDetailInfo: timelineDetailInfo ) owner.navigationController?.pushViewController(timelineEditVC, animated: true) + owner.viewModel.sendAction(.movedToEdit) } .store(in: &cancellables) diff --git a/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/ViewModel/TimelineDetailViewModel.swift b/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/ViewModel/TimelineDetailViewModel.swift index 9f1902f..13ce77d 100644 --- a/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/ViewModel/TimelineDetailViewModel.swift +++ b/iOS/traveline/Sources/Feature/TimelineDetailFeature/TimelineDetailScene/ViewModel/TimelineDetailViewModel.swift @@ -14,6 +14,7 @@ enum TimelineDetailAction: BaseAction { case editTimeline case deleteTimeline case translateTimeline + case movedToEdit } enum TimelineDetailSideEffect: BaseSideEffect { @@ -34,6 +35,7 @@ enum TimelineDetailSideEffect: BaseSideEffect { case popToTimeline(Bool) case showTimelineDetailEditing case loadTimelineTranslatedInfo(TimelineTranslatedInfo) + case resetIsEditStatus } struct TimelineDetailState: BaseState { @@ -68,6 +70,9 @@ final class TimelineDetailViewModel: BaseViewModel Date: Sun, 14 Jan 2024 12:18:08 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix=20#383:=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=9D=B4=EB=8F=99=20=EC=8B=9C=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80=20=EB=85=B8?= =?UTF-8?q?=EC=B6=9C=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SelectImageButton에서 hasImage 프로퍼티의 업데이트 타이밍과 updateView 함수 호출의 타이밍이 맞지 않아 발생한 문제였음 --- .../VC/TimelineWritingVC.swift | 2 +- .../View/SelectImageButton.swift | 23 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift index 8ee8ad6..a918176 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift @@ -165,7 +165,6 @@ final class TimelineWritingVC: UIViewController { @objc private func imageButtonCancelTapped() { selectImageButton.setImage(nil) viewModel.sendAction(.imageDidChange(nil)) - selectImageButton.updateView() } @objc private func locationButtonCancelTapped() { @@ -336,6 +335,7 @@ private extension TimelineWritingVC { viewModel.state .map(\.imageURLString) + .removeDuplicates() .withUnretained(self) .sink { owner, imageURLString in owner.selectImageButton.setImage(urlString: imageURLString) diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/View/SelectImageButton.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/View/SelectImageButton.swift index 5b44f1d..547ade5 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/View/SelectImageButton.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/View/SelectImageButton.swift @@ -21,7 +21,7 @@ final class SelectImageButton: UIView { // MARK: - UI Components - let view: UIView = { + private let view: UIView = { let view = UIView() view.layer.cornerRadius = Metric.cornerRadius view.clipsToBounds = true @@ -41,7 +41,7 @@ final class SelectImageButton: UIView { let imageView: UIImageView = .init() - let selectView: UIStackView = { + private let selectView: UIStackView = { let view = UIStackView() view.axis = .vertical view.alignment = .center @@ -51,26 +51,19 @@ final class SelectImageButton: UIView { return view }() - let selectViewIcon: UIImageView = { + private let selectViewIcon: UIImageView = { let view = UIImageView(image: TLImage.Common.album) view.contentMode = .scaleAspectFit return view }() - let selectViewLabel: TLLabel = { + private let selectViewLabel: TLLabel = { let label = TLLabel(font: TLFont.body2, color: TLColor.white) label.textAlignment = .center return label }() - // MARK: - Properties - - private var hasImage: Bool { - imageView.image != nil - } - let width = Metric.viewWidth + Metric.buttonOffset - // MARK: - initialize init() { @@ -86,7 +79,7 @@ final class SelectImageButton: UIView { // MARK: - Functions - func updateView() { + private func updateView(hasImage: Bool) { selectView.isHidden = hasImage imageView.isHidden = !hasImage cancelButton.isHidden = !hasImage @@ -94,12 +87,12 @@ final class SelectImageButton: UIView { func setImage(_ image: UIImage?) { imageView.image = image - updateView() + updateView(hasImage: image != nil) } func setImage(urlString: String?, imagePath: String? = nil) { imageView.setImage(from: urlString, imagePath: imagePath) - updateView() + updateView(hasImage: urlString != nil) } } @@ -111,7 +104,7 @@ private extension SelectImageButton { func setupAttributes() { selectViewLabel.setText(to: "선택") view.backgroundColor = TLColor.backgroundGray - updateView() + updateView(hasImage: false) } func setupLayout() { From f8503c22f34edd71813cccc3847a3210f01402d4 Mon Sep 17 00:00:00 2001 From: kth1210 Date: Sun, 14 Jan 2024 13:41:27 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix=20#383:=20=EC=A7=80=EC=86=8D=EC=A0=81?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EC=83=98=ED=94=8C=EB=A7=81=EC=9D=B4=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=A0=81=EC=9A=A9=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기존의 이미지인지 확인하는 state 프로퍼티 추가 --- .../TimelineWritingScene/VC/TimelineWritingVC.swift | 5 ++++- .../ViewModel/TimelineWritingViewModel.swift | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift index a918176..18049a3 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift @@ -465,7 +465,10 @@ extension TimelineWritingVC: LocationSearchDelegate { extension TimelineWritingVC: TLNavigationBarDelegate { func rightButtonDidTapped() { if let selectedImage = selectImageButton.imageView.image { - let image = selectedImage.downSampling() + var image: UIImage? = selectedImage + if !viewModel.currentState.isOriginImage { + image = image?.downSampling() + } let imageData = image?.jpegData(compressionQuality: 1) viewModel.sendAction(.tapCompleteButton(imageData)) } else { diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift index d8184db..039474a 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift @@ -55,6 +55,7 @@ enum TimelineWritingSideEffect: BaseSideEffect { } struct TimelineWritingState: BaseState { + var isOriginImage: Bool = false var isCompletable: Bool = false var timelineDetailRequest: TimelineDetailRequest = .empty var popToTimeline: Bool = false @@ -190,6 +191,7 @@ final class TimelineWritingViewModel: BaseViewModel Date: Sun, 14 Jan 2024 13:55:17 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix=20#383:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=96=88=EC=9D=84=20=EB=95=8C=20?= =?UTF-8?q?=EB=8B=A4=EC=9A=B4=EC=83=98=ED=94=8C=EB=A7=81=EC=9D=B4=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이미지가 변경되었음을 알리는 action 추가 --- .../TimelineWritingScene/VC/TimelineWritingVC.swift | 10 +++++++--- .../ViewModel/TimelineWritingViewModel.swift | 12 ++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift index 18049a3..eb359fb 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift @@ -163,8 +163,7 @@ final class TimelineWritingVC: UIViewController { } @objc private func imageButtonCancelTapped() { - selectImageButton.setImage(nil) - viewModel.sendAction(.imageDidChange(nil)) + changeImage(to: nil) } @objc private func locationButtonCancelTapped() { @@ -172,6 +171,11 @@ final class TimelineWritingVC: UIViewController { viewModel.sendAction(.placeDidChange(.emtpy)) } + private func changeImage(to image: UIImage?) { + selectImageButton.setImage(image) + viewModel.sendAction(.imageDidChange) + } + private func actionKeyboardWillShow(_ keyboardFrame: CGRect) { self.scrollView.contentInset.bottom = keyboardFrame.size.height scrollView.scrollRectToVisible(textView.frame, animated: true) @@ -439,7 +443,7 @@ extension TimelineWritingVC: PHPickerViewControllerDelegate { guard let self = self else { return } DispatchQueue.main.async { guard let selectedImage = image as? UIImage else { return } - self.selectImageButton.setImage(selectedImage) + self.changeImage(to: selectedImage) } } diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift index 039474a..b15661a 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift @@ -17,7 +17,7 @@ enum TimelineWritingAction: BaseAction { case metaDataTime(String) case searchPlace(String) case placeDidChange(TimelinePlace) - case imageDidChange(Data?) + case imageDidChange case placeDidScrollToBottom case tapCompleteButton(Data?) case configTimelineDetailInfo(TimelineDetailInfo) @@ -43,7 +43,7 @@ enum TimelineWritingSideEffect: BaseSideEffect { case updateTitleState(String) case updateContentState(String) case updateTimeState(String) - case updateImageState(Data?) + case updateImageState case updatePlaceState(TimelinePlace) case updatePlaceKeyword(String) case fetchPlaceList(TimelinePlaceList) @@ -114,8 +114,8 @@ final class TimelineWritingViewModel: BaseViewModel Date: Sun, 14 Jan 2024 14:17:46 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix=20#383:=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EB=A7=8C=20=EB=B3=80=EA=B2=BD=EB=90=90=EC=9D=84=20=EC=8B=9C=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=EB=B2=84=ED=8A=BC=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94=20=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=ED=98=84?= =?UTF-8?q?=EC=83=81=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/TimelineWritingViewModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift index b15661a..35815dc 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/ViewModel/TimelineWritingViewModel.swift @@ -188,6 +188,7 @@ final class TimelineWritingViewModel: BaseViewModel Date: Tue, 16 Jan 2024 01:14:01 +0900 Subject: [PATCH 6/6] =?UTF-8?q?chore=20#383:=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20-=20=EC=82=BC=ED=95=AD=20=EC=97=B0?= =?UTF-8?q?=EC=82=B0=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TimelineWritingScene/VC/TimelineWritingVC.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift index eb359fb..0d56b06 100644 --- a/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift +++ b/iOS/traveline/Sources/Feature/TimelineFeature/TimelineWritingScene/VC/TimelineWritingVC.swift @@ -469,10 +469,7 @@ extension TimelineWritingVC: LocationSearchDelegate { extension TimelineWritingVC: TLNavigationBarDelegate { func rightButtonDidTapped() { if let selectedImage = selectImageButton.imageView.image { - var image: UIImage? = selectedImage - if !viewModel.currentState.isOriginImage { - image = image?.downSampling() - } + let image = viewModel.currentState.isOriginImage ? selectedImage : selectedImage.downSampling() let imageData = image?.jpegData(compressionQuality: 1) viewModel.sendAction(.tapCompleteButton(imageData)) } else {