From 0b7ac0b0a0ba00ef8716170ae0c0a1a286e1e3c2 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Fri, 30 Dec 2022 20:07:31 +0900 Subject: [PATCH 01/23] =?UTF-8?q?=20-=20=EB=AC=B8=EA=B5=AC=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 4 ++-- Archive/Flows/MainFlow.swift | 4 ++-- Archive/Info.plist | 2 +- Archive/Info_debug.plist | 2 +- .../Sub/LoginInformation/LoginInformationViewController.swift | 2 +- .../Main/MyPage/Sub/Withdrawal/WithdrawalViewController.swift | 2 +- Archive/Main/Regist/RegistViewController.swift | 2 +- .../SubViewController/RegistEmotionSelectViewController.swift | 2 +- Archive/Manager/ArchiveError.swift | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index e1126e4..49238c0 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -2078,7 +2078,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 34; + CURRENT_PROJECT_VERSION = 35; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -2158,7 +2158,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 34; + CURRENT_PROJECT_VERSION = 35; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; diff --git a/Archive/Flows/MainFlow.swift b/Archive/Flows/MainFlow.swift index ec57847..1659026 100644 --- a/Archive/Flows/MainFlow.swift +++ b/Archive/Flows/MainFlow.swift @@ -56,7 +56,7 @@ final class MainFlow: Flow { let homeViewController = UIStoryboard(name: "Home", bundle: nil).instantiateViewController(identifier: HomeViewController.identifier) { coder in return HomeViewController(coder: coder, reactor: homeReactor) } - homeViewController.tabBarItem = UITabBarItem(title: "나의 티켓", image: Gen.Images.homeOff.image, selectedImage: Gen.Images.homeOn.image) + homeViewController.tabBarItem = UITabBarItem(title: "나의 관람", image: Gen.Images.homeOff.image, selectedImage: Gen.Images.homeOn.image) let dummyRecordViewController = DummyRecordViewController() dummyRecordViewController.tabBarItem = UITabBarItem(title: "전시 기록", image: Gen.Images.addArchvieOff.image, selectedImage: Gen.Images.addArchvieOn.image) @@ -74,7 +74,7 @@ final class MainFlow: Flow { myLikeRepository: MyLikeRepositoryImplement(), detailRepository: DetailRepositoryImplement()) let myPageViewController = MyPageViewController(reactor: myPageReactor) - myPageViewController.tabBarItem = UITabBarItem(title: "내 정보", image: Gen.Images.myPageOff.image, selectedImage: Gen.Images.myPageOn.image) + myPageViewController.tabBarItem = UITabBarItem(title: "나의 정보", image: Gen.Images.myPageOff.image, selectedImage: Gen.Images.myPageOn.image) return TabViewControllers(homeViewController: homeViewController, homeStepper: homeReactor, diff --git a/Archive/Info.plist b/Archive/Info.plist index dab3307..70b24d0 100644 --- a/Archive/Info.plist +++ b/Archive/Info.plist @@ -48,7 +48,7 @@ NSPhotoLibraryUsageDescription - 티켓 기록 사진을 선택할 때 Archive가 사진 라이브러리를 사용합니다. + 전시 기록 사진을 선택할 때 Archive가 사진 라이브러리를 사용합니다. UIAppFonts Pretendard-Bold.ttf diff --git a/Archive/Info_debug.plist b/Archive/Info_debug.plist index d99c103..179aa79 100644 --- a/Archive/Info_debug.plist +++ b/Archive/Info_debug.plist @@ -32,7 +32,7 @@ NSPhotoLibraryUsageDescription - 티켓 기록 사진을 선택할 때 Archive가 사진 라이브러리를 사용합니다. + 전시 기록 사진을 선택할 때 Archive가 사진 라이브러리를 사용합니다. UIAppFonts Pretendard-Bold.ttf diff --git a/Archive/Main/MyPage/Sub/LoginInformation/LoginInformationViewController.swift b/Archive/Main/MyPage/Sub/LoginInformation/LoginInformationViewController.swift index 227221e..6db183d 100644 --- a/Archive/Main/MyPage/Sub/LoginInformation/LoginInformationViewController.swift +++ b/Archive/Main/MyPage/Sub/LoginInformation/LoginInformationViewController.swift @@ -102,7 +102,7 @@ class LoginInformationViewController: UIViewController, StoryboardView, Activity self.logoutBtn.rx.tap .asDriver() .drive(onNext: { - CommonAlertView.shared.show(message: "로그아웃 하시겠어요?", subMessage: "로그인을 한 상태에서만\n나의 티켓들을 볼 수 있어요.", confirmBtnTxt: "로그아웃", cancelBtnTxt: "취소", confirmHandler: { + CommonAlertView.shared.show(message: "로그아웃 하시겠어요?", subMessage: "로그인을 한 상태에서만\n나의 전시들을 볼 수 있어요.", confirmBtnTxt: "로그아웃", cancelBtnTxt: "취소", confirmHandler: { CommonAlertView.shared.hide(nil) reactor.action.onNext(.logout) }, cancelHandler: { diff --git a/Archive/Main/MyPage/Sub/Withdrawal/WithdrawalViewController.swift b/Archive/Main/MyPage/Sub/Withdrawal/WithdrawalViewController.swift index 3f31303..aa1bdd8 100644 --- a/Archive/Main/MyPage/Sub/Withdrawal/WithdrawalViewController.swift +++ b/Archive/Main/MyPage/Sub/Withdrawal/WithdrawalViewController.swift @@ -98,7 +98,7 @@ class WithdrawalViewController: UIViewController, StoryboardView, ActivityIndica self.mainContainerView.backgroundColor = .clear self.mainTitleLabel.font = .fonts(.header3) self.mainTitleLabel.textColor = Gen.Colors.gray01.color - self.mainTitleLabel.text = "아카이브를 삭제하면?" + self.mainTitleLabel.text = "아카이브를 탈퇴하면?" self.withdrawalBtn.layer.cornerRadius = 8 self.withdrawalBtn.layer.borderWidth = 1 diff --git a/Archive/Main/Regist/RegistViewController.swift b/Archive/Main/Regist/RegistViewController.swift index 7f5a5a8..8f1d782 100644 --- a/Archive/Main/Regist/RegistViewController.swift +++ b/Archive/Main/Regist/RegistViewController.swift @@ -458,7 +458,7 @@ class RegistViewController: UIViewController, View { reactor.moveToConfig .asDriver(onErrorJustReturn: ()) .drive(onNext: { [weak self] in - CommonAlertView.shared.show(message: "티켓 기록 사진을 선택하려면 사진 라이브러리 접근권한이 필요합니다.", subMessage: nil, btnText: "확인", hapticType: .warning, confirmHandler: { + CommonAlertView.shared.show(message: "전시 기록 사진을 선택하려면 사진 라이브러리 접근권한이 필요합니다.", subMessage: nil, btnText: "확인", hapticType: .warning, confirmHandler: { Util.moveToSetting() CommonAlertView.shared.hide(nil) }) diff --git a/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift b/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift index 9ba53c6..ec2dd11 100644 --- a/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift +++ b/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift @@ -42,7 +42,7 @@ class RegistEmotionSelectViewController: UIViewController { private let bottomViewSubtitleLabel = UILabel().then { $0.font = .fonts(.body) $0.textColor = Gen.Colors.gray02.color - $0.text = "선택한 감정으로 티켓커버가 변경됩니다." + $0.text = "선택한 감정으로 전시커버가 변경됩니다." } private let confirmBtn = UIButton().then { diff --git a/Archive/Manager/ArchiveError.swift b/Archive/Manager/ArchiveError.swift index 9157e9e..eb3e98c 100644 --- a/Archive/Manager/ArchiveError.swift +++ b/Archive/Manager/ArchiveError.swift @@ -110,7 +110,7 @@ class ArchiveError: Error { case .publicArchiveIsEndOfPage: returnValue = "더 이상 공개된 카드가 없어요 😭" case .photoAuth: - returnValue = "티켓 기록 사진을 선택하려면 사진 라이브러리 접근권한이 필요합니다." + returnValue = "전시 기록 사진을 선택하려면 사진 라이브러리 접근권한이 필요합니다." case .imageUploadCntFail: returnValue = "이미지 업로드 오류" case .imageUploadFail: From 7898a5422bcabafc60373dce03b925b651d55e20 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Fri, 6 Jan 2023 17:49:22 +0900 Subject: [PATCH 02/23] =?UTF-8?q?=EC=95=84=EC=B9=B4=EC=9D=B4=EB=B8=8C=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=EC=8B=9C=20=EC=BB=A4=EB=B2=84=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=97=AC=EB=B6=80=20=EC=8A=A4=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Main/Regist/RegistViewController.swift | 4 +- .../RegistEmotionSelectViewController.swift | 55 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/Archive/Main/Regist/RegistViewController.swift b/Archive/Main/Regist/RegistViewController.swift index 8f1d782..bd05fd7 100644 --- a/Archive/Main/Regist/RegistViewController.swift +++ b/Archive/Main/Regist/RegistViewController.swift @@ -250,8 +250,10 @@ class RegistViewController: UIViewController, View { .asDriver(onErrorJustReturn: ()) .drive(onNext: { [weak self] in GAModule.sendEventLogToGA(.startEmotionSelect) + let navi = UINavigationController(rootViewController: self?.emotionSelectViewController ?? UIViewController()) + navi.modalPresentationStyle = .overFullScreen self?.navigationController? - .present(self?.emotionSelectViewController ?? UIViewController(), + .present(navi, animated: false, completion: { [weak self] in self?.foregroundContentsView.isHidden = true diff --git a/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift b/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift index ec2dd11..23c21bc 100644 --- a/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift +++ b/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift @@ -15,6 +15,7 @@ import CropViewController @objc protocol RegistEmotionSelectViewControllerDelegate: AnyObject { @objc optional func selectedEmotion(emotion: Emotion) + @objc optional func isUsingCover(_ isUseing: Bool) } class RegistEmotionSelectViewController: UIViewController { @@ -72,6 +73,22 @@ class RegistEmotionSelectViewController: UIViewController { $0.numberOfLines = 2 } + private let coverIsUseSwitchContainerView = UIView().then { + $0.backgroundColor = .clear + } + + private lazy var coverIsUseSwitch = UISwitch().then { + $0.tintColor = Gen.Colors.gray04.color + $0.onTintColor = Gen.Colors.black.color + $0.isOn = true + } + + private let coverIsUseSwitchLabel = UILabel().then { + $0.font = .fonts(.subTitle) + $0.textColor = Gen.Colors.white.color + $0.text = "감정 커버를 사용할래요" + } + // MARK: private property // MARK: internal property @@ -122,6 +139,18 @@ class RegistEmotionSelectViewController: UIViewController { self?.dismiss(animated: false) }) .disposed(by: self.disposeBag) + + self.coverIsUseSwitch.rx.isOn + .asDriver() + .drive(onNext: { [weak self] isOn in + if isOn { + self?.emotionSampleImageView.alpha = 1 + } else { + self?.emotionSampleImageView.alpha = 0 + } + self?.delegate?.isUsingCover?(isOn) + }) + .disposed(by: self.disposeBag) } override func loadView() { @@ -197,6 +226,25 @@ class RegistEmotionSelectViewController: UIViewController { $0.leading.equalTo(self.helpEmotionImageContainerView.snp.leading) $0.trailing.equalTo(self.helpEmotionImageContainerView.snp.trailing) } + + self.mainContentsView.addSubview(self.coverIsUseSwitchContainerView) + self.coverIsUseSwitchContainerView.snp.makeConstraints { + $0.top.equalTo(self.mainContentsView).offset(20) + $0.centerX.equalTo(self.mainContentsView) + } + + self.coverIsUseSwitchContainerView.addSubview(self.coverIsUseSwitch) + self.coverIsUseSwitch.snp.makeConstraints { + $0.trailing.top.bottom.equalTo(self.coverIsUseSwitchContainerView) + } + + self.coverIsUseSwitchContainerView.addSubview(self.coverIsUseSwitchLabel) + self.coverIsUseSwitchLabel.snp.makeConstraints { + $0.leading.equalTo(self.coverIsUseSwitchContainerView) + $0.trailing.equalTo(self.coverIsUseSwitch.snp.leading).offset(-10) + $0.centerY.equalTo(self.coverIsUseSwitch) + } + } // MARK: private function @@ -243,4 +291,11 @@ extension Reactive where Base: RegistEmotionSelectViewController { return Emotion.getEmotionFromIndex(emotionRawValue) ?? .pleasant } } + + var switchIsUsingCover: Observable { + return delegate.methodInvoked(#selector(RegistEmotionSelectViewControllerDelegate.isUsingCover(_:))) + .map { result in + return result[0] as? Bool ?? true + } + } } From 095064a54a4c6c37401544da6ddbe8900cd74ae0 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Fri, 6 Jan 2023 20:08:21 +0900 Subject: [PATCH 03/23] =?UTF-8?q?=EC=82=AC=EC=A7=84=EB=93=B1=EB=A1=9D=20st?= =?UTF-8?q?ep2=ED=99=94=EB=A9=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Main/Regist/RegistReactor.swift | 7 +++ .../Main/Regist/RegistViewController.swift | 7 +++ .../SubView/ForegroundStep2TopView.swift | 50 ++++++++++++++++--- .../RegistImageAddCollectionViewCell.swift | 4 +- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Archive/Main/Regist/RegistReactor.swift b/Archive/Main/Regist/RegistReactor.swift index a639856..6ce85c6 100644 --- a/Archive/Main/Regist/RegistReactor.swift +++ b/Archive/Main/Regist/RegistReactor.swift @@ -42,6 +42,7 @@ class RegistReactor: Reactor, Stepper { case regist case registIsComplete case setOriginPhotoInfo([PHAsset: PhotoFromAlbumModel]) + case setIsUsingCover(Bool) } enum Mutation { @@ -58,6 +59,7 @@ class RegistReactor: Reactor, Stepper { case clearPhotoContents case setIsForegroundViewConfirmIsEnable(Bool) case setOriginPhotoInfo([PHAsset: PhotoFromAlbumModel]) + case setIsUsingCover(Bool) } struct State { @@ -72,6 +74,7 @@ class RegistReactor: Reactor, Stepper { var photoContents: [Int: String] = [:] var isForegroundViewConfirmIsEnable: Bool = false var originPhotoInfo: [PHAsset: PhotoFromAlbumModel] = [:] + var isCoverUsing: Bool = true } // MARK: life cycle @@ -210,6 +213,8 @@ class RegistReactor: Reactor, Stepper { return .empty() case .setOriginPhotoInfo(let info): return .just(.setOriginPhotoInfo(info)) + case .setIsUsingCover(let isUsing): + return .just(.setIsUsingCover(isUsing)) } } @@ -242,6 +247,8 @@ class RegistReactor: Reactor, Stepper { newState.isForegroundViewConfirmIsEnable = isEnable case .setOriginPhotoInfo(let info): newState.originPhotoInfo = info + case .setIsUsingCover(let isUsing): + newState.isCoverUsing = isUsing } return newState } diff --git a/Archive/Main/Regist/RegistViewController.swift b/Archive/Main/Regist/RegistViewController.swift index bd05fd7..c3f47a4 100644 --- a/Archive/Main/Regist/RegistViewController.swift +++ b/Archive/Main/Regist/RegistViewController.swift @@ -275,6 +275,13 @@ class RegistViewController: UIViewController, View { }) .disposed(by: self.disposeBag) + self.emotionSelectViewController.rx.switchIsUsingCover + .asDriver(onErrorJustReturn: true) + .drive(onNext: { [weak self] isOn in + reactor.action.onNext(.setIsUsingCover(isOn)) + }) + .disposed(by: self.disposeBag) + self.foregroundStep2TopView.rx.selectImage .observe(on: ConcurrentDispatchQueueScheduler(queue: .global())) .subscribe(onNext: { diff --git a/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift b/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift index c4f5a08..6988107 100644 --- a/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift +++ b/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift @@ -61,10 +61,18 @@ class ForegroundStep2TopView: UIView { // MARK: private UI property - private let mainContentsView = UIView().then { + private let backgroundColorView = UIView().then { $0.backgroundColor = Gen.Colors.gray05.color } + private let emotionColorView = UIView().then { + $0.backgroundColor = .clear + } + + private let mainContentsView = UIView().then { + $0.backgroundColor = .clear + } + private let emotionCoverView = UIImageView().then { $0.image = Emotion.pleasant.coverAlphaImage } @@ -88,6 +96,7 @@ class ForegroundStep2TopView: UIView { private let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: UICollectionViewLayout()).then { $0.isPagingEnabled = true + $0.backgroundColor = .clear let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing = 0 @@ -185,16 +194,26 @@ class ForegroundStep2TopView: UIView { private func setup() { self.backgroundColor = .clear + self.addSubview(self.backgroundColorView) + self.backgroundColorView.snp.makeConstraints { + $0.edges.equalTo(self) + } + + self.addSubview(self.emotionColorView) + self.emotionColorView.snp.makeConstraints { + $0.edges.equalTo(self) + } + self.addSubview(self.collectionView) self.collectionView.snp.makeConstraints { $0.edges.equalTo(self) } - + self.addSubview(self.mainContentsView) self.mainContentsView.snp.makeConstraints { $0.edges.equalTo(self) } - + self.mainContentsView.addSubview(self.emptyView) self.emptyView.snp.makeConstraints { $0.leading.equalTo(self.mainContentsView).offset(32) @@ -202,23 +221,23 @@ class ForegroundStep2TopView: UIView { $0.height.equalTo(UIScreen.main.bounds.width - 64) $0.bottom.equalTo(self.mainContentsView).offset(-75) } - + self.emptyView.addSubview(self.addIconImgView) self.addIconImgView.snp.makeConstraints { $0.width.height.equalTo(44) $0.center.equalTo(self.emptyView) } - + self.mainContentsView.addSubview(self.emotionCoverView) self.emotionCoverView.snp.makeConstraints { $0.edges.equalTo(self.emptyView) } - + self.emptyView.addSubview(self.btn) self.btn.snp.makeConstraints { $0.edges.equalTo(self.emptyView) } - + self.mainContentsView.addSubview(self.upIconImgView) self.upIconImgView.snp.makeConstraints { $0.width.height.equalTo(44) @@ -228,7 +247,7 @@ class ForegroundStep2TopView: UIView { } private func refreshEmotionUI(emotion: Emotion) { - self.mainContentsView.backgroundColor = emotion.color + self.emotionColorView.backgroundColor = emotion.color self.emotionCoverView.image = emotion.coverAlphaImage self.collectionView.reloadData() } @@ -249,6 +268,11 @@ class ForegroundStep2TopView: UIView { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: RegistImageAddCollectionViewCell.identifier, for: indexPath) as? RegistImageAddCollectionViewCell else { return UICollectionViewCell() } cell.topBarHeight = self.topBarHeight cell.delegate = self + if indexPath.item == 0 { + cell.mainContentsView.backgroundColor = .clear + } else { + cell.mainContentsView.backgroundColor = Gen.Colors.gray05.color + } return cell } @@ -306,6 +330,16 @@ class ForegroundStep2TopView: UIView { self?.willDisplayIndex = indexPath.item }) .disposed(by: self.disposeBag) + + self.reactor.state + .map { $0.isCoverUsing } + .distinctUntilChanged() + .asDriver(onErrorJustReturn: true) + .drive(onNext: { [weak self] isOn in + self?.emotionCoverView.isHidden = !isOn + self?.emotionColorView.isHidden = !isOn + }) + .disposed(by: self.disposeBag) } func hideEmptyView() { diff --git a/Archive/Main/Regist/SubView/RegistImageAddCollectionViewCell.swift b/Archive/Main/Regist/SubView/RegistImageAddCollectionViewCell.swift index 8e6e07c..e67a98a 100644 --- a/Archive/Main/Regist/SubView/RegistImageAddCollectionViewCell.swift +++ b/Archive/Main/Regist/SubView/RegistImageAddCollectionViewCell.swift @@ -17,8 +17,8 @@ class RegistImageAddCollectionViewCell: UICollectionViewCell, ClassIdentifiable // MARK: UI property - private let mainContentsView = UIView().then { - $0.backgroundColor = Gen.Colors.gray05.color + let mainContentsView = UIView().then { + $0.backgroundColor = .clear } private let addImageView = UIImageView().then { From 3682bfc2a2b8d28763b2b0d55391b652ac94c4b3 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Fri, 6 Jan 2023 20:21:48 +0900 Subject: [PATCH 04/23] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=ED=8E=B8?= =?UTF-8?q?=EC=A7=91=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Main/Regist/RegistViewController.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Archive/Main/Regist/RegistViewController.swift b/Archive/Main/Regist/RegistViewController.swift index c3f47a4..7b0c64f 100644 --- a/Archive/Main/Regist/RegistViewController.swift +++ b/Archive/Main/Regist/RegistViewController.swift @@ -499,10 +499,6 @@ class RegistViewController: UIViewController, View { cropViewController.doneButtonColor = Gen.Colors.white.color cropViewController.cancelButtonTitle = "취소" cropViewController.cancelButtonColor = Gen.Colors.white.color - cropViewController.aspectRatioLockEnabled = true - cropViewController.resetButtonHidden = true - cropViewController.customAspectRatio = CGSize(width: 300, height: 300) - cropViewController.aspectRatioPickerButtonHidden = true self.present(cropViewController, animated: true, completion: nil) } From f6d0dc3fa210cf19c2833869e71351b9f45b870e Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Fri, 6 Jan 2023 21:27:26 +0900 Subject: [PATCH 05/23] =?UTF-8?q?=EC=95=84=EC=B9=B4=EC=9D=B4=EB=B8=8C=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20Type2=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=ED=8E=B8=EC=A7=91=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 4 + Archive/Define/CommonDefine.swift | 5 ++ Archive/Main/Regist/RegistReactor.swift | 3 + .../Main/Regist/RegistViewController.swift | 3 +- .../SubView/ForegroundStep2TopView.swift | 24 +++++- ...mageCoverImageTypeCollectionViewCell.swift | 76 +++++++++++++++++++ .../RegistEmotionSelectViewController.swift | 1 - .../RegistPhotoReactor.swift | 5 +- .../RegistPhotoViewController.swift | 22 +++++- 9 files changed, 133 insertions(+), 10 deletions(-) create mode 100644 Archive/Main/Regist/SubView/RegistImageCoverImageTypeCollectionViewCell.swift diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index 49238c0..c0ba3fe 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -103,6 +103,7 @@ 783A61DF273BEB02004D848F /* InstagramStoryShareManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 783A61DE273BEB02004D848F /* InstagramStoryShareManager.swift */; }; 783A61E2273BEE9F004D848F /* TopConerRadiusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 783A61E1273BEE9F004D848F /* TopConerRadiusView.swift */; }; 783FD01B287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 783FD01A287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift */; }; + 784260132968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784260122968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift */; }; 78436F26287C77F800013982 /* CommunityFilterCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78436F25287C77F800013982 /* CommunityFilterCollectionViewCell.swift */; }; 7845765627E3809F00BE6863 /* GAModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7845765527E3809F00BE6863 /* GAModule.swift */; }; 78458D2A272C18BB00392B45 /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78458D29272C18BB00392B45 /* Util.swift */; }; @@ -367,6 +368,7 @@ 783A61DE273BEB02004D848F /* InstagramStoryShareManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstagramStoryShareManager.swift; sourceTree = ""; }; 783A61E1273BEE9F004D848F /* TopConerRadiusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopConerRadiusView.swift; sourceTree = ""; }; 783FD01A287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityFilterHeaderView.swift; sourceTree = ""; }; + 784260122968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistImageCoverImageTypeCollectionViewCell.swift; sourceTree = ""; }; 78436F25287C77F800013982 /* CommunityFilterCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityFilterCollectionViewCell.swift; sourceTree = ""; }; 7845765527E3809F00BE6863 /* GAModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GAModule.swift; sourceTree = ""; }; 78458D29272C18BB00392B45 /* Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = ""; }; @@ -1338,6 +1340,7 @@ 7824796328B09FE8003E71A2 /* RegistImageAddCollectionViewCell.swift */, 78D5F50328B1241D00C2B271 /* RegistContentsBottomView.swift */, 78027CEE28B4FC450096B400 /* RegistBehindView.swift */, + 784260122968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift */, ); path = SubView; sourceTree = ""; @@ -1895,6 +1898,7 @@ 7831D52427E5A5B200E3FA57 /* LoginOAuthRepositoryImplement.swift in Sources */, 44FB0A1727183C22006E1048 /* PasswordInputViewController.swift in Sources */, 783A61DF273BEB02004D848F /* InstagramStoryShareManager.swift in Sources */, + 784260132968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift in Sources */, 78A3217F275BBEB20078650D /* UIColorExtension.swift in Sources */, 7839E49B28DEDF3A00A80A1D /* NickNameDuplicationUsecase.swift in Sources */, 78D58B1828BB575200AF3191 /* UploadImageRepositoryImplement.swift in Sources */, diff --git a/Archive/Define/CommonDefine.swift b/Archive/Define/CommonDefine.swift index 483fc11..40d79fb 100644 --- a/Archive/Define/CommonDefine.swift +++ b/Archive/Define/CommonDefine.swift @@ -14,6 +14,11 @@ enum Direction { case bottom } +enum CoverType { + case cover + case image +} + class CommonDefine: NSObject { static let kakaoAppKey: String = "147a5c186ee0f5fdc58244b704165132" static let devApiServer: String = "https://archive-ticket.site/dev" // 개발 diff --git a/Archive/Main/Regist/RegistReactor.swift b/Archive/Main/Regist/RegistReactor.swift index 6ce85c6..df170c6 100644 --- a/Archive/Main/Regist/RegistReactor.swift +++ b/Archive/Main/Regist/RegistReactor.swift @@ -248,7 +248,10 @@ class RegistReactor: Reactor, Stepper { case .setOriginPhotoInfo(let info): newState.originPhotoInfo = info case .setIsUsingCover(let isUsing): + newState.originPhotoInfo = [:] newState.isCoverUsing = isUsing + newState.photoContents.removeAll() + newState.imageInfo = .init(images: [], isMoveFirstIndex: true) } return newState } diff --git a/Archive/Main/Regist/RegistViewController.swift b/Archive/Main/Regist/RegistViewController.swift index 7b0c64f..1bfe80b 100644 --- a/Archive/Main/Regist/RegistViewController.swift +++ b/Archive/Main/Regist/RegistViewController.swift @@ -295,7 +295,8 @@ class RegistViewController: UIViewController, View { GAModule.sendEventLogToGA(.startPhotoSelect) let vc = RegistPhotoViewController(reactor: RegistPhotoReactor( emotion: self?.reactor?.currentState.emotion ?? .pleasant, - originPhotoInfo: reactor.currentState.originPhotoInfo)) + originPhotoInfo: reactor.currentState.originPhotoInfo, + isUsingCover: reactor.currentState.isCoverUsing)) vc.delegate = self let navi = UINavigationController(rootViewController: vc) navi.modalPresentationStyle = .fullScreen diff --git a/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift b/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift index 6988107..41284f8 100644 --- a/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift +++ b/Archive/Main/Regist/SubView/ForegroundStep2TopView.swift @@ -141,10 +141,17 @@ class ForegroundStep2TopView: UIView { var cell: UICollectionViewCell? switch item.type { case .cover: - cell = self.makeCoverCell(emotion: self.emotion, - imageInfo: item.imageInfo ?? RegistImageInfo(image: UIImage(), color: .white), - from: collectionView, - indexPath: indexPath) + if self.reactor.currentState.isCoverUsing { + cell = self.makeCoverCell(emotion: self.emotion, + imageInfo: item.imageInfo ?? RegistImageInfo(image: UIImage(), color: .white), + from: collectionView, + indexPath: indexPath) + } else { + cell = self.makeCoverImageTypeCell(emotion: self.emotion, + imageInfo: item.imageInfo ?? RegistImageInfo(image: UIImage(), color: .white), + from: collectionView, + indexPath: indexPath) + } case .image: cell = self.makeCardCell(imageInfo: item.imageInfo ?? RegistImageInfo(image: UIImage(), color: .white), from: collectionView, @@ -182,6 +189,8 @@ class ForegroundStep2TopView: UIView { forCellWithReuseIdentifier: RegistImageAddCollectionViewCell.identifier) self.collectionView.register(RegistImageCoverCollectionViewCell.self, forCellWithReuseIdentifier: RegistImageCoverCollectionViewCell.identifier) + self.collectionView.register(RegistImageCoverImageTypeCollectionViewCell.self, + forCellWithReuseIdentifier: RegistImageCoverImageTypeCollectionViewCell.identifier) } @@ -283,6 +292,13 @@ class ForegroundStep2TopView: UIView { return cell } + private func makeCoverImageTypeCell(emotion: Emotion?, imageInfo: RegistImageInfo, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: RegistImageCoverImageTypeCollectionViewCell.identifier, for: indexPath) as? RegistImageCoverImageTypeCollectionViewCell else { return UICollectionViewCell() } + cell.emotion = emotion + cell.image = imageInfo.image + return cell + } + // MARK: func func bind() { diff --git a/Archive/Main/Regist/SubView/RegistImageCoverImageTypeCollectionViewCell.swift b/Archive/Main/Regist/SubView/RegistImageCoverImageTypeCollectionViewCell.swift new file mode 100644 index 0000000..3b59105 --- /dev/null +++ b/Archive/Main/Regist/SubView/RegistImageCoverImageTypeCollectionViewCell.swift @@ -0,0 +1,76 @@ +// +// RegistImageCoverImageTypeCollectionViewCell.swift +// Archive +// +// Created by hanwe on 2023/01/06. +// + +import UIKit +import SnapKit +import Then + +class RegistImageCoverImageTypeCollectionViewCell: UICollectionViewCell, ClassIdentifiable { + + // MARK: UI property + + private let mainContentsView = UIView().then { + $0.backgroundColor = Gen.Colors.white.color + } + + private let imageView = UIImageView().then { + $0.contentMode = .scaleAspectFill + } + + // MARK: private property + + // MARK: internal property + + var image: UIImage? { + didSet { + guard let image = image else { return } + DispatchQueue.main.async { [weak self] in + self?.imageView.image = image + } + } + } + + var emotion: Emotion? { + didSet { + guard let emotion = emotion else { return } + DispatchQueue.main.async { [weak self] in + self?.mainContentsView.backgroundColor = emotion.color + } + } + } + + // MARK: lifeCycle + + override init(frame: CGRect) { + super.init(frame: frame) + setup() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + } + + // MARK: private function + + private func setup() { + self.addSubview(self.mainContentsView) + self.mainContentsView.snp.makeConstraints { + $0.edges.equalTo(self) + } + + self.mainContentsView.addSubview(self.imageView) + self.imageView.snp.makeConstraints { + $0.edges.equalTo(self.mainContentsView) + } + } + + // MARK: internal function + + // MARK: action +} + diff --git a/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift b/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift index 23c21bc..0730a0d 100644 --- a/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift +++ b/Archive/Main/Regist/SubViewController/RegistEmotionSelectViewController.swift @@ -11,7 +11,6 @@ import RxSwift import RxCocoa import SnapKit import Then -import CropViewController @objc protocol RegistEmotionSelectViewControllerDelegate: AnyObject { @objc optional func selectedEmotion(emotion: Emotion) diff --git a/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoReactor.swift b/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoReactor.swift index ba0e5db..8ab0d7f 100644 --- a/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoReactor.swift +++ b/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoReactor.swift @@ -42,6 +42,7 @@ class RegistPhotoReactor: Reactor { } struct State { + let isUsingCover: Bool var thumbnailImage: UIImage? var imageInfos: [PHAsset: PhotoFromAlbumModel] = [PHAsset: PhotoFromAlbumModel]() var isLoading: Bool = false @@ -51,9 +52,9 @@ class RegistPhotoReactor: Reactor { // MARK: life cycle - init(emotion: Emotion, originPhotoInfo: [PHAsset: PhotoFromAlbumModel]) { + init(emotion: Emotion, originPhotoInfo: [PHAsset: PhotoFromAlbumModel], isUsingCover: Bool) { self.emotion = emotion - self.initialState = .init(originPhotoInfo: originPhotoInfo) + self.initialState = .init(isUsingCover: isUsingCover, originPhotoInfo: originPhotoInfo) } func mutate(action: Action) -> Observable { diff --git a/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoViewController.swift b/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoViewController.swift index 15adc28..b374b72 100644 --- a/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoViewController.swift +++ b/Archive/Main/Regist/SubViewController/RegistPhotoViewController/RegistPhotoViewController.swift @@ -95,7 +95,11 @@ class RegistPhotoViewController: UIViewController, View, ActivityIndicatorable { .asDriver(onErrorJustReturn: []) .drive(onNext: { [weak self] imageArr in if imageArr.count == 0 { return } - self?.showImageEditView(image: imageArr[0]) + if reactor.currentState.isUsingCover { + self?.showImageCoverTypeEditView(image: imageArr[0]) + } else { + self?.showImageImageTypeEditView(image: imageArr[0]) + } }) .disposed(by: self.disposeBag) @@ -199,7 +203,7 @@ class RegistPhotoViewController: UIViewController, View, ActivityIndicatorable { self.dismiss(animated: true, completion: nil) } - private func showImageEditView(image: UIImage) { + private func showImageCoverTypeEditView(image: UIImage) { let cropViewController: CropViewController = CropViewController(croppingStyle: .default, image: image) cropViewController.delegate = self cropViewController.doneButtonTitle = "확인" @@ -225,6 +229,20 @@ class RegistPhotoViewController: UIViewController, View, ActivityIndicatorable { self.present(cropViewController, animated: true, completion: nil) } + private func showImageImageTypeEditView(image: UIImage) { + let cropViewController: CropViewController = CropViewController(croppingStyle: .default, image: image) + cropViewController.delegate = self + cropViewController.doneButtonTitle = "확인" + cropViewController.doneButtonColor = Gen.Colors.white.color + cropViewController.cancelButtonTitle = "취소" + cropViewController.cancelButtonColor = Gen.Colors.white.color + cropViewController.aspectRatioLockEnabled = true + cropViewController.resetButtonHidden = true + cropViewController.customAspectRatio = CGSize(width: 300, height: 400) + cropViewController.aspectRatioPickerButtonHidden = true + self.present(cropViewController, animated: true, completion: nil) + } + // MARK: internal function } From 98b5aa7dbea81836997344599e20675bc5c63f15 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Sat, 7 Jan 2023 11:43:59 +0900 Subject: [PATCH 06/23] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B9=B4=EB=93=9C=20=EC=85=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 8 +- Archive/Main/Home/HomeViewController.swift | 2 + .../Main/Home/TicketCollectionViewCell.swift | 1 - .../Home/TicketCollectionViewCellModel.swift | 12 -- .../Main/Home/TicketImageContentView.swift | 4 + .../TicketImageTypeCollectionViewCell.swift | 145 ++++++++++++++++++ 6 files changed, 155 insertions(+), 17 deletions(-) delete mode 100644 Archive/Main/Home/TicketCollectionViewCellModel.swift create mode 100644 Archive/Main/Home/TicketImageTypeCollectionViewCell.swift diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index c0ba3fe..7a9e16f 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -104,6 +104,7 @@ 783A61E2273BEE9F004D848F /* TopConerRadiusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 783A61E1273BEE9F004D848F /* TopConerRadiusView.swift */; }; 783FD01B287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 783FD01A287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift */; }; 784260132968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784260122968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift */; }; + 7842601529684BC400A5B74E /* TicketImageTypeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7842601429684BC400A5B74E /* TicketImageTypeCollectionViewCell.swift */; }; 78436F26287C77F800013982 /* CommunityFilterCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78436F25287C77F800013982 /* CommunityFilterCollectionViewCell.swift */; }; 7845765627E3809F00BE6863 /* GAModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7845765527E3809F00BE6863 /* GAModule.swift */; }; 78458D2A272C18BB00392B45 /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78458D29272C18BB00392B45 /* Util.swift */; }; @@ -131,7 +132,6 @@ 78599DD8276375C2003FD959 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78599DD0276375C2003FD959 /* HomeViewController.swift */; }; 78599DD9276375C2003FD959 /* TicketDescriptionContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78599DD1276375C2003FD959 /* TicketDescriptionContentView.swift */; }; 78599DDA276375C2003FD959 /* HomeReactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78599DD2276375C2003FD959 /* HomeReactor.swift */; }; - 78599DDB276375C2003FD959 /* TicketCollectionViewCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78599DD3276375C2003FD959 /* TicketCollectionViewCellModel.swift */; }; 78599DEA27638221003FD959 /* HomeShimmerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78599DE927638221003FD959 /* HomeShimmerView.swift */; }; 78599DED27638241003FD959 /* HomeShimmerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 78599DEC27638241003FD959 /* HomeShimmerView.xib */; }; 785F5E43273018BC00ACC7BA /* UIImageViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 785F5E42273018BC00ACC7BA /* UIImageViewExtension.swift */; }; @@ -369,6 +369,7 @@ 783A61E1273BEE9F004D848F /* TopConerRadiusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopConerRadiusView.swift; sourceTree = ""; }; 783FD01A287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityFilterHeaderView.swift; sourceTree = ""; }; 784260122968483E00A5B74E /* RegistImageCoverImageTypeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistImageCoverImageTypeCollectionViewCell.swift; sourceTree = ""; }; + 7842601429684BC400A5B74E /* TicketImageTypeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TicketImageTypeCollectionViewCell.swift; sourceTree = ""; }; 78436F25287C77F800013982 /* CommunityFilterCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityFilterCollectionViewCell.swift; sourceTree = ""; }; 7845765527E3809F00BE6863 /* GAModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GAModule.swift; sourceTree = ""; }; 78458D29272C18BB00392B45 /* Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = ""; }; @@ -397,7 +398,6 @@ 78599DD0276375C2003FD959 /* HomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; 78599DD1276375C2003FD959 /* TicketDescriptionContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TicketDescriptionContentView.swift; sourceTree = ""; }; 78599DD2276375C2003FD959 /* HomeReactor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeReactor.swift; sourceTree = ""; }; - 78599DD3276375C2003FD959 /* TicketCollectionViewCellModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TicketCollectionViewCellModel.swift; sourceTree = ""; }; 78599DE927638221003FD959 /* HomeShimmerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeShimmerView.swift; sourceTree = ""; }; 78599DEC27638241003FD959 /* HomeShimmerView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HomeShimmerView.xib; sourceTree = ""; }; 785F5E42273018BC00ACC7BA /* UIImageViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageViewExtension.swift; sourceTree = ""; }; @@ -1052,7 +1052,7 @@ 78599DCC276375C2003FD959 /* TicketImageContentView.swift */, 78599DCD276375C2003FD959 /* TicketCollectionViewLayout.swift */, 78599DCE276375C2003FD959 /* TicketCollectionViewCell.swift */, - 78599DD3276375C2003FD959 /* TicketCollectionViewCellModel.swift */, + 7842601429684BC400A5B74E /* TicketImageTypeCollectionViewCell.swift */, 78599DD1276375C2003FD959 /* TicketDescriptionContentView.swift */, 78599DE927638221003FD959 /* HomeShimmerView.swift */, 78599DEC27638241003FD959 /* HomeShimmerView.xib */, @@ -1884,8 +1884,8 @@ 78B872E12726C6D1009EFB54 /* EmotionDefine.swift in Sources */, 78D10DF0294DD7EA00BD6156 /* ArchiveEditRepositoryImplement.swift in Sources */, 784FCDE9282FEE9E007683D2 /* LoginAccessTokenRepository.swift in Sources */, - 78599DDB276375C2003FD959 /* TicketCollectionViewCellModel.swift in Sources */, 7831D52227E5A5A300E3FA57 /* LoginOAuthRepository.swift in Sources */, + 7842601529684BC400A5B74E /* TicketImageTypeCollectionViewCell.swift in Sources */, 78D58B1B28BB59AD00AF3191 /* RegistUsecase.swift in Sources */, 78486D6C27E6C974008448A7 /* ErrorExtension.swift in Sources */, 783FD01B287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift in Sources */, diff --git a/Archive/Main/Home/HomeViewController.swift b/Archive/Main/Home/HomeViewController.swift index 85b5780..36afa19 100644 --- a/Archive/Main/Home/HomeViewController.swift +++ b/Archive/Main/Home/HomeViewController.swift @@ -66,6 +66,8 @@ final class HomeViewController: UIViewController, StoryboardView, ActivityIndica NotificationCenter.default.addObserver(self, selector: #selector(self.archiveIsAddedNotificationReceive(notification:)), name: Notification.Name(NotificationDefine.ARCHIVE_IS_ADDED), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.archiveIsDeletedNotificationReceive(notification:)), name: Notification.Name(NotificationDefine.ARCHIVE_IS_DELETED), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.archiveIsUpdatedNotificationReceive(notification:)), name: Notification.Name(NotificationDefine.ARCHIVE_STATE_IS_UPDATED), object: nil) + self.ticketCollectionView.register(TicketImageTypeCollectionViewCell.self, + forCellWithReuseIdentifier: TicketImageTypeCollectionViewCell.identifier) } override func viewWillAppear(_ animated: Bool) { diff --git a/Archive/Main/Home/TicketCollectionViewCell.swift b/Archive/Main/Home/TicketCollectionViewCell.swift index b645343..998ceca 100644 --- a/Archive/Main/Home/TicketCollectionViewCell.swift +++ b/Archive/Main/Home/TicketCollectionViewCell.swift @@ -26,7 +26,6 @@ final class TicketCollectionViewCell: UICollectionViewCell, ReuseIdentifiable { let imageView = UIImageView() return imageView }() - private lazy var coverImageView: UIImageView = { let imageView = UIImageView() diff --git a/Archive/Main/Home/TicketCollectionViewCellModel.swift b/Archive/Main/Home/TicketCollectionViewCellModel.swift deleted file mode 100644 index 7d16205..0000000 --- a/Archive/Main/Home/TicketCollectionViewCellModel.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// TicketCollectionViewCellModel.swift -// Archive -// -// Created by TTOzzi on 2021/11/13. -// - -import Foundation - -struct TicketCollectionViewCellModel { - -} diff --git a/Archive/Main/Home/TicketImageContentView.swift b/Archive/Main/Home/TicketImageContentView.swift index 335241d..13c23fe 100644 --- a/Archive/Main/Home/TicketImageContentView.swift +++ b/Archive/Main/Home/TicketImageContentView.swift @@ -10,6 +10,7 @@ import UIKit final class TicketImageContentView: UIView { var bgColor: UIColor? + var maskLayer: CAShapeLayer = CAShapeLayer() override init(frame: CGRect) { super.init(frame: frame) backgroundColor = .clear @@ -45,5 +46,8 @@ final class TicketImageContentView: UIView { self.bgColor?.set() path.fill() + + maskLayer.path = path.cgPath + self.layer.mask = maskLayer } } diff --git a/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift b/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift new file mode 100644 index 0000000..7b26dc3 --- /dev/null +++ b/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift @@ -0,0 +1,145 @@ +// +// TicketImageTypeCollectionViewCell.swift +// Archive +// +// Created by hanwe on 2023/01/06. +// + +import UIKit +import SnapKit +import Kingfisher +import Then + +final class TicketImageTypeCollectionViewCell: UICollectionViewCell, ReuseIdentifiable { + + private lazy var contentStackView: UIStackView = { + let stackView = UIStackView() + stackView.axis = .vertical + return stackView + }() + + private lazy var imageContentView: TicketImageContentView = { + let view = TicketImageContentView() + view.layer.masksToBounds = true + view.clipsToBounds = true + return view + }() + + private let mainImageContainerView = UIView().then { + $0.backgroundColor = .clear + } + + private lazy var mainImageView: UIImageView = { + let imageView = UIImageView() + return imageView + }() + + private lazy var descriptionView: TicketDescriptionContentView = { + let view = TicketDescriptionContentView() + return view + }() + + private lazy var emotionImageView: UIImageView = { + let imageView = UIImageView() + return imageView + }() + + private lazy var emotionTitleLabel: UILabel = { + let label: UILabel = UILabel() + label.font = .fonts(.subTitle) + label.textColor = Gen.Colors.white.color + return label + }() + + private lazy var lockImageView = UIImageView().then { + $0.backgroundColor = .clear + } + + var infoData: ArchiveInfo? { + didSet { + guard let info = self.infoData else { return } + DispatchQueue.main.async { [weak self] in + self?.imageContentView.bgColor = info.emotion.color + self?.emotionImageView.image = info.emotion.preImage + self?.emotionTitleLabel.text = info.emotion.localizationTitle + self?.imageContentView.setNeedsDisplay() + self?.mainImageView.kf.setImage(with: URL(string: info.mainImageUrl), + placeholder: nil, + options: [.cacheMemoryOnly], + completionHandler: nil) + self?.descriptionView.titleLabel.text = info.archiveName + self?.descriptionView.dateLabel.text = info.watchedOn + self?.descriptionView.setLikeCount(info.likeCount) + if info.isPublic { + self?.lockImageView.image = nil + } else { + self?.lockImageView.image = Gen.Images.lock.image + } + } + } + } + + override init(frame: CGRect) { + super.init(frame: frame) + setupAttributes() + setupLayouts() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setupAttributes() { + layer.backgroundColor = UIColor.clear.cgColor + layer.shadowColor = UIColor.black.cgColor + layer.shadowOffset = CGSize(width: 0, height: 2.0) + layer.shadowRadius = 10.0 + layer.shadowOpacity = 0.4 + layer.masksToBounds = false + } + + private func setupLayouts() { + contentView.addSubview(contentStackView) + contentStackView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + contentStackView.addArrangedSubview(imageContentView) + imageContentView.snp.makeConstraints { + $0.width.equalTo(imageContentView.snp.height).multipliedBy(0.75) + } + self.imageContentView.addSubview(self.mainImageContainerView) + self.mainImageContainerView.snp.makeConstraints { + $0.edges.equalTo(self.imageContentView) + } + mainImageContainerView.addSubview(mainImageView) + mainImageView.snp.makeConstraints { + $0.edges.equalTo(self) + } + contentStackView.addArrangedSubview(descriptionView) + descriptionView.snp.makeConstraints { + $0.height.equalTo(imageContentView.snp.height).multipliedBy(0.3) + } + descriptionView.setLayout() + + imageContentView.addSubview(emotionImageView) + emotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.top.equalTo(imageContentView.snp.top).offset(20) + $0.leading.equalTo(imageContentView.snp.leading).offset(20) + } + + imageContentView.addSubview(emotionTitleLabel) + emotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(emotionImageView.snp.centerY) + $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) + } + + imageContentView.addSubview(lockImageView) + lockImageView.snp.makeConstraints { + $0.top.equalTo(self.imageContentView).offset(20) + $0.trailing.equalTo(self.imageContentView).offset(-20) + $0.width.height.equalTo(24) + } + } +} From 75a610f2baa17d4449815a4c4be904605ec0d4aa Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Sat, 7 Jan 2023 11:56:52 +0900 Subject: [PATCH 07/23] =?UTF-8?q?=EC=83=88=EB=A1=9C=EC=9A=B4=20=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20=ED=83=80=EC=9E=85=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TicketImageTypeCollectionViewCell.swift | 24 +++++++++--- Archive/Resources/Assets.swift | 1 + .../WhiteOpacity70.colorset/Contents.json | 38 +++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 Archive/Resources/Assets/Colors.xcassets/WhiteOpacity70.colorset/Contents.json diff --git a/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift b/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift index 7b26dc3..09e23eb 100644 --- a/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift +++ b/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift @@ -39,6 +39,11 @@ final class TicketImageTypeCollectionViewCell: UICollectionViewCell, ReuseIdenti return view }() + private let emotionContainerView = UIView().then { + $0.layer.cornerRadius = 10 + $0.backgroundColor = Gen.Colors.whiteOpacity70.color + } + private lazy var emotionImageView: UIImageView = { let imageView = UIImageView() return imageView @@ -47,7 +52,7 @@ final class TicketImageTypeCollectionViewCell: UICollectionViewCell, ReuseIdenti private lazy var emotionTitleLabel: UILabel = { let label: UILabel = UILabel() label.font = .fonts(.subTitle) - label.textColor = Gen.Colors.white.color + label.textColor = Gen.Colors.black.color return label }() @@ -60,7 +65,7 @@ final class TicketImageTypeCollectionViewCell: UICollectionViewCell, ReuseIdenti guard let info = self.infoData else { return } DispatchQueue.main.async { [weak self] in self?.imageContentView.bgColor = info.emotion.color - self?.emotionImageView.image = info.emotion.preImage + self?.emotionImageView.image = info.emotion.typeImage self?.emotionTitleLabel.text = info.emotion.localizationTitle self?.imageContentView.setNeedsDisplay() self?.mainImageView.kf.setImage(with: URL(string: info.mainImageUrl), @@ -121,18 +126,25 @@ final class TicketImageTypeCollectionViewCell: UICollectionViewCell, ReuseIdenti } descriptionView.setLayout() - imageContentView.addSubview(emotionImageView) + imageContentView.addSubview(self.emotionContainerView) + self.emotionContainerView.snp.makeConstraints { + $0.top.leading.equalTo(self.imageContentView).offset(12) + } + + emotionContainerView.addSubview(emotionImageView) emotionImageView.snp.makeConstraints { $0.width.equalTo(24) $0.height.equalTo(24) - $0.top.equalTo(imageContentView.snp.top).offset(20) - $0.leading.equalTo(imageContentView.snp.leading).offset(20) + $0.leading.equalTo(self.emotionContainerView).offset(8) + $0.top.equalTo(self.emotionContainerView).offset(6) + $0.bottom.equalTo(self.emotionContainerView).offset(-6) } - imageContentView.addSubview(emotionTitleLabel) + emotionContainerView.addSubview(emotionTitleLabel) emotionTitleLabel.snp.makeConstraints { $0.centerY.equalTo(emotionImageView.snp.centerY) $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(emotionContainerView.snp.trailing).offset(-8) } imageContentView.addSubview(lockImageView) diff --git a/Archive/Resources/Assets.swift b/Archive/Resources/Assets.swift index 7626666..1d307d4 100644 --- a/Archive/Resources/Assets.swift +++ b/Archive/Resources/Assets.swift @@ -52,6 +52,7 @@ internal enum Gen { internal static let touchingOrangeDarken = ColorAsset(name: "TouchingOrangeDarken") internal static let white = ColorAsset(name: "White") internal static let whiteOpacity = ColorAsset(name: "WhiteOpacity") + internal static let whiteOpacity70 = ColorAsset(name: "WhiteOpacity70") internal static let wonderfulPurple = ColorAsset(name: "WonderfulPurple") internal static let wonderfulPurpleDarken = ColorAsset(name: "WonderfulPurpleDarken") } diff --git a/Archive/Resources/Assets/Colors.xcassets/WhiteOpacity70.colorset/Contents.json b/Archive/Resources/Assets/Colors.xcassets/WhiteOpacity70.colorset/Contents.json new file mode 100644 index 0000000..897681b --- /dev/null +++ b/Archive/Resources/Assets/Colors.xcassets/WhiteOpacity70.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.700", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.700", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} From 7fdf814be01e3189aa8b77d8f02a5316e36ea236 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Sat, 7 Jan 2023 15:14:52 +0900 Subject: [PATCH 08/23] =?UTF-8?q?=EB=A9=94=EC=9D=B8=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=97=90=20=ED=83=80=EC=9E=852=EC=85=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Define/CommonDefine.swift | 10 ++- .../Community/CommunityViewController.swift | 4 +- Archive/Main/Home/HomeViewController.swift | 66 +++++++++++++++++-- .../MyLikeList/MyLikeListViewController.swift | 4 +- .../MyArchive/MyArchiveRepository.swift | 15 +++++ 5 files changed, 88 insertions(+), 11 deletions(-) diff --git a/Archive/Define/CommonDefine.swift b/Archive/Define/CommonDefine.swift index 40d79fb..9bbda01 100644 --- a/Archive/Define/CommonDefine.swift +++ b/Archive/Define/CommonDefine.swift @@ -14,9 +14,17 @@ enum Direction { case bottom } -enum CoverType { +enum CoverType: String, Encodable, CaseIterable { case cover case image + + static func coverTypeFromRawValue(_ rawValue: String) -> CoverType? { + var returnValue: CoverType? + for item in CoverType.allCases where item.rawValue == rawValue { + returnValue = item + } + return returnValue + } } class CommonDefine: NSObject { diff --git a/Archive/Main/Community/CommunityViewController.swift b/Archive/Main/Community/CommunityViewController.swift index 1268c49..5ec2bc3 100644 --- a/Archive/Main/Community/CommunityViewController.swift +++ b/Archive/Main/Community/CommunityViewController.swift @@ -94,7 +94,7 @@ class CommunityViewController: UIViewController, View, ActivityIndicatorable, Ac let configuration = AnimationConfiguration(insertAnimation: .automatic, reloadAnimation: .automatic, deleteAnimation: .automatic) let ds = ArchiveSectionDataSource(animationConfiguration: configuration) { datasource, collectionView, indexPath, item in - var cell = self.makeArhiveCell(item, from: collectionView, indexPath: indexPath) + var cell = self.makeArchiveCell(item, from: collectionView, indexPath: indexPath) return cell } @@ -298,7 +298,7 @@ class CommunityViewController: UIViewController, View, ActivityIndicatorable, Ac // MARK: private func - private func makeArhiveCell(_ archive: PublicArchive, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + private func makeArchiveCell(_ archive: PublicArchive, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CommunityCollectionViewCell.identifier, for: indexPath) as? CommunityCollectionViewCell else { return UICollectionViewCell() } cell.infoData = archive cell.index = indexPath.item diff --git a/Archive/Main/Home/HomeViewController.swift b/Archive/Main/Home/HomeViewController.swift index 36afa19..a3988c2 100644 --- a/Archive/Main/Home/HomeViewController.swift +++ b/Archive/Main/Home/HomeViewController.swift @@ -11,6 +11,20 @@ import RxSwift import RxCocoa import RxDataSources +struct UserArchiveSection { + var items: [ArchiveInfo] + var identity: Int { + return 0 + } +} + +extension UserArchiveSection: AnimatableSectionModelType { + init(original: UserArchiveSection, items: [ArchiveInfo]) { + self = original + self.items = items + } +} + final class HomeViewController: UIViewController, StoryboardView, ActivityIndicatorable, FakeSplashViewProtocol { // MARK: IBOutlet @@ -42,6 +56,25 @@ final class HomeViewController: UIViewController, StoryboardView, ActivityIndica private let shimmerView: HomeShimmerView? = HomeShimmerView.instance() private var didScrollecDirection: Direction = .left + typealias ArchiveSectionDataSource = RxCollectionViewSectionedAnimatedDataSource + private lazy var dataSource: ArchiveSectionDataSource = { + let configuration = AnimationConfiguration(insertAnimation: .automatic, reloadAnimation: .automatic, deleteAnimation: .automatic) + + let ds = ArchiveSectionDataSource(animationConfiguration: configuration) { [weak self] datasource, collectionView, indexPath, item in + var cell: UICollectionViewCell = { + switch item.coverType { + case .cover: + return self?.makeArchiveCoverTypeCell(item, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() + case .image: + return self?.makeArchiveImageTypeCell(item, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() + } + }() + return cell + } + return ds + }() + private var sections = BehaviorRelay<[UserArchiveSection]>(value: []) + // MARK: internal property var disposeBag = DisposeBag() @@ -68,6 +101,7 @@ final class HomeViewController: UIViewController, StoryboardView, ActivityIndica NotificationCenter.default.addObserver(self, selector: #selector(self.archiveIsUpdatedNotificationReceive(notification:)), name: Notification.Name(NotificationDefine.ARCHIVE_STATE_IS_UPDATED), object: nil) self.ticketCollectionView.register(TicketImageTypeCollectionViewCell.self, forCellWithReuseIdentifier: TicketImageTypeCollectionViewCell.identifier) + setupDatasource() } override func viewWillAppear(_ animated: Bool) { @@ -92,12 +126,14 @@ final class HomeViewController: UIViewController, StoryboardView, ActivityIndica }) .disposed(by: self.disposeBag) - reactor.state.map { $0.archives } - .distinctUntilChanged() - .bind(to: self.ticketCollectionView.rx.items(cellIdentifier: TicketCollectionViewCell.identifier, cellType: TicketCollectionViewCell.self)) { index, element, cell in - cell.infoData = element - } - .disposed(by: self.disposeBag) + reactor.state + .map { $0.archives } + .distinctUntilChanged() + .asDriver(onErrorJustReturn: []) + .drive(onNext: { [weak self] archives in + self?.sections.accept([UserArchiveSection(items: archives)]) + }) + .disposed(by: self.disposeBag) reactor.state .map { $0.archives } @@ -301,6 +337,24 @@ final class HomeViewController: UIViewController, StoryboardView, ActivityIndica } } + private func makeArchiveCoverTypeCell(_ archive: ArchiveInfo, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TicketCollectionViewCell.identifier, for: indexPath) as? TicketCollectionViewCell else { return UICollectionViewCell() } + cell.infoData = archive + return cell + } + + private func makeArchiveImageTypeCell(_ archive: ArchiveInfo, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TicketImageTypeCollectionViewCell.identifier, for: indexPath) as? TicketImageTypeCollectionViewCell else { return UICollectionViewCell() } + cell.infoData = archive + return cell + } + + private func setupDatasource() { + self.ticketCollectionView.dataSource = nil + sections.bind(to: self.ticketCollectionView.rx.items(dataSource: self.dataSource)) + .disposed(by: self.disposeBag) + } + // MARK: internal function // MARK: action diff --git a/Archive/Main/MyPage/Sub/MyLikeList/MyLikeListViewController.swift b/Archive/Main/MyPage/Sub/MyLikeList/MyLikeListViewController.swift index 5d66ef0..5666d2e 100644 --- a/Archive/Main/MyPage/Sub/MyLikeList/MyLikeListViewController.swift +++ b/Archive/Main/MyPage/Sub/MyLikeList/MyLikeListViewController.swift @@ -81,7 +81,7 @@ class MyLikeListViewController: UIViewController, View, ActivityIndicatorable, A let configuration = AnimationConfiguration(insertAnimation: .automatic, reloadAnimation: .automatic, deleteAnimation: .automatic) let ds = ArchiveSectionDataSource(animationConfiguration: configuration) { [weak self] datasource, collectionView, indexPath, item in - guard let cell = self?.makeArhiveCell(item, from: collectionView, indexPath: indexPath) else { return UICollectionViewCell() } + guard let cell = self?.makeArchiveCell(item, from: collectionView, indexPath: indexPath) else { return UICollectionViewCell() } return cell } @@ -224,7 +224,7 @@ class MyLikeListViewController: UIViewController, View, ActivityIndicatorable, A // MARK: private func - private func makeArhiveCell(_ archive: PublicArchive, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + private func makeArchiveCell(_ archive: PublicArchive, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MyLikeCollectionViewCell.identifier, for: indexPath) as? MyLikeCollectionViewCell else { return UICollectionViewCell() } cell.infoData = archive cell.delegate = self diff --git a/Archive/Usecase/MyArchive/MyArchiveRepository.swift b/Archive/Usecase/MyArchive/MyArchiveRepository.swift index e8edb41..07366d6 100644 --- a/Archive/Usecase/MyArchive/MyArchiveRepository.swift +++ b/Archive/Usecase/MyArchive/MyArchiveRepository.swift @@ -6,6 +6,7 @@ // import RxSwift +import RxDataSources protocol MyArchiveRepository { func getArchives(sortBy: ArchiveSortType, emotion: Emotion?, lastSeenArchiveDateMilli: Int?, lastSeenArchiveId: Int?) -> Observable> @@ -32,6 +33,7 @@ struct ArchiveInfo: CodableWrapper { // let isLiked: Bool // let authorProfileImageUrl: String let likeCount: Int + let coverType: CoverType enum CodingKeys: String, CodingKey { @@ -48,6 +50,7 @@ struct ArchiveInfo: CodableWrapper { // case isLiked // case authorProfileImageUrl = "authorProfileImage" case likeCount + case coverType } init(from decoder: Decoder) throws { @@ -66,6 +69,18 @@ struct ArchiveInfo: CodableWrapper { // self.isLiked = try container.decode(Bool.self, forKey: .isLiked) // self.authorProfileImageUrl = try container.decode(String.self, forKey: .authorProfileImageUrl) self.likeCount = try container.decode(Int.self, forKey: .likeCount) + if let coverTypeRawValue = try? container.decode(String.self, forKey: .coverType) { + self.coverType = CoverType.coverTypeFromRawValue(coverTypeRawValue) ?? .cover + } else { + self.coverType = .cover + } + } } + +extension ArchiveInfo: IdentifiableType, Equatable { + typealias Identity = Int + + var identity: Identity { return self.archiveId } +} From dfad109697d8a5d99d3b5611d9be8832b43a13f7 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Sat, 7 Jan 2023 20:32:15 +0900 Subject: [PATCH 09/23] =?UTF-8?q?=EB=94=94=ED=85=8C=EC=9D=BC=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=EB=B3=B4=EA=B8=B0=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 8 + Archive/Define/CommonDefine.swift | 2 +- Archive/Detail/DetailViewController.swift | 17 +- ...etailCardImageTypeCollectionViewCell.swift | 141 ++++++++++ .../DetailCardImageTypeCollectionViewCell.xib | 240 ++++++++++++++++++ Archive/Usecase/Detail/DetailRepository.swift | 1 + 6 files changed, 407 insertions(+), 2 deletions(-) create mode 100644 Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift create mode 100644 Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.xib diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index 7a9e16f..878db58 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -202,6 +202,8 @@ 78BB7E232778938500DF78AF /* DetailContentsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BB7E212778938500DF78AF /* DetailContentsCollectionViewCell.swift */; }; 78BB7E272778970900DF78AF /* DetailFriendsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BB7E252778970900DF78AF /* DetailFriendsCollectionViewCell.swift */; }; 78BB7E282778970900DF78AF /* DetailFriendsCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 78BB7E262778970900DF78AF /* DetailFriendsCollectionViewCell.xib */; }; + 78BC9B1729698B6C00133F56 /* DetailCardImageTypeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BC9B1629698B6C00133F56 /* DetailCardImageTypeCollectionViewCell.swift */; }; + 78BC9B1929698C3400133F56 /* DetailCardImageTypeCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 78BC9B1829698C3400133F56 /* DetailCardImageTypeCollectionViewCell.xib */; }; 78C4B328272428AB0006EBAD /* MyPage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 78C4B327272428AB0006EBAD /* MyPage.storyboard */; }; 78C4B32B272428D40006EBAD /* WithdrawalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78C4B32A272428D40006EBAD /* WithdrawalViewController.swift */; }; 78C4B33527243C660006EBAD /* NSMutableAttributedStringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78C4B33427243C660006EBAD /* NSMutableAttributedStringExtension.swift */; }; @@ -463,6 +465,8 @@ 78BB7E212778938500DF78AF /* DetailContentsCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailContentsCollectionViewCell.swift; sourceTree = ""; }; 78BB7E252778970900DF78AF /* DetailFriendsCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailFriendsCollectionViewCell.swift; sourceTree = ""; }; 78BB7E262778970900DF78AF /* DetailFriendsCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DetailFriendsCollectionViewCell.xib; sourceTree = ""; }; + 78BC9B1629698B6C00133F56 /* DetailCardImageTypeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailCardImageTypeCollectionViewCell.swift; sourceTree = ""; }; + 78BC9B1829698C3400133F56 /* DetailCardImageTypeCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DetailCardImageTypeCollectionViewCell.xib; sourceTree = ""; }; 78C4B327272428AB0006EBAD /* MyPage.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MyPage.storyboard; sourceTree = ""; }; 78C4B32A272428D40006EBAD /* WithdrawalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WithdrawalViewController.swift; sourceTree = ""; }; 78C4B33427243C660006EBAD /* NSMutableAttributedStringExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSMutableAttributedStringExtension.swift; sourceTree = ""; }; @@ -1299,6 +1303,8 @@ 78BB7E24277896DD00DF78AF /* Sub */, 78BB7E112778563700DF78AF /* DetailCardCollectionViewCell.swift */, 78BB7E122778563700DF78AF /* DetailCardCollectionViewCell.xib */, + 78BC9B1629698B6C00133F56 /* DetailCardImageTypeCollectionViewCell.swift */, + 78BC9B1829698C3400133F56 /* DetailCardImageTypeCollectionViewCell.xib */, ); path = DetailCard; sourceTree = ""; @@ -1604,6 +1610,7 @@ 78599DD7276375C2003FD959 /* Home.storyboard in Resources */, 784ACCE528C6E5AE007EC7D5 /* Like.json in Resources */, 780389D3278956AF00DB1730 /* Splash.json in Resources */, + 78BC9B1929698C3400133F56 /* DetailCardImageTypeCollectionViewCell.xib in Resources */, 784D1DCA27083D88004B1A23 /* Images.xcassets in Resources */, 78BB7E142778563700DF78AF /* DetailCardCollectionViewCell.xib in Resources */, 78315E722764EC38001B3342 /* Upload.json in Resources */, @@ -1767,6 +1774,7 @@ 781C8433282F6378004A0FB3 /* MainTabBarViewController.swift in Sources */, 7839E4AC28DF26BC00A80A1D /* ProfileRepositoryImplement.swift in Sources */, 7830103E2882A2980031F8CB /* BannerRepositoryImplement.swift in Sources */, + 78BC9B1729698B6C00133F56 /* DetailCardImageTypeCollectionViewCell.swift in Sources */, 78D3EEC228716F9400409228 /* ArchiveProgressBar.swift in Sources */, 78599DD4276375C2003FD959 /* TicketImageContentView.swift in Sources */, 44FB09FB27183269006E1048 /* ArchiveStep.swift in Sources */, diff --git a/Archive/Define/CommonDefine.swift b/Archive/Define/CommonDefine.swift index 9bbda01..a12f718 100644 --- a/Archive/Define/CommonDefine.swift +++ b/Archive/Define/CommonDefine.swift @@ -14,7 +14,7 @@ enum Direction { case bottom } -enum CoverType: String, Encodable, CaseIterable { +enum CoverType: String, Codable, CaseIterable { case cover case image diff --git a/Archive/Detail/DetailViewController.swift b/Archive/Detail/DetailViewController.swift index 56e62af..58ca638 100644 --- a/Archive/Detail/DetailViewController.swift +++ b/Archive/Detail/DetailViewController.swift @@ -41,7 +41,14 @@ class DetailViewController: UIViewController, StoryboardView, ActivityIndicatora private lazy var dataSource = RxCollectionViewSectionedReloadDataSource>(configureCell: { [weak self] dataSource, collectionView, indexPath, item in switch item { case .cover(let infoData): - return self?.makeCardCell(with: infoData, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() + switch self?.reactor?.currentState.detailData.coverType { + case .cover: + return self?.makeCardCell(with: infoData, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() + case .image: + return self?.makeCardImageTypeCell(with: infoData, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() + case .none: + return self?.makeCardCell(with: infoData, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() + } case .commonImage(let imageInfo, let emotion, let name): return self?.makeImageCell(with: imageInfo, emotion: emotion, name: name, from: collectionView, indexPath: indexPath) ?? UICollectionViewCell() } @@ -201,6 +208,7 @@ class DetailViewController: UIViewController, StoryboardView, ActivityIndicatora self.collectionView.showsHorizontalScrollIndicator = false self.collectionView.register(UINib(nibName: DetailCardCollectionViewCell.identifier, bundle: nil), forCellWithReuseIdentifier: DetailCardCollectionViewCell.identifier) + self.collectionView.register(UINib(nibName: DetailCardImageTypeCollectionViewCell.identifier, bundle: nil), forCellWithReuseIdentifier: DetailCardImageTypeCollectionViewCell.identifier) self.collectionView.register(UINib(nibName: DetailContentsCollectionViewCell.identifier, bundle: nil), forCellWithReuseIdentifier: DetailContentsCollectionViewCell.identifier) self.pageControl.pageIndicatorTintColor = Gen.Colors.gray03.color @@ -219,6 +227,13 @@ class DetailViewController: UIViewController, StoryboardView, ActivityIndicatora return cell } + private func makeCardImageTypeCell(with element: ArchiveDetailInfo, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailCardImageTypeCollectionViewCell.identifier, for: indexPath) as? DetailCardImageTypeCollectionViewCell else { return UICollectionViewCell() } + cell.infoData = element + cell.topContainerViewHeightConstraint.constant = self.topbarHeight + return cell + } + private func makeImageCell(with element: ArchiveDetailImageInfo, emotion: Emotion, name: String, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailContentsCollectionViewCell.identifier, for: indexPath) as? DetailContentsCollectionViewCell else { return UICollectionViewCell() } cell.infoData = element diff --git a/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift b/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift new file mode 100644 index 0000000..0ecfce5 --- /dev/null +++ b/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift @@ -0,0 +1,141 @@ +// +// DetailCardImageTypeCollectionViewCell.swift +// Archive +// +// Created by hanwe on 2021/12/26. +// + +import UIKit +import Kingfisher + +class DetailCardImageTypeCollectionViewCell: UICollectionViewCell, ClassIdentifiable { + + // MARK: IBOutlet + @IBOutlet weak var mainBackgroundView: UIView! + @IBOutlet weak var scrollView: UIScrollView! + @IBOutlet weak var mainContetnsView: UIView! + + @IBOutlet weak var topContainerView: UIView! + @IBOutlet weak var topContainerViewHeightConstraint: NSLayoutConstraint! + + @IBOutlet weak var centerContainerView: UIView! + @IBOutlet weak var miniEmotionImageView: UIImageView! + @IBOutlet weak var emotionLabel: UILabel! + @IBOutlet weak var mainImageView: UIImageView! + + @IBOutlet weak var bottomContainerView: UIView! + @IBOutlet weak var eventNameLabel: UILabel! + @IBOutlet weak var eventDateLabel: UILabel! + + @IBOutlet weak var friendsCollectionView: UICollectionView! + + // MARK: private property + + // MARK: internal property + + var infoData: ArchiveDetailInfo? { + didSet { + guard let info = self.infoData else { return } + DispatchQueue.main.async { [weak self] in + self?.setNewEmotion(info.emotion) + self?.mainImageView.kf.setImage(with: URL(string: info.mainImage), + placeholder: nil, + options: [.cacheMemoryOnly], + completionHandler: { [weak self] _ in + self?.mainImageView.fadeIn(duration: 0.1, completeHandler: nil) + }) + self?.eventNameLabel.text = info.name + self?.eventDateLabel.text = info.watchedOn + } + } + } + + // MARK: lifeCycle + + override func awakeFromNib() { + super.awakeFromNib() + initUI() + ImageCache.default.clearCache() + } + + // MARK: private function + + private func initUI() { + self.scrollView.backgroundColor = .clear + self.mainContetnsView.backgroundColor = .clear + + self.topContainerView.backgroundColor = .clear + + self.centerContainerView.backgroundColor = .clear + + self.emotionLabel.font = .fonts(.subTitle) + self.emotionLabel.textColor = Gen.Colors.white.color + + self.bottomContainerView.backgroundColor = Gen.Colors.white.color + + self.eventNameLabel.font = .fonts(.header2) + self.eventNameLabel.textColor = Gen.Colors.black.color + + self.eventDateLabel.font = .fonts(.header3) + self.eventDateLabel.textColor = Gen.Colors.black.color + + self.friendsCollectionView.register(UINib(nibName: DetailFriendsCollectionViewCell.identifier, bundle: nil), forCellWithReuseIdentifier: DetailFriendsCollectionViewCell.identifier) + self.friendsCollectionView.showsHorizontalScrollIndicator = false + let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() + layout.scrollDirection = .horizontal + layout.sectionInset = UIEdgeInsets(top: 0, left: 9, bottom: 0, right: 0) + layout.minimumLineSpacing = 12 + self.friendsCollectionView.collectionViewLayout = layout + self.friendsCollectionView.dataSource = self + self.friendsCollectionView.delegate = self + self.friendsCollectionView.backgroundColor = .clear + + self.mainImageView.contentMode = .scaleAspectFill + + } + + private func setNewEmotion(_ emotion: Emotion) { + self.mainContetnsView.backgroundColor = Gen.Colors.gray05.color + self.emotionLabel.text = emotion.localizationTitle + self.miniEmotionImageView.image = emotion.preImage + } + + private func getFriendsCellWidth(_ text: String) -> CGFloat { + let fontAttributes = [NSAttributedString.Key.font: UIFont.fonts(.subTitle)] + return (text as NSString).size(withAttributes: fontAttributes).width + 25 + } + + // MARK: internal function + + // MARK: action + +} + +extension DetailCardImageTypeCollectionViewCell: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return self.infoData?.companions?.count ?? 0 + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell: DetailFriendsCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: DetailFriendsCollectionViewCell.identifier, for: indexPath) as? DetailFriendsCollectionViewCell else { + return UICollectionViewCell() + } + + if let title = self.infoData?.companions?[indexPath.item] { + cell.mainTitleLabel.text = title + } + + return cell + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + + var cellSize: CGSize = CGSize(width: 10, height: 10) + if let companions = self.infoData?.companions { + let text = companions[indexPath.item] + cellSize = CGSize(width: self.getFriendsCellWidth(text), height: 36) + } + + return cellSize + } +} diff --git a/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.xib b/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.xib new file mode 100644 index 0000000..9a124e0 --- /dev/null +++ b/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.xib @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Archive/Usecase/Detail/DetailRepository.swift b/Archive/Usecase/Detail/DetailRepository.swift index e61ad13..8bf6e37 100644 --- a/Archive/Usecase/Detail/DetailRepository.swift +++ b/Archive/Usecase/Detail/DetailRepository.swift @@ -24,6 +24,7 @@ struct ArchiveDetailInfo: CodableWrapper, Equatable { let images: [ArchiveDetailImageInfo]? let nickname: String let profileImage: String + let coverType: CoverType = .image } struct ArchiveDetailImageInfo: CodableWrapper { From 61fec894c527772b0e90a9e840694c48da61e617 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Tue, 17 Jan 2023 14:59:53 +0900 Subject: [PATCH 10/23] =?UTF-8?q?=EB=82=B4=20=EC=95=84=EC=B9=B4=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=20=EB=AA=A9=EB=A1=9D=20=EC=BB=A4=EB=B2=84=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Define/CommonDefine.swift | 4 ++-- Archive/Usecase/MyArchive/MyArchiveRepository.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Archive/Define/CommonDefine.swift b/Archive/Define/CommonDefine.swift index a12f718..f628f74 100644 --- a/Archive/Define/CommonDefine.swift +++ b/Archive/Define/CommonDefine.swift @@ -15,8 +15,8 @@ enum Direction { } enum CoverType: String, Codable, CaseIterable { - case cover - case image + case cover = "EMOTION_COVER" + case image = "NO_COVER" static func coverTypeFromRawValue(_ rawValue: String) -> CoverType? { var returnValue: CoverType? diff --git a/Archive/Usecase/MyArchive/MyArchiveRepository.swift b/Archive/Usecase/MyArchive/MyArchiveRepository.swift index 07366d6..c8d3517 100644 --- a/Archive/Usecase/MyArchive/MyArchiveRepository.swift +++ b/Archive/Usecase/MyArchive/MyArchiveRepository.swift @@ -50,7 +50,7 @@ struct ArchiveInfo: CodableWrapper { // case isLiked // case authorProfileImageUrl = "authorProfileImage" case likeCount - case coverType + case coverType = "coverImageType" } init(from decoder: Decoder) throws { From b64c7240b711b031008519c1642d2178be2fac38 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Tue, 17 Jan 2023 15:13:25 +0900 Subject: [PATCH 11/23] =?UTF-8?q?=20-=20=EC=95=84=EC=B9=B4=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=20=EB=93=B1=EB=A1=9D=EC=8B=9C=20=EC=BB=A4=EB=B2=84?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Main/Regist/RegistReactor.swift | 32 ++++++++++--------- .../RegistUsecase/RegistRepositoty.swift | 1 + .../Usecase/RegistUsecase/RegistUsecase.swift | 5 +-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Archive/Main/Regist/RegistReactor.swift b/Archive/Main/Regist/RegistReactor.swift index df170c6..5251bd0 100644 --- a/Archive/Main/Regist/RegistReactor.swift +++ b/Archive/Main/Regist/RegistReactor.swift @@ -170,22 +170,24 @@ class RegistReactor: Reactor, Stepper { err.onNext(.init(.archiveDataIsInvaild)) return .just(.empty) } - let registObservable = self.registUsecase.regist(name: name, - watchedOn: visitDate, - companions: friendsToFriendsArr(self.currentState.friends), - emotion: emotion.rawStringValue, - images: self.currentState.imageInfo.images, - imageContents: self.currentState.photoContents, - isPublic: self.currentState.isPublic) - .map { [weak self] result -> RegistReactor.Mutation in - switch result { - case .success(_): - break - case .failure(let err): - self?.err.onNext(err) - } - return .empty + let registObservable = self.registUsecase.regist( + name: name, + watchedOn: visitDate, + companions: friendsToFriendsArr(self.currentState.friends), + emotion: emotion.rawStringValue, + images: self.currentState.imageInfo.images, + imageContents: self.currentState.photoContents, + isPublic: self.currentState.isPublic, + coverType: self.currentState.isCoverUsing ? .cover : .image + ).map { [weak self] result -> RegistReactor.Mutation in + switch result { + case .success(_): + break + case .failure(let err): + self?.err.onNext(err) } + return .empty + } let getThisMonthRegistCountObservable = self.registUsecase.getThisMonthRegistCnt() .map { result -> Result in switch result { diff --git a/Archive/Usecase/RegistUsecase/RegistRepositoty.swift b/Archive/Usecase/RegistUsecase/RegistRepositoty.swift index d6f5571..a8392a9 100644 --- a/Archive/Usecase/RegistUsecase/RegistRepositoty.swift +++ b/Archive/Usecase/RegistUsecase/RegistRepositoty.swift @@ -28,6 +28,7 @@ struct RecordData: CodableWrapper { let mainImage: String let images: [RecordImageData]? let isPublic: Bool + let coverImageType: CoverType } diff --git a/Archive/Usecase/RegistUsecase/RegistUsecase.swift b/Archive/Usecase/RegistUsecase/RegistUsecase.swift index 332abb8..baa95b9 100644 --- a/Archive/Usecase/RegistUsecase/RegistUsecase.swift +++ b/Archive/Usecase/RegistUsecase/RegistUsecase.swift @@ -66,7 +66,7 @@ class RegistUsecase: NSObject { // MARK: internal function - func regist(name: String, watchedOn: String, companions: [String]?, emotion: String, images: [RegistImageInfo], imageContents: [Int: String], isPublic: Bool) -> Observable> { + func regist(name: String, watchedOn: String, companions: [String]?, emotion: String, images: [RegistImageInfo], imageContents: [Int: String], isPublic: Bool, coverType: CoverType) -> Observable> { return self.uploadImages(images) .map { result -> Result<[UploadImageInfo], ArchiveError> in switch result { @@ -101,7 +101,8 @@ class RegistUsecase: NSObject { emotion: emotion, mainImage: mainImage, images: recordImageDataArr, - isPublic: isPublic) + isPublic: isPublic, + coverImageType: coverType) return self?.repository.regist(info: recordData) ?? .just(.failure(.init(.selfIsNull))) case .failure(let err): return .just(.failure(err)) From ee7b86365db07619892eb0013c495085760204d8 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Tue, 17 Jan 2023 15:45:44 +0900 Subject: [PATCH 12/23] =?UTF-8?q?=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20?= =?UTF-8?q?=EC=BB=A4=EB=B2=84=ED=83=80=EC=9E=85=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Main/Community/CommunityReactor.swift | 4 +- .../CommunityDetailViewController.swift | 4 +- Archive/Usecase/Detail/DetailRepository.swift | 52 ++++++++++++++++++- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/Archive/Main/Community/CommunityReactor.swift b/Archive/Main/Community/CommunityReactor.swift index 8aff5ea..b280feb 100644 --- a/Archive/Main/Community/CommunityReactor.swift +++ b/Archive/Main/Community/CommunityReactor.swift @@ -85,7 +85,7 @@ class CommunityReactor: Reactor, Stepper, MainTabStepperProtocol { var isShimmerLoading: Bool = false var archives: Pulse<[PublicArchive]> = Pulse(wrappedValue: []) var detailArchive: DetailInfo = DetailInfo( - archiveInfo: .init(archiveId: 0, authorId: 0, name: "", watchedOn: "", emotion: .fun, companions: nil, mainImage: "", images: nil, nickname: "", profileImage: ""), + archiveInfo: .init(), innerIndex: 0, index: 0) var archiveTimeSortBy: ArchiveSortType = .sortByRegist @@ -273,7 +273,7 @@ class CommunityReactor: Reactor, Stepper, MainTabStepperProtocol { case .setDetailArchive(let data): newState.detailArchive = data case .clearDetailArchive: - newState.detailArchive = DetailInfo(archiveInfo: .init(archiveId: 0, authorId: 0, name: "", watchedOn: "", emotion: .fun, companions: nil, mainImage: "", images: nil, nickname: "", profileImage: ""), innerIndex: 0, index: 0) + newState.detailArchive = DetailInfo(archiveInfo: .init(), innerIndex: 0, index: 0) case .setBannerInfo(let info): newState.bannerInfo = info case .appendArchives(let archives): diff --git a/Archive/Main/Community/Detail/CommunityDetailViewController.swift b/Archive/Main/Community/Detail/CommunityDetailViewController.swift index 44abfc9..f7de3b7 100644 --- a/Archive/Main/Community/Detail/CommunityDetailViewController.swift +++ b/Archive/Main/Community/Detail/CommunityDetailViewController.swift @@ -382,7 +382,7 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab reactor.state .map { $0.detailArchive } .distinctUntilChanged() - .asDriver(onErrorJustReturn: .init(archiveInfo: .init(archiveId: 0, authorId: 0, name: "", watchedOn: "", emotion: .fun, companions: nil, mainImage: "", images: nil, nickname: "", profileImage: ""), innerIndex: 0, index: 0)) + .asDriver(onErrorJustReturn: .init(archiveInfo: .init(), innerIndex: 0, index: 0)) .drive(onNext: { [weak self] data in if data.innerIndex == 0 { self?.showCover(infoData: data) @@ -411,7 +411,7 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab reactor.state .map { $0.detailArchive } .distinctUntilChanged() - .asDriver(onErrorJustReturn: .init(archiveInfo: .init(archiveId: 0, authorId: 0, name: "", watchedOn: "", emotion: .fun, companions: nil, mainImage: "", images: nil, nickname: "", profileImage: ""), innerIndex: 0, index: 0)) + .asDriver(onErrorJustReturn: .init(archiveInfo: .init(), innerIndex: 0, index: 0)) .drive(onNext: { [weak self] data in self?.likeBtn.isLike = LikeManager.shared.likeList.contains("\(data.archiveInfo.archiveId)") }) diff --git a/Archive/Usecase/Detail/DetailRepository.swift b/Archive/Usecase/Detail/DetailRepository.swift index 8bf6e37..919278a 100644 --- a/Archive/Usecase/Detail/DetailRepository.swift +++ b/Archive/Usecase/Detail/DetailRepository.swift @@ -24,7 +24,57 @@ struct ArchiveDetailInfo: CodableWrapper, Equatable { let images: [ArchiveDetailImageInfo]? let nickname: String let profileImage: String - let coverType: CoverType = .image + let coverType: CoverType + + enum CodingKeys: String, CodingKey { + case archiveId + case authorId + case name + case watchedOn + case emotion + case companions + case mainImage + case images + case nickname + case profileImage + case coverType = "coverImageType" + } + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.archiveId = try container.decode(Int.self, forKey: .archiveId) + self.authorId = try container.decode(Int.self, forKey: .authorId) + self.name = try container.decode(String.self, forKey: .name) + self.watchedOn = try container.decode(String.self, forKey: .watchedOn) + let emotionRawValue = try container.decode(String.self, forKey: .emotion) + self.emotion = Emotion.fromString(emotionRawValue) ?? .fun + self.companions = try? container.decode([String].self, forKey: .companions) + self.mainImage = try container.decode(String.self, forKey: .mainImage) + self.images = try? container.decode([ArchiveDetailImageInfo].self, forKey: .images) + self.nickname = try container.decode(String.self, forKey: .nickname) + self.profileImage = try container.decode(String.self, forKey: .profileImage) + if let coverTypeRawValue = try? container.decode(String.self, forKey: .coverType) { + self.coverType = CoverType.coverTypeFromRawValue(coverTypeRawValue) ?? .cover + } else { + self.coverType = .cover + } + + } + + init() { + self.coverType = .cover + self.archiveId = 0 + self.authorId = 0 + self.name = "" + self.watchedOn = "" + self.emotion = .pleasant + self.companions = [] + self.mainImage = "" + self.images = [] + self.nickname = "" + self.profileImage = "" + } + } struct ArchiveDetailImageInfo: CodableWrapper { From e6a766c1baedda59590b9d8fc4a0d08ebfb7bf5d Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Tue, 17 Jan 2023 16:17:42 +0900 Subject: [PATCH 13/23] =?UTF-8?q?=ED=8D=BC=EB=B8=94=EB=A6=AD=EC=95=84?= =?UTF-8?q?=EC=B9=B4=EC=9D=B4=EB=B8=8C=20=EC=BB=A4=EB=B2=84=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 4 + .../CommunityImageCollectionViewCell.swift | 281 ++++++++++++++++++ .../Community/CommunityViewController.swift | 24 +- .../Community/CommunityRepository.swift | 2 + 4 files changed, 308 insertions(+), 3 deletions(-) create mode 100644 Archive/Main/Community/CommunityImageCollectionViewCell.swift diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index 878db58..4a6266c 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -255,6 +255,7 @@ 78ECDB16280A8F1A005C8D5D /* FindPasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78ECDB15280A8F1A005C8D5D /* FindPasswordViewController.swift */; }; 78ECDB18280A940D005C8D5D /* ConfirmBtn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78ECDB17280A940D005C8D5D /* ConfirmBtn.swift */; }; 78ED6766275B4DAB004E8AEC /* UserDefaultManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78ED6765275B4DAB004E8AEC /* UserDefaultManager.swift */; }; + 78ED8EAA29767D4C006E7595 /* CommunityImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78ED8EA929767D4C006E7595 /* CommunityImageCollectionViewCell.swift */; }; 78EDAD61274525D40028F56D /* ShareCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78EDAD60274525D40028F56D /* ShareCardView.swift */; }; 78EDAD63274525E80028F56D /* ShareCardView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 78EDAD62274525E80028F56D /* ShareCardView.xib */; }; 78F06C8B2830C8420033882E /* MyPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78F06C8A2830C8420033882E /* MyPageViewController.swift */; }; @@ -517,6 +518,7 @@ 78ECDB15280A8F1A005C8D5D /* FindPasswordViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindPasswordViewController.swift; sourceTree = ""; }; 78ECDB17280A940D005C8D5D /* ConfirmBtn.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmBtn.swift; sourceTree = ""; }; 78ED6765275B4DAB004E8AEC /* UserDefaultManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultManager.swift; sourceTree = ""; }; + 78ED8EA929767D4C006E7595 /* CommunityImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityImageCollectionViewCell.swift; sourceTree = ""; }; 78EDAD60274525D40028F56D /* ShareCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareCardView.swift; sourceTree = ""; }; 78EDAD62274525E80028F56D /* ShareCardView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareCardView.xib; sourceTree = ""; }; 78F06C8A2830C8420033882E /* MyPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewController.swift; sourceTree = ""; }; @@ -764,6 +766,7 @@ 781C843D282F7CF3004A0FB3 /* CommunityViewController.swift */, 781C843F282F7D05004A0FB3 /* CommunityReactor.swift */, 78E8E6342866F2F700B18AD8 /* CommunityCollectionViewCell.swift */, + 78ED8EA929767D4C006E7595 /* CommunityImageCollectionViewCell.swift */, 78436F25287C77F800013982 /* CommunityFilterCollectionViewCell.swift */, 783FD01A287DB8DC003EE0C7 /* CommunityFilterHeaderView.swift */, 783010362882A1670031F8CB /* CommunityBannerViewCell.swift */, @@ -1805,6 +1808,7 @@ 44BE6F01271144AB00E74A7D /* TermsAgreementViewController.swift in Sources */, 78A32167275B92530078650D /* DetailViewController.swift in Sources */, 789E61BC2725847B00D6E18F /* ClassIdentifiable.swift in Sources */, + 78ED8EAA29767D4C006E7595 /* CommunityImageCollectionViewCell.swift in Sources */, 78ECDB16280A8F1A005C8D5D /* FindPasswordViewController.swift in Sources */, 7839E4AA28DF26B300A80A1D /* ProfileRepository.swift in Sources */, 78179A5327E6FE7E00420F0A /* LoginWithKakaoRepositoryImplement.swift in Sources */, diff --git a/Archive/Main/Community/CommunityImageCollectionViewCell.swift b/Archive/Main/Community/CommunityImageCollectionViewCell.swift new file mode 100644 index 0000000..3940517 --- /dev/null +++ b/Archive/Main/Community/CommunityImageCollectionViewCell.swift @@ -0,0 +1,281 @@ +// +// CommunityImageCollectionViewCell.swift +// Archive +// +// Created by hanwe on 2023/01/17. +// + +import UIKit +import SnapKit +import Kingfisher +import RxSwift +import RxCocoa +import Then + +class CommunityImageCollectionViewCell: UICollectionViewCell, ClassIdentifiable { + + // MARK: UI property + + private let mainBackgroundView = UIView().then { + $0.backgroundColor = .clear + } + + private let mainContentsView = UIView().then { + $0.backgroundColor = .clear + } + + private let cardView = UIView().then { + $0.backgroundColor = Gen.Colors.white.color + $0.layer.cornerRadius = 8 + $0.layer.masksToBounds = true + } + + private let thumbnailImageView = UIImageView().then { + $0.backgroundColor = .clear + } + +// private let emotionCoverImageView = UIImageView().then { +// $0.backgroundColor = .clear +// } + + private let userImageView = UIImageView().then { + $0.backgroundColor = .clear + $0.image = Gen.Images.userImagePlaceHolder.image + $0.layer.cornerRadius = 15 + $0.layer.masksToBounds = true + } + + private let userNicknameLabel = UILabel().then { + $0.font = .fonts(.button2) + $0.textColor = Gen.Colors.white.color + } + + private let cardBottomView = UIView().then { + $0.backgroundColor = Gen.Colors.white.color + } + + private let archiveTitleLabel = UILabel().then { + $0.font = .fonts(.header3) + $0.textColor = Gen.Colors.black.color + $0.numberOfLines = 2 + } + + private let dateLabel = UILabel().then { + $0.font = .fonts(.subTitle) + $0.textColor = Gen.Colors.gray03.color + } + + private let likeBtn = LikeButton().then { + $0.backgroundColor = .clear + } + + private let likeCntLabel = UILabel().then { + $0.font = .fonts(.body) + $0.textColor = Gen.Colors.gray03.color + } + + private let emotionContainerView = UIView().then { + $0.layer.cornerRadius = 10 + $0.backgroundColor = Gen.Colors.whiteOpacity70.color + } + + private lazy var emotionImageView = UIImageView().then { + $0.backgroundColor = .clear + } + + private lazy var emotionTitleLabel = UILabel().then { + $0.font = .fonts(.subTitle) + $0.textColor = Gen.Colors.black.color + } + + // MARK: private property + + private let disposeBag = DisposeBag() + + // MARK: internal property + + var infoData: PublicArchive? { + didSet { + guard let info = self.infoData else { return } + DispatchQueue.main.async { [weak self] in + if let thumbnailUrl = URL(string: info.mainImage) { + self?.thumbnailImageView.kf.setImage(with: thumbnailUrl, + completionHandler: { [weak self] _ in + self?.thumbnailImageView.fadeIn(duration: 0.1, + completeHandler: nil) + }) + } + + self?.emotionImageView.image = info.emotion.typeImage + self?.emotionTitleLabel.text = info.emotion.localizationTitle + if let userImageUrl = URL(string: info.authorProfileImage) { + self?.userImageView.kf.setImage(with: userImageUrl, placeholder: Gen.Images.userImagePlaceHolder.image) + } else { + self?.userImageView.image = Gen.Images.userImagePlaceHolder.image + } + + self?.userNicknameLabel.text = info.authorNickname + self?.archiveTitleLabel.text = info.archiveName + self?.dateLabel.text = info.watchedOn + let likeCnt: Int = { + var cnt = info.likeCount + if LikeManager.shared.likeList.contains("\(info.archiveId)") { + cnt += 1 + } + return cnt + }() + self?.likeCntLabel.text = likeCnt.likeCntToArchiveLikeCnt + } + } + } + + weak var reactor: CommunityReactor? + var index: Int = -1 + var isLike: Bool = false { + didSet { + DispatchQueue.main.async { [weak self] in + self?.refreshLikeUI() + } + } + } + + static var titleWidth: CGFloat { + return UIScreen.main.bounds.width - 64 - 38 + } + + // MARK: lifeCycle + + override init(frame: CGRect) { + super.init(frame: frame) + setup() + bind() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + bind() + } + + // MARK: private function + + private func setup() { + + self.addSubview(mainBackgroundView) + self.mainBackgroundView.snp.makeConstraints { + $0.edges.equalTo(self) + } + + self.mainBackgroundView.addSubview(self.mainContentsView) + self.mainContentsView.snp.makeConstraints { + $0.edges.equalTo(self.mainBackgroundView) + } + + self.mainContentsView.addSubview(self.cardView) + self.cardView.snp.makeConstraints { + $0.top.equalTo(self.mainContentsView.snp.top) + $0.bottom.equalTo(self.mainContentsView.snp.bottom) + $0.leading.equalTo(self.mainContentsView.snp.leading).offset(32) + $0.trailing.equalTo(self.mainContentsView.snp.trailing).offset(-32) + } + + self.cardView.addSubview(self.thumbnailImageView) + self.thumbnailImageView.snp.makeConstraints { + $0.top.equalTo(self.cardView.snp.top) + $0.leading.equalTo(self.cardView.snp.leading) + $0.trailing.equalTo(self.cardView.snp.trailing) + $0.height.equalTo(self.cardView.snp.width) + } + + self.cardView.addSubview(self.userImageView) + self.userImageView.snp.makeConstraints { + $0.width.equalTo(30) + $0.height.equalTo(30) + $0.top.equalTo(self.cardView.snp.top).offset(16) + $0.leading.equalTo(self.cardView.snp.leading).offset(16) + } + + self.cardView.addSubview(self.userNicknameLabel) + self.userNicknameLabel.snp.makeConstraints { + $0.centerY.equalTo(self.userImageView.snp.centerY) + $0.leading.equalTo(self.userImageView.snp.trailing).offset(8) + $0.trailing.equalTo(self.cardView.snp.trailing).offset(2) + } + + self.cardView.addSubview(self.emotionContainerView) + self.emotionContainerView.snp.makeConstraints { + $0.bottom.trailing.equalTo(self.thumbnailImageView).offset(-4) + } + + emotionContainerView.addSubview(emotionImageView) + emotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.leading.equalTo(self.emotionContainerView).offset(8) + $0.top.equalTo(self.emotionContainerView).offset(6) + $0.bottom.equalTo(self.emotionContainerView).offset(-6) + } + + emotionContainerView.addSubview(emotionTitleLabel) + emotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(emotionImageView.snp.centerY) + $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(emotionContainerView.snp.trailing).offset(-8) + } + + + self.cardView.addSubview(self.cardBottomView) + self.cardBottomView.snp.makeConstraints { + $0.leading.equalTo(self.cardView.snp.leading) + $0.trailing.equalTo(self.cardView.snp.trailing) + $0.top.equalTo(self.thumbnailImageView.snp.bottom) + $0.height.equalTo(self.cardView.snp.height).multipliedBy(0.2) + } + + self.cardBottomView.addSubview(self.archiveTitleLabel) + self.archiveTitleLabel.snp.makeConstraints { + $0.top.equalTo(self.cardBottomView.snp.top).offset(10) + $0.leading.equalTo(self.cardBottomView.snp.leading) + } + + self.cardBottomView.addSubview(self.dateLabel) + self.dateLabel.snp.makeConstraints { + $0.top.equalTo(self.archiveTitleLabel.snp.bottom).offset(5) + $0.leading.equalTo(self.cardView.snp.leading) + } + + self.cardBottomView.addSubview(self.likeBtn) + self.likeBtn.snp.makeConstraints { + $0.trailing.equalTo(self.cardBottomView.snp.trailing).offset(-5) + $0.top.equalTo(self.cardBottomView.snp.top).offset(5) + $0.width.equalTo(30) + $0.height.equalTo(30) + $0.leading.equalTo(self.archiveTitleLabel.snp.trailing).offset(8) + } + + self.cardBottomView.addSubview(self.likeCntLabel) + self.likeCntLabel.snp.makeConstraints { + $0.centerX.equalTo(self.likeBtn.snp.centerX) + $0.top.equalTo(self.likeBtn.snp.bottom).offset(-5) + } + } + + private func bind() { + self.likeBtn.rx.likeClicked + .subscribe(onNext: { [weak self] isLike in + if isLike { + LikeManager.shared.like(id: "\(self?.infoData?.archiveId ?? -1)") + } else { + LikeManager.shared.likeCancel(id: "\(self?.infoData?.archiveId ?? -1)") + } + }) + .disposed(by: self.disposeBag) + } + + private func refreshLikeUI() { + self.likeBtn.isLike = self.isLike + } + + // MARK: internal function + +} diff --git a/Archive/Main/Community/CommunityViewController.swift b/Archive/Main/Community/CommunityViewController.swift index 5ec2bc3..02d800b 100644 --- a/Archive/Main/Community/CommunityViewController.swift +++ b/Archive/Main/Community/CommunityViewController.swift @@ -94,9 +94,12 @@ class CommunityViewController: UIViewController, View, ActivityIndicatorable, Ac let configuration = AnimationConfiguration(insertAnimation: .automatic, reloadAnimation: .automatic, deleteAnimation: .automatic) let ds = ArchiveSectionDataSource(animationConfiguration: configuration) { datasource, collectionView, indexPath, item in - var cell = self.makeArchiveCell(item, from: collectionView, indexPath: indexPath) - - return cell + switch item.coverType { + case .cover: + return self.makeArchiveCell(item, from: collectionView, indexPath: indexPath) + case .image: + return self.makeArchiveImageCell(item, from: collectionView, indexPath: indexPath) + } } return ds @@ -117,6 +120,7 @@ class CommunityViewController: UIViewController, View, ActivityIndicatorable, Ac override func viewDidLoad() { super.viewDidLoad() self.collectionView.register(CommunityCollectionViewCell.self, forCellWithReuseIdentifier: CommunityCollectionViewCell.identifier) + self.collectionView.register(CommunityImageCollectionViewCell.self, forCellWithReuseIdentifier: CommunityImageCollectionViewCell.identifier) collectionView.register(CommunityFilterHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: CommunityFilterHeaderView.identifier) self.reactor?.action.onNext(.getFirstPublicArchives(sortBy: .sortByRegist, emotion: nil)) setupDatasource() @@ -306,6 +310,14 @@ class CommunityViewController: UIViewController, View, ActivityIndicatorable, Ac return cell } + private func makeArchiveImageCell(_ archive: PublicArchive, from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CommunityImageCollectionViewCell.identifier, for: indexPath) as? CommunityImageCollectionViewCell else { return UICollectionViewCell() } + cell.infoData = archive + cell.index = indexPath.item + cell.isLike = LikeManager.shared.likeList.contains("\(archive.archiveId)") + return cell + } + private func makeArhiveFilterCell(from collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CommunityFilterCollectionViewCell.identifier, for: indexPath) as? CommunityFilterCollectionViewCell else { return UICollectionViewCell() } return cell @@ -351,6 +363,12 @@ class CommunityViewController: UIViewController, View, ActivityIndicatorable, Ac self?.collectionView.reloadItems(at: [IndexPath(item: cell.index, section: 0)]) } } + } else if let cell = ($0 as? CommunityImageCollectionViewCell) { + if changedArchiveIdSet.contains("\(cell.infoData?.archiveId ?? 0)") { + if cell.index != -1 { + self?.collectionView.reloadItems(at: [IndexPath(item: cell.index, section: 0)]) + } + } } } } diff --git a/Archive/Usecase/Community/CommunityRepository.swift b/Archive/Usecase/Community/CommunityRepository.swift index 6e8dc4b..b7fcfff 100644 --- a/Archive/Usecase/Community/CommunityRepository.swift +++ b/Archive/Usecase/Community/CommunityRepository.swift @@ -25,6 +25,7 @@ struct PublicArchive: CodableWrapper { let watchedOn: String let dateMilli: Int? var likeCount: Int + var coverType: CoverType enum CodingKeys: String, CodingKey { case authorId @@ -37,6 +38,7 @@ struct PublicArchive: CodableWrapper { case watchedOn case dateMilli case likeCount + case coverType = "coverImageType" } } From f5b38609d3178a21e846bddbcc94bdfc54bc43fb Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Tue, 17 Jan 2023 16:24:08 +0900 Subject: [PATCH 14/23] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=BB=A8?= =?UTF-8?q?=ED=85=90=EC=B8=A0=EB=AA=A8=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Main/Community/CommunityImageCollectionViewCell.swift | 3 ++- Archive/Main/Home/TicketImageTypeCollectionViewCell.swift | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Archive/Main/Community/CommunityImageCollectionViewCell.swift b/Archive/Main/Community/CommunityImageCollectionViewCell.swift index 3940517..cae065a 100644 --- a/Archive/Main/Community/CommunityImageCollectionViewCell.swift +++ b/Archive/Main/Community/CommunityImageCollectionViewCell.swift @@ -31,7 +31,8 @@ class CommunityImageCollectionViewCell: UICollectionViewCell, ClassIdentifiable } private let thumbnailImageView = UIImageView().then { - $0.backgroundColor = .clear + $0.contentMode = .scaleAspectFill +// $0.backgroundColor = .clear } // private let emotionCoverImageView = UIImageView().then { diff --git a/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift b/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift index 09e23eb..f8982fe 100644 --- a/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift +++ b/Archive/Main/Home/TicketImageTypeCollectionViewCell.swift @@ -31,6 +31,7 @@ final class TicketImageTypeCollectionViewCell: UICollectionViewCell, ReuseIdenti private lazy var mainImageView: UIImageView = { let imageView = UIImageView() + imageView.contentMode = .scaleAspectFill return imageView }() From 167c7b437e7062b498523dbb054afadb17f98392 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Tue, 17 Jan 2023 16:44:15 +0900 Subject: [PATCH 15/23] =?UTF-8?q?=EC=A2=8B=EC=95=84=EC=9A=94=20=EC=B9=B4?= =?UTF-8?q?=EB=93=9C=20=ED=83=80=EC=9E=85=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommunityImageCollectionViewCell.swift | 5 -- .../MyLikeList/MyLikeCollectionViewCell.swift | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Archive/Main/Community/CommunityImageCollectionViewCell.swift b/Archive/Main/Community/CommunityImageCollectionViewCell.swift index cae065a..61c9418 100644 --- a/Archive/Main/Community/CommunityImageCollectionViewCell.swift +++ b/Archive/Main/Community/CommunityImageCollectionViewCell.swift @@ -32,13 +32,8 @@ class CommunityImageCollectionViewCell: UICollectionViewCell, ClassIdentifiable private let thumbnailImageView = UIImageView().then { $0.contentMode = .scaleAspectFill -// $0.backgroundColor = .clear } -// private let emotionCoverImageView = UIImageView().then { -// $0.backgroundColor = .clear -// } - private let userImageView = UIImageView().then { $0.backgroundColor = .clear $0.image = Gen.Images.userImagePlaceHolder.image diff --git a/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift b/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift index c72ef64..2f2c93f 100644 --- a/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift +++ b/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift @@ -79,6 +79,20 @@ class MyLikeCollectionViewCell: UICollectionViewCell, ClassIdentifiable { $0.textColor = Gen.Colors.gray03.color } + private let emotionContainerView = UIView().then { + $0.layer.cornerRadius = 10 + $0.backgroundColor = Gen.Colors.whiteOpacity70.color + } + + private lazy var emotionImageView = UIImageView().then { + $0.backgroundColor = .clear + } + + private lazy var emotionTitleLabel = UILabel().then { + $0.font = .fonts(.subTitle) + $0.textColor = Gen.Colors.black.color + } + // MARK: private property private let disposeBag = DisposeBag() @@ -105,6 +119,18 @@ class MyLikeCollectionViewCell: UICollectionViewCell, ClassIdentifiable { self?.archiveTitleLabel.text = info.archiveName self?.dateLabel.text = info.watchedOn self?.likeCntLabel.text = info.likeCount.likeCntToArchiveLikeCnt + self?.emotionImageView.image = info.emotion.typeImage + self?.emotionTitleLabel.text = info.emotion.localizationTitle + switch info.coverType { + case .cover: + self?.emotionContainerView.isHidden = true + self?.emotionCoverImageView.isHidden = false + self?.thumbnailImageView.contentMode = .scaleToFill + case .image: + self?.emotionCoverImageView.isHidden = true + self?.emotionContainerView.isHidden = false + self?.thumbnailImageView.contentMode = .scaleAspectFill + } } } } @@ -213,6 +239,27 @@ class MyLikeCollectionViewCell: UICollectionViewCell, ClassIdentifiable { $0.centerX.equalTo(self.likeBtn.snp.centerX) $0.top.equalTo(self.likeBtn.snp.bottom).offset(-5) } + + self.cardView.addSubview(self.emotionContainerView) + self.emotionContainerView.snp.makeConstraints { + $0.bottom.trailing.equalTo(self.thumbnailImageView).offset(-4) + } + + emotionContainerView.addSubview(emotionImageView) + emotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.leading.equalTo(self.emotionContainerView).offset(8) + $0.top.equalTo(self.emotionContainerView).offset(6) + $0.bottom.equalTo(self.emotionContainerView).offset(-6) + } + + emotionContainerView.addSubview(emotionTitleLabel) + emotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(emotionImageView.snp.centerY) + $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(emotionContainerView.snp.trailing).offset(-8) + } } private func bind() { From 01730926a7361c32d810d2def904a4a768d18076 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 18 Jan 2023 14:27:33 +0900 Subject: [PATCH 16/23] =?UTF-8?q?=EC=BB=A4=EB=AE=A4=EB=8B=88=ED=8B=B0=20?= =?UTF-8?q?=EB=94=94=ED=85=8C=EC=9D=BC=20=EC=BB=A4=EB=B2=84=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommunityDetailViewController.swift | 84 +++++++++++++++++-- 1 file changed, 75 insertions(+), 9 deletions(-) diff --git a/Archive/Main/Community/Detail/CommunityDetailViewController.swift b/Archive/Main/Community/Detail/CommunityDetailViewController.swift index f7de3b7..24035ff 100644 --- a/Archive/Main/Community/Detail/CommunityDetailViewController.swift +++ b/Archive/Main/Community/Detail/CommunityDetailViewController.swift @@ -135,6 +135,28 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab // private let // 친구들 보여줘야할까? + private let topFullCoverContentsView = UIView().then { + $0.backgroundColor = Gen.Colors.white.color + } + + private let fullMainImageView = UIImageView().then { + $0.contentMode = .scaleAspectFill + } + + private let fullTypeEmotionContainerView = UIView().then { + $0.layer.cornerRadius = 10 + $0.backgroundColor = Gen.Colors.whiteOpacity70.color + } + + private lazy var fullTypeEmotionImageView = UIImageView().then { + $0.backgroundColor = .clear + } + + private lazy var fullTypeEmotionTitleLabel = UILabel().then { + $0.font = .fonts(.subTitle) + $0.textColor = Gen.Colors.black.color + } + // type Photo private let topPhotoContentsView = UIView().then { @@ -349,6 +371,41 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab $0.centerX.equalTo(likeBtn.snp.centerX) $0.top.equalTo(self.likeBtn.snp.bottom).offset(5) } + + + + + self.topContentsView.addSubview(self.topFullCoverContentsView) + self.topFullCoverContentsView.snp.makeConstraints { + $0.edges.equalTo(self.topContentsView) + } + + self.topFullCoverContentsView.addSubview(self.fullMainImageView) + self.fullMainImageView.snp.makeConstraints { + $0.edges.equalTo(self.topFullCoverContentsView) + } + + topFullCoverContentsView.addSubview(self.fullTypeEmotionContainerView) + self.fullTypeEmotionContainerView.snp.makeConstraints { + $0.leading.equalTo(self.topFullCoverContentsView).offset(12) + $0.top.equalTo(self.progressBar).offset(12) + } + + fullTypeEmotionContainerView.addSubview(fullTypeEmotionImageView) + fullTypeEmotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.leading.equalTo(self.fullTypeEmotionContainerView).offset(8) + $0.top.equalTo(self.fullTypeEmotionContainerView).offset(6) + $0.bottom.equalTo(self.fullTypeEmotionContainerView).offset(-6) + } + + fullTypeEmotionContainerView.addSubview(fullTypeEmotionTitleLabel) + fullTypeEmotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(fullTypeEmotionImageView.snp.centerY) + $0.leading.equalTo(fullTypeEmotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(fullTypeEmotionContainerView.snp.trailing).offset(-8) + } } required init?(coder: NSCoder) { @@ -439,7 +496,16 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab private func showCover(infoData: CommunityReactor.DetailInfo) { let item = infoData.archiveInfo - self.topCoverContentsView.isHidden = false + switch infoData.archiveInfo.coverType { + case .cover: + self.topCoverContentsView.isHidden = false + self.topFullCoverContentsView.isHidden = true + case .image: + print("무슨?") + self.topCoverContentsView.isHidden = true + self.topFullCoverContentsView.isHidden = false + } + self.bottomCoverContentsView.isHidden = false self.topPhotoContentsView.isHidden = true self.bottomPhotoContentsView.isHidden = true @@ -449,17 +515,16 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab placeholder: nil, options: [.cacheMemoryOnly], completionHandler: nil) + self.fullMainImageView.kf.setImage(with: URL(string: item.mainImage), + placeholder: nil, + options: [.cacheMemoryOnly], + completionHandler: nil) + self.topCoverEmotionCoverView.image = item.emotion.coverAlphaImage self.bottomCoverTitleLabel.text = item.name self.bottomCoverDateLabel.text = item.watchedOn -// self.userNameLabel.text = item.authorId - -// self.likeBtn.isLike -// private let likeCntLabel = UILabel().then { -// $0.font = .fonts(.body) -// $0.textColor = Gen.Colors.gray03.color -// } - + self.fullTypeEmotionImageView.image = item.emotion.typeImage + self.fullTypeEmotionTitleLabel.text = item.emotion.localizationTitle if self.currentIndex != -1 { if currentIndex > infoData.index { @@ -507,6 +572,7 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab private func showPhoto(infoData: CommunityReactor.DetailInfo) { guard let item = infoData.archiveInfo.images?[infoData.innerIndex-1] else { return } self.topCoverContentsView.isHidden = true + self.topFullCoverContentsView.isHidden = true self.bottomCoverContentsView.isHidden = true self.topPhotoContentsView.isHidden = false self.bottomPhotoContentsView.isHidden = false From 62bf1542f02f2808b6cd6a7cf22e617c5ae7fd00 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 18 Jan 2023 14:29:50 +0900 Subject: [PATCH 17/23] =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index 4a6266c..42c0f97 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -2094,7 +2094,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 37; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -2102,7 +2102,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.4; OTHER_LDFLAGS = ( "$(inherited)", "-framework", @@ -2174,7 +2174,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 37; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -2182,7 +2182,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2.0.2; + MARKETING_VERSION = 2.0.4; OTHER_LDFLAGS = ( "$(inherited)", "-framework", From bfdcd892098605fc74ba6cebb5ce6b3149a2ad46 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 18 Jan 2023 15:02:03 +0900 Subject: [PATCH 18/23] =?UTF-8?q?=EC=89=90=EC=96=B4=20=EC=B9=B4=EB=93=9C?= =?UTF-8?q?=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 4 +-- .../ShareCard/ShareCardView.swift | 35 +++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index 42c0f97..035dcca 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -2094,7 +2094,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 37; + CURRENT_PROJECT_VERSION = 38; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -2174,7 +2174,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 37; + CURRENT_PROJECT_VERSION = 38; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; diff --git a/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift b/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift index cda07dc..83db643 100644 --- a/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift +++ b/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift @@ -7,6 +7,7 @@ import UIKit import SnapKit +import Then class ShareCardView: UIView, NibIdentifiable { // MARK: IBOutlet @@ -25,6 +26,12 @@ class ShareCardView: UIView, NibIdentifiable { return view }() + + // cover + private let coverTypeContainerView = UIView().then { + $0.backgroundColor = .clear + } + private lazy var mainImageView: UIImageView = { let imageView = UIImageView() return imageView @@ -36,6 +43,12 @@ class ShareCardView: UIView, NibIdentifiable { return imageView }() + // full image + + + + // end + private lazy var descriptionView: TicketDescriptionContentView = { let view = TicketDescriptionContentView() return view @@ -90,31 +103,38 @@ class ShareCardView: UIView, NibIdentifiable { imageContentView.snp.makeConstraints { $0.width.equalTo(imageContentView.snp.height).multipliedBy(0.75) } - imageContentView.addSubview(mainImageView) + + self.imageContentView.addSubview(self.coverTypeContainerView) + self.coverTypeContainerView.snp.makeConstraints { + $0.edges.equalTo(self.imageContentView) + } + + + coverTypeContainerView.addSubview(mainImageView) mainImageView.snp.makeConstraints { $0.width.equalTo(mainImageView.snp.height) $0.leading.trailing.centerY.equalToSuperview() } - imageContentView.addSubview(coverImageView) + coverTypeContainerView.addSubview(coverImageView) coverImageView.snp.makeConstraints { $0.width.equalTo(coverImageView.snp.height) $0.leading.trailing.centerY.equalToSuperview() } contentStackView.addArrangedSubview(descriptionView) descriptionView.snp.makeConstraints { - $0.height.equalTo(imageContentView.snp.height).multipliedBy(0.3) + $0.height.equalTo(coverTypeContainerView.snp.height).multipliedBy(0.3) } descriptionView.setLayout() - imageContentView.addSubview(emotionImageView) + coverTypeContainerView.addSubview(emotionImageView) emotionImageView.snp.makeConstraints { $0.width.equalTo(24) $0.height.equalTo(24) - $0.top.equalTo(imageContentView.snp.top).offset(20) - $0.leading.equalTo(imageContentView.snp.leading).offset(20) + $0.top.equalTo(coverTypeContainerView.snp.top).offset(20) + $0.leading.equalTo(coverTypeContainerView.snp.leading).offset(20) } - imageContentView.addSubview(emotionTitleLabel) + coverTypeContainerView.addSubview(emotionTitleLabel) emotionTitleLabel.snp.makeConstraints { $0.centerY.equalTo(emotionImageView.snp.centerY) $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) @@ -130,6 +150,7 @@ class ShareCardView: UIView, NibIdentifiable { self.coverImageView.image = emotion.coverAlphaImage self.emotionImageView.image = emotion.preImage self.emotionTitleLabel.text = emotion.localizationTitle + self.coverTypeContainerView.backgroundColor = emotion.color self.mainImageView.image = thumbnailImage self.descriptionView.titleLabel.text = eventName self.descriptionView.dateLabel.text = date From 563f0069491ed5085a8918960a436d4715155827 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 18 Jan 2023 15:21:54 +0900 Subject: [PATCH 19/23] =?UTF-8?q?=EA=B3=B5=EC=9C=A0=20=ED=92=80=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Detail/DetailReactor.swift | 2 +- .../ShareCard/ShareCardView.swift | 72 +++++++++++++++++-- .../RegistUploadCompleteViewController.swift | 3 +- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/Archive/Detail/DetailReactor.swift b/Archive/Detail/DetailReactor.swift index f8a5c5d..013ace4 100644 --- a/Archive/Detail/DetailReactor.swift +++ b/Archive/Detail/DetailReactor.swift @@ -152,7 +152,7 @@ class DetailReactor: Reactor, Stepper { guard let self = self else { return } guard let cardView: ShareCardView = ShareCardView.instance() else { return } cardView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width * 1.73) - cardView.setInfoData(emotion: self.recordData.emotion, thumbnailImage: UIImage(data: data) ?? UIImage(), eventName: self.recordData.name, date: self.recordData.watchedOn) + cardView.setInfoData(emotion: self.recordData.emotion, thumbnailImage: UIImage(data: data) ?? UIImage(), eventName: self.recordData.name, date: self.recordData.watchedOn, coverType: self.recordData.coverType) completion(cardView) } } else { diff --git a/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift b/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift index 83db643..4f32f1c 100644 --- a/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift +++ b/Archive/Main/Regist/SubViewController/ShareCard/ShareCardView.swift @@ -45,6 +45,27 @@ class ShareCardView: UIView, NibIdentifiable { // full image + private let fullTypeContainerView = UIView().then { + $0.backgroundColor = .clear + } + + private let fullTypeMainImageView = UIImageView().then { + $0.contentMode = .scaleAspectFill + } + + private let fullTypeEmotionContainerView = UIView().then { + $0.layer.cornerRadius = 10 + $0.backgroundColor = Gen.Colors.whiteOpacity70.color + } + + private lazy var fullTypeEmotionImageView = UIImageView().then { + $0.backgroundColor = .clear + } + + private lazy var fullTypeEmotionTitleLabel = UILabel().then { + $0.font = .fonts(.subTitle) + $0.textColor = Gen.Colors.black.color + } // end @@ -122,11 +143,11 @@ class ShareCardView: UIView, NibIdentifiable { } contentStackView.addArrangedSubview(descriptionView) descriptionView.snp.makeConstraints { - $0.height.equalTo(coverTypeContainerView.snp.height).multipliedBy(0.3) + $0.height.equalTo(imageContentView.snp.height).multipliedBy(0.3) } descriptionView.setLayout() - coverTypeContainerView.addSubview(emotionImageView) + imageContentView.addSubview(emotionImageView) emotionImageView.snp.makeConstraints { $0.width.equalTo(24) $0.height.equalTo(24) @@ -134,16 +155,47 @@ class ShareCardView: UIView, NibIdentifiable { $0.leading.equalTo(coverTypeContainerView.snp.leading).offset(20) } - coverTypeContainerView.addSubview(emotionTitleLabel) + imageContentView.addSubview(emotionTitleLabel) emotionTitleLabel.snp.makeConstraints { $0.centerY.equalTo(emotionImageView.snp.centerY) $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) } + + self.imageContentView.addSubview(self.fullTypeContainerView) + self.fullTypeContainerView.snp.makeConstraints { + $0.edges.equalTo(self.imageContentView) + } + + self.fullTypeContainerView.addSubview(self.fullTypeMainImageView) + self.fullTypeMainImageView.snp.makeConstraints { + $0.edges.equalTo(self.fullTypeContainerView) + } + + fullTypeContainerView.addSubview(self.fullTypeEmotionContainerView) + self.fullTypeEmotionContainerView.snp.makeConstraints { + $0.leading.top.equalTo(self.fullTypeContainerView).offset(12) + } + + fullTypeEmotionContainerView.addSubview(fullTypeEmotionImageView) + fullTypeEmotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.leading.equalTo(self.fullTypeEmotionContainerView).offset(8) + $0.top.equalTo(self.fullTypeEmotionContainerView).offset(6) + $0.bottom.equalTo(self.fullTypeEmotionContainerView).offset(-6) + } + + fullTypeEmotionContainerView.addSubview(fullTypeEmotionTitleLabel) + fullTypeEmotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(fullTypeEmotionImageView.snp.centerY) + $0.leading.equalTo(fullTypeEmotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(fullTypeEmotionContainerView.snp.trailing).offset(-8) + } } // MARK: internal function - func setInfoData(emotion: Emotion, thumbnailImage: UIImage, eventName: String, date: String) { + func setInfoData(emotion: Emotion, thumbnailImage: UIImage, eventName: String, date: String, coverType: CoverType) { self.topBackgroundColor = emotion.darkenColor self.bottomBackgroundColor = emotion.color self.imageContentView.bgColor = emotion.color @@ -154,6 +206,18 @@ class ShareCardView: UIView, NibIdentifiable { self.mainImageView.image = thumbnailImage self.descriptionView.titleLabel.text = eventName self.descriptionView.dateLabel.text = date + self.fullTypeMainImageView.image = thumbnailImage + self.fullTypeEmotionImageView.image = emotion.typeImage + self.fullTypeEmotionTitleLabel.text = emotion.localizationTitle + + switch coverType { + case .cover: + self.fullTypeContainerView.isHidden = true + self.coverTypeContainerView.isHidden = false + case .image: + self.fullTypeContainerView.isHidden = false + self.coverTypeContainerView.isHidden = true + } } } diff --git a/Archive/Main/Regist/UploadComplete/RegistUploadCompleteViewController.swift b/Archive/Main/Regist/UploadComplete/RegistUploadCompleteViewController.swift index 4415c97..73cf18a 100644 --- a/Archive/Main/Regist/UploadComplete/RegistUploadCompleteViewController.swift +++ b/Archive/Main/Regist/UploadComplete/RegistUploadCompleteViewController.swift @@ -239,7 +239,8 @@ class RegistUploadCompleteViewController: UIViewController, View { cardView.setInfoData(emotion: self.reactor?.currentState.emotion ?? .pleasant, thumbnailImage: self.reactor?.currentState.imageInfo.images[0].image ?? UIImage(), eventName: self.reactor?.currentState.archiveName ?? "", - date: self.reactor?.currentState.visitDate ?? "") + date: self.reactor?.currentState.visitDate ?? "", + coverType: (self.reactor?.currentState.isCoverUsing ?? true) ? .cover : .image) return cardView } From 0cf52ac092b1298df1f3ccb577414db1d15e2c27 Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 18 Jan 2023 15:31:30 +0900 Subject: [PATCH 20/23] =?UTF-8?q?=EC=83=81=EC=84=B8=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=85=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...etailCardImageTypeCollectionViewCell.swift | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift b/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift index 0ecfce5..c7ffb7a 100644 --- a/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift +++ b/Archive/Detail/Sub/DetailCard/DetailCardImageTypeCollectionViewCell.swift @@ -29,6 +29,23 @@ class DetailCardImageTypeCollectionViewCell: UICollectionViewCell, ClassIdentifi @IBOutlet weak var friendsCollectionView: UICollectionView! + private let emotionContainerView = UIView().then { + $0.layer.cornerRadius = 10 + $0.backgroundColor = Gen.Colors.whiteOpacity70.color + } + + private lazy var emotionImageView: UIImageView = { + let imageView = UIImageView() + return imageView + }() + + private lazy var emotionTitleLabel: UILabel = { + let label: UILabel = UILabel() + label.font = .fonts(.subTitle) + label.textColor = Gen.Colors.black.color + return label + }() + // MARK: private property // MARK: internal property @@ -92,12 +109,36 @@ class DetailCardImageTypeCollectionViewCell: UICollectionViewCell, ClassIdentifi self.mainImageView.contentMode = .scaleAspectFill + centerContainerView.addSubview(self.emotionContainerView) + self.emotionContainerView.snp.makeConstraints { + $0.leading.equalTo(self.centerContainerView).offset(12) + $0.top.equalTo(self.topContainerView.snp.bottom).offset(12) + } + + emotionContainerView.addSubview(emotionImageView) + emotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.leading.equalTo(self.emotionContainerView).offset(8) + $0.top.equalTo(self.emotionContainerView).offset(6) + $0.bottom.equalTo(self.emotionContainerView).offset(-6) + } + + emotionContainerView.addSubview(emotionTitleLabel) + emotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(emotionImageView.snp.centerY) + $0.leading.equalTo(emotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(emotionContainerView.snp.trailing).offset(-8) + } + } private func setNewEmotion(_ emotion: Emotion) { self.mainContetnsView.backgroundColor = Gen.Colors.gray05.color self.emotionLabel.text = emotion.localizationTitle self.miniEmotionImageView.image = emotion.preImage + self.emotionImageView.image = emotion.typeImage + self.emotionTitleLabel.text = emotion.localizationTitle } private func getFriendsCellWidth(_ text: String) -> CGFloat { From 06ea06711bacc000a20afc148eb45734ca1ba95f Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 25 Jan 2023 16:59:21 +0900 Subject: [PATCH 21/23] =?UTF-8?q?=EB=B2=84=EA=B7=B8=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EB=94=94=EC=9E=90=EC=9D=B8=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommunityImageCollectionViewCell.swift | 4 +- .../CommunityDetailViewController.swift | 72 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Archive/Main/Community/CommunityImageCollectionViewCell.swift b/Archive/Main/Community/CommunityImageCollectionViewCell.swift index 61c9418..72ad105 100644 --- a/Archive/Main/Community/CommunityImageCollectionViewCell.swift +++ b/Archive/Main/Community/CommunityImageCollectionViewCell.swift @@ -32,6 +32,7 @@ class CommunityImageCollectionViewCell: UICollectionViewCell, ClassIdentifiable private let thumbnailImageView = UIImageView().then { $0.contentMode = .scaleAspectFill + $0.backgroundColor = Gen.Colors.gray05.color } private let userImageView = UIImageView().then { @@ -96,6 +97,7 @@ class CommunityImageCollectionViewCell: UICollectionViewCell, ClassIdentifiable DispatchQueue.main.async { [weak self] in if let thumbnailUrl = URL(string: info.mainImage) { self?.thumbnailImageView.kf.setImage(with: thumbnailUrl, + placeholder: Gen.Images.defaultEmotionMain.image, completionHandler: { [weak self] _ in self?.thumbnailImageView.fadeIn(duration: 0.1, completeHandler: nil) @@ -200,7 +202,7 @@ class CommunityImageCollectionViewCell: UICollectionViewCell, ClassIdentifiable self.cardView.addSubview(self.emotionContainerView) self.emotionContainerView.snp.makeConstraints { - $0.bottom.trailing.equalTo(self.thumbnailImageView).offset(-4) + $0.bottom.trailing.equalTo(self.thumbnailImageView).offset(-16) } emotionContainerView.addSubview(emotionImageView) diff --git a/Archive/Main/Community/Detail/CommunityDetailViewController.swift b/Archive/Main/Community/Detail/CommunityDetailViewController.swift index 24035ff..951567e 100644 --- a/Archive/Main/Community/Detail/CommunityDetailViewController.swift +++ b/Archive/Main/Community/Detail/CommunityDetailViewController.swift @@ -315,9 +315,44 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab $0.bottom.equalTo(self.bottomContentsView) } + self.view.addSubview(self.progressBar) + self.progressBar.snp.makeConstraints { + $0.top.equalTo(safeGuide) + $0.leading.trailing.equalTo(self.mainContentsView) + $0.height.equalTo(2) + } + self.topContentsView.addSubview(self.topFullCoverContentsView) + self.topFullCoverContentsView.snp.makeConstraints { + $0.edges.equalTo(self.topContentsView) + } + self.topFullCoverContentsView.addSubview(self.fullMainImageView) + self.fullMainImageView.snp.makeConstraints { + $0.edges.equalTo(self.topFullCoverContentsView) + } + self.topFullCoverContentsView.addSubview(self.fullTypeEmotionContainerView) + self.fullTypeEmotionContainerView.snp.makeConstraints { + $0.leading.equalTo(self.topFullCoverContentsView).offset(12) + $0.top.equalTo(self.progressBar).offset(12) + } + + self.fullTypeEmotionContainerView.addSubview(self.fullTypeEmotionImageView) + self.fullTypeEmotionImageView.snp.makeConstraints { + $0.width.equalTo(24) + $0.height.equalTo(24) + $0.leading.equalTo(self.fullTypeEmotionContainerView).offset(8) + $0.top.equalTo(self.fullTypeEmotionContainerView).offset(6) + $0.bottom.equalTo(self.fullTypeEmotionContainerView).offset(-6) + } + + self.fullTypeEmotionContainerView.addSubview(self.fullTypeEmotionTitleLabel) + self.fullTypeEmotionTitleLabel.snp.makeConstraints { + $0.centerY.equalTo(fullTypeEmotionImageView.snp.centerY) + $0.leading.equalTo(fullTypeEmotionImageView.snp.trailing).offset(8) + $0.trailing.equalTo(fullTypeEmotionContainerView.snp.trailing).offset(-8) + } self.topContentsView.addSubview(self.leftTriangleView) self.leftTriangleView.snp.makeConstraints { @@ -351,13 +386,6 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab $0.width.equalTo(50) } - self.view.addSubview(self.progressBar) - self.progressBar.snp.makeConstraints { - $0.top.equalTo(safeGuide) - $0.leading.trailing.equalTo(self.mainContentsView) - $0.height.equalTo(2) - } - self.bottomContentsView.addSubview(self.likeBtn) self.likeBtn.snp.makeConstraints { $0.trailing.equalTo(self.bottomContentsView.snp.trailing).offset(-32) @@ -375,37 +403,7 @@ class CommunityDetailViewController: UIViewController, View, ActivityIndicatorab - self.topContentsView.addSubview(self.topFullCoverContentsView) - self.topFullCoverContentsView.snp.makeConstraints { - $0.edges.equalTo(self.topContentsView) - } - - self.topFullCoverContentsView.addSubview(self.fullMainImageView) - self.fullMainImageView.snp.makeConstraints { - $0.edges.equalTo(self.topFullCoverContentsView) - } - topFullCoverContentsView.addSubview(self.fullTypeEmotionContainerView) - self.fullTypeEmotionContainerView.snp.makeConstraints { - $0.leading.equalTo(self.topFullCoverContentsView).offset(12) - $0.top.equalTo(self.progressBar).offset(12) - } - - fullTypeEmotionContainerView.addSubview(fullTypeEmotionImageView) - fullTypeEmotionImageView.snp.makeConstraints { - $0.width.equalTo(24) - $0.height.equalTo(24) - $0.leading.equalTo(self.fullTypeEmotionContainerView).offset(8) - $0.top.equalTo(self.fullTypeEmotionContainerView).offset(6) - $0.bottom.equalTo(self.fullTypeEmotionContainerView).offset(-6) - } - - fullTypeEmotionContainerView.addSubview(fullTypeEmotionTitleLabel) - fullTypeEmotionTitleLabel.snp.makeConstraints { - $0.centerY.equalTo(fullTypeEmotionImageView.snp.centerY) - $0.leading.equalTo(fullTypeEmotionImageView.snp.trailing).offset(8) - $0.trailing.equalTo(fullTypeEmotionContainerView.snp.trailing).offset(-8) - } } required init?(coder: NSCoder) { From 93367162f7995f722dfb188e53ea99ddf4cd2cdc Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 25 Jan 2023 17:03:16 +0900 Subject: [PATCH 22/23] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20=EB=B0=8F=20=EB=94=94=EC=9E=90=EC=9D=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive/Main/Community/CommunityReactor.swift | 4 +--- .../Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Archive/Main/Community/CommunityReactor.swift b/Archive/Main/Community/CommunityReactor.swift index b280feb..e052724 100644 --- a/Archive/Main/Community/CommunityReactor.swift +++ b/Archive/Main/Community/CommunityReactor.swift @@ -115,7 +115,6 @@ class CommunityReactor: Reactor, Stepper, MainTabStepperProtocol { ]) case .refreshPublicArchives: return Observable.concat([ - Observable.just(Mutation.setIsLoading(true)), getFirstPublicArchives(sortBy: self.archiveSortType, emotion: self.filterEmotion) .map { [weak self] result in switch result { @@ -125,8 +124,7 @@ class CommunityReactor: Reactor, Stepper, MainTabStepperProtocol { self?.err.onNext(err) return .empty } - }, - Observable.just(Mutation.setIsLoading(false)) + } ]) case .getMorePublicArchives: if !self.usecase.isQuerying && !self.usecase.isEndOfPage { diff --git a/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift b/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift index 2f2c93f..5b417d5 100644 --- a/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift +++ b/Archive/Main/MyPage/Sub/MyLikeList/MyLikeCollectionViewCell.swift @@ -242,7 +242,7 @@ class MyLikeCollectionViewCell: UICollectionViewCell, ClassIdentifiable { self.cardView.addSubview(self.emotionContainerView) self.emotionContainerView.snp.makeConstraints { - $0.bottom.trailing.equalTo(self.thumbnailImageView).offset(-4) + $0.bottom.trailing.equalTo(self.thumbnailImageView).offset(-12) } emotionContainerView.addSubview(emotionImageView) From 290cc0854d252ec07ca1c0108eba1f4153e1481a Mon Sep 17 00:00:00 2001 From: Hanwe Lee Date: Wed, 25 Jan 2023 17:04:42 +0900 Subject: [PATCH 23/23] =?UTF-8?q?=EB=B9=8C=EB=93=9C=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Archive.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Archive.xcodeproj/project.pbxproj b/Archive.xcodeproj/project.pbxproj index 035dcca..842a852 100644 --- a/Archive.xcodeproj/project.pbxproj +++ b/Archive.xcodeproj/project.pbxproj @@ -2094,7 +2094,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 38; + CURRENT_PROJECT_VERSION = 39; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -2174,7 +2174,7 @@ CODE_SIGN_ENTITLEMENTS = Archive/Archive.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 38; + CURRENT_PROJECT_VERSION = 39; DEVELOPMENT_TEAM = P4ZJYAK634; INFOPLIST_FILE = Archive/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0;