diff --git a/Projects/App/Resources/Pokit-info.plist b/Projects/App/Resources/Pokit-info.plist index 7368d7ef..af5f75f4 100644 --- a/Projects/App/Resources/Pokit-info.plist +++ b/Projects/App/Resources/Pokit-info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.3 + 1.0.4 CFBundleURLTypes diff --git a/Projects/App/Sources/MainTab/MainTabFeatureView.swift b/Projects/App/Sources/MainTab/MainTabFeatureView.swift index 5fcc9cee..58d51b7e 100644 --- a/Projects/App/Sources/MainTab/MainTabFeatureView.swift +++ b/Projects/App/Sources/MainTab/MainTabFeatureView.swift @@ -185,11 +185,11 @@ private extension MainTabView { PokitHeaderItems(placement: .trailing) { PokitToolbarButton( .icon(.search), - action: { store.send(.remind(.view(.searchButtonTapped))) } + action: { store.send(.remind(.view(.검색_버튼_눌렀을때))) } ) PokitToolbarButton( .icon(.bell), - action: { store.send(.remind(.view(.bellButtonTapped))) } + action: { store.send(.remind(.view(.알림_버튼_눌렀을때))) } ) } } diff --git a/Projects/App/Sources/MainTab/MainTabPath.swift b/Projects/App/Sources/MainTab/MainTabPath.swift index d8bea9c7..d61bc262 100644 --- a/Projects/App/Sources/MainTab/MainTabPath.swift +++ b/Projects/App/Sources/MainTab/MainTabPath.swift @@ -145,7 +145,7 @@ public extension MainTabFeature { case .pokit: return .send(.pokit(.delegate(.미분류_카테고리_컨텐츠_조회))) case .remind: - return .send(.remind(.delegate(.컨텐츠목록_조회))) + return .send(.remind(.delegate(.컨텐츠_상세보기_delegate_위임))) } } switch lastPath { diff --git a/Projects/Feature/FeatureRemind/Sources/Remind/RemindFeature.swift b/Projects/Feature/FeatureRemind/Sources/Remind/RemindFeature.swift index 72f34f6f..15e31412 100644 --- a/Projects/Feature/FeatureRemind/Sources/Remind/RemindFeature.swift +++ b/Projects/Feature/FeatureRemind/Sources/Remind/RemindFeature.swift @@ -4,6 +4,8 @@ // // Created by 김도형 on 7/12/24. +import SwiftUI + import ComposableArchitecture import Domain import CoreKit @@ -65,35 +67,36 @@ public struct RemindFeature { public enum View: Equatable, BindableAction { case binding(BindingAction) - /// - Button Tapped - case bellButtonTapped - case searchButtonTapped - case linkCardTapped(content: BaseContentItem) - case kebabButtonTapped(content: BaseContentItem) - case unreadNavigationLinkTapped - case favoriteNavigationLinkTapped - case bottomSheetButtonTapped( + case bottomSheet( delegate: PokitBottomSheet.Delegate, content: BaseContentItem ) - case deleteAlertConfirmTapped(content: BaseContentItem) + + /// - Button Tapped + case 알림_버튼_눌렀을때 + case 검색_버튼_눌렀을때 + case 컨텐츠_항목_눌렀을때(content: BaseContentItem) + case 컨텐츠_항목_케밥_버튼_눌렀을때(content: BaseContentItem) + case 안읽음_목록_버튼_눌렀을때 + case 즐겨찾기_목록_버튼_눌렀을때 + case 링크_삭제_눌렀을때(content: BaseContentItem) case 링크_공유_완료 - case remindViewOnAppeared + case 뷰가_나타났을때 } public enum InnerAction: Equatable { - case dismissBottomSheet - case 오늘의_리마인드_조회(contents: [BaseContentItem]) - case 읽지않음_컨텐츠_조회(contentList: BaseContentListInquiry) - case 즐겨찾기_링크모음_조회(contentList: BaseContentListInquiry) - case 컨텐츠_삭제_반영(id: Int) + case 바텀시트_해제 + case 오늘의_리마인드_조회_API_반영(contents: [BaseContentItem]) + case 읽지않음_컨텐츠_조회_API_반영(contentList: BaseContentListInquiry) + case 즐겨찾기_링크모음_조회_API_반영(contentList: BaseContentListInquiry) + case 컨텐츠_삭제_API_반영(id: Int) } public enum AsyncAction: Equatable { - case 오늘의_리마인드_조회 - case 읽지않음_컨텐츠_조회 - case 즐겨찾기_링크모음_조회 - case 컨텐츠_삭제(id: Int) + case 오늘의_리마인드_조회_API + case 읽지않음_컨텐츠_조회_API + case 즐겨찾기_링크모음_조회_API + case 컨텐츠_삭제_API(id: Int) } public enum ScopeAction: Equatable { case bottomSheet( @@ -108,7 +111,7 @@ public struct RemindFeature { case 링크수정(id: Int) case 링크목록_안읽음 case 링크목록_즐겨찾기 - case 컨텐츠목록_조회 + case 컨텐츠_상세보기_delegate_위임 } } /// initiallizer @@ -144,37 +147,31 @@ private extension RemindFeature { /// - View Effect func handleViewAction(_ action: Action.View, state: inout State) -> Effect { switch action { - case .bellButtonTapped: - return .run { send in await send(.delegate(.alertButtonTapped)) } - case .searchButtonTapped: - return .run { send in await send(.delegate(.searchButtonTapped)) } - case .favoriteNavigationLinkTapped: + case .binding: + return .none + case .bottomSheet(let delegate, let content): + return .run { send in + await send(.inner(.바텀시트_해제)) + await send(.scope(.bottomSheet(delegate: delegate, content: content))) + } + case .알림_버튼_눌렀을때: + return .send(.delegate(.alertButtonTapped)) + case .검색_버튼_눌렀을때: + return .send(.delegate(.searchButtonTapped)) + case .즐겨찾기_목록_버튼_눌렀을때: return .send(.delegate(.링크목록_즐겨찾기)) - case .unreadNavigationLinkTapped: + case .안읽음_목록_버튼_눌렀을때: return .send(.delegate(.링크목록_안읽음)) - case .kebabButtonTapped(let content): + case .컨텐츠_항목_케밥_버튼_눌렀을때(let content): state.bottomSheetItem = content return .none - case .linkCardTapped(let content): + case .컨텐츠_항목_눌렀을때(let content): return .send(.delegate(.링크상세(content: content))) - case .bottomSheetButtonTapped(let delegate, let content): - return .run { send in - await send(.inner(.dismissBottomSheet)) - await send(.scope(.bottomSheet(delegate: delegate, content: content))) - } - case .deleteAlertConfirmTapped: + case .링크_삭제_눌렀을때: guard let id = state.alertItem?.id else { return .none } - return .run { [id] send in - await send(.async(.컨텐츠_삭제(id: id))) - } - case .binding: - return .none - case .remindViewOnAppeared: - return .run { send in - await send(.async(.오늘의_리마인드_조회), animation: .pokitDissolve) - await send(.async(.읽지않음_컨텐츠_조회), animation: .pokitDissolve) - await send(.async(.즐겨찾기_링크모음_조회), animation: .pokitDissolve) - } + return .send(.async(.컨텐츠_삭제_API(id: id))) + case .뷰가_나타났을때: + return allContentFetch(animation: .pokitDissolve) case .링크_공유_완료: state.shareSheetItem = nil return .none @@ -183,19 +180,19 @@ private extension RemindFeature { /// - Inner Effect func handleInnerAction(_ action: Action.InnerAction, state: inout State) -> Effect { switch action { - case .dismissBottomSheet: + case .바텀시트_해제: state.bottomSheetItem = nil return .none - case .오늘의_리마인드_조회(contents: let contents): + case .오늘의_리마인드_조회_API_반영(contents: let contents): state.domain.recommendedList = contents return .none - case .읽지않음_컨텐츠_조회(contentList: let contentList): + case .읽지않음_컨텐츠_조회_API_반영(contentList: let contentList): state.domain.unreadList = contentList return .none - case .즐겨찾기_링크모음_조회(contentList: let contentList): + case .즐겨찾기_링크모음_조회_API_반영(contentList: let contentList): state.domain.favoriteList = contentList return .none - case .컨텐츠_삭제_반영(id: let contentId): + case .컨텐츠_삭제_API_반영(id: let contentId): state.alertItem = nil state.domain.recommendedList?.removeAll { $0.id == contentId } state.domain.unreadList.data?.removeAll { $0.id == contentId } @@ -206,12 +203,12 @@ private extension RemindFeature { /// - Async Effect func handleAsyncAction(_ action: Action.AsyncAction, state: inout State) -> Effect { switch action { - case .오늘의_리마인드_조회: + case .오늘의_리마인드_조회_API: return .run { send in let contents = try await remindClient.오늘의_리마인드_조회().map { $0.toDomain() } - await send(.inner(.오늘의_리마인드_조회(contents: contents)), animation: .pokitDissolve) + await send(.inner(.오늘의_리마인드_조회_API_반영(contents: contents)), animation: .pokitDissolve) } - case .읽지않음_컨텐츠_조회: + case .읽지않음_컨텐츠_조회_API: return .run { [pageable = state.domain.unreadListPageable] send in let contentList = try await remindClient.읽지않음_컨텐츠_조회( BasePageableRequest( @@ -220,9 +217,9 @@ private extension RemindFeature { sort: pageable.sort ) ).toDomain() - await send(.inner(.읽지않음_컨텐츠_조회(contentList: contentList)), animation: .pokitDissolve) + await send(.inner(.읽지않음_컨텐츠_조회_API_반영(contentList: contentList)), animation: .pokitDissolve) } - case .즐겨찾기_링크모음_조회: + case .즐겨찾기_링크모음_조회_API: return .run { [pageable = state.domain.favoriteListPageable] send in let contentList = try await remindClient.즐겨찾기_링크모음_조회( BasePageableRequest( @@ -231,12 +228,12 @@ private extension RemindFeature { sort: pageable.sort ) ).toDomain() - await send(.inner(.즐겨찾기_링크모음_조회(contentList: contentList)), animation: .pokitDissolve) + await send(.inner(.즐겨찾기_링크모음_조회_API_반영(contentList: contentList)), animation: .pokitDissolve) } - case .컨텐츠_삭제(id: let id): - return .run { [id] send in + case .컨텐츠_삭제_API(id: let id): + return .run { send in let _ = try await contentClient.컨텐츠_삭제("\(id)") - await send(.inner(.컨텐츠_삭제_반영(id: id)), animation: .pokitSpring) + await send(.inner(.컨텐츠_삭제_API_반영(id: id)), animation: .pokitSpring) } } } @@ -262,13 +259,17 @@ private extension RemindFeature { /// - Delegate Effect func handleDelegateAction(_ action: Action.DelegateAction, state: inout State) -> Effect { switch action { - case .컨텐츠목록_조회: - return .run { send in - await send(.async(.오늘의_리마인드_조회)) - await send(.async(.읽지않음_컨텐츠_조회)) - await send(.async(.즐겨찾기_링크모음_조회)) - } + case .컨텐츠_상세보기_delegate_위임: + return allContentFetch() default: return .none } } + + func allContentFetch(animation: Animation? = nil) -> Effect { + return .run { send in + await send(.async(.오늘의_리마인드_조회_API), animation: animation) + await send(.async(.읽지않음_컨텐츠_조회_API), animation: animation) + await send(.async(.즐겨찾기_링크모음_조회_API), animation: animation) + } + } } diff --git a/Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift b/Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift index 6f78327d..de321408 100644 --- a/Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift +++ b/Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift @@ -35,7 +35,7 @@ public extension RemindView { PokitBottomSheet( items: [.share, .edit, .delete], height: 224 - ) { send(.bottomSheetButtonTapped(delegate: $0, content: content)) } + ) { send(.bottomSheet(delegate: $0, content: content)) } } .sheet(item: $store.shareSheetItem) { content in if let shareURL = URL(string: content.data) { @@ -51,9 +51,9 @@ public extension RemindView { "링크를 정말 삭제하시겠습니까?", message: "함께 저장한 모든 정보가 삭제되며, \n복구하실 수 없습니다.", confirmText: "삭제" - ) { send(.deleteAlertConfirmTapped(content: content)) } + ) { send(.링크_삭제_눌렀을때(content: content)) } } - .task { await send(.remindViewOnAppeared, animation: .pokitDissolve).finish() } + .task { await send(.뷰가_나타났을때, animation: .pokitDissolve).finish() } } } } @@ -134,7 +134,7 @@ extension RemindView { @ViewBuilder private func recommendedContentCell(content: BaseContentItem) -> some View { - Button(action: { send(.linkCardTapped(content: content)) }) { + Button(action: { send(.컨텐츠_항목_눌렀을때(content: content)) }) { recommendedContentCellLabel(content: content) } @@ -186,7 +186,7 @@ extension RemindView { Spacer() kebabButton { - send(.kebabButtonTapped(content: content)) + send(.컨텐츠_항목_케밥_버튼_눌렀을때(content: content)) } .foregroundStyle(.pokit(.icon(.inverseWh))) .zIndex(1) @@ -243,7 +243,7 @@ extension RemindView { VStack(spacing: 0) { VStack(spacing: 0) { listNavigationLink("한번도 읽지 않았어요") { - send(.unreadNavigationLinkTapped) + send(.안읽음_목록_버튼_눌렀을때) } .padding(.bottom, 16) } @@ -254,8 +254,8 @@ extension RemindView { PokitLinkCard( link: content, - action: { send(.linkCardTapped(content: content)) }, - kebabAction: { send(.kebabButtonTapped(content: content)) } + action: { send(.컨텐츠_항목_눌렀을때(content: content)) }, + kebabAction: { send(.컨텐츠_항목_케밥_버튼_눌렀을때(content: content)) } ) .divider(isFirst: isFirst, isLast: isLast) } @@ -270,7 +270,7 @@ extension RemindView { ) -> some View { VStack(spacing: 0) { listNavigationLink("즐겨찾기 링크만 모았어요") { - send(.favoriteNavigationLinkTapped) + send(.즐겨찾기_목록_버튼_눌렀을때) } .padding(.bottom, 16) @@ -288,8 +288,8 @@ extension RemindView { PokitLinkCard( link: content, - action: { send(.linkCardTapped(content: content)) }, - kebabAction: { send(.kebabButtonTapped(content: content)) } + action: { send(.컨텐츠_항목_눌렀을때(content: content)) }, + kebabAction: { send(.컨텐츠_항목_케밥_버튼_눌렀을때(content: content)) } ) .divider(isFirst: isFirst, isLast: isLast) }