Skip to content

Commit

Permalink
[feat] #157 리마인드에서 링크 상세 플로우 변경사항 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Nov 30, 2024
1 parent bb8974c commit 1cb5ff9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 84 deletions.
65 changes: 3 additions & 62 deletions Projects/Feature/FeatureRemind/Sources/Remind/RemindFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public struct RemindFeature {
favoriteList.forEach { identifiedArray.append($0) }
return identifiedArray
}
/// sheet item
var bottomSheetItem: BaseContentItem? = nil
var alertItem: BaseContentItem? = nil
var shareSheetItem: BaseContentItem? = nil
}
/// - Action
public enum Action: FeatureAction, ViewAction {
Expand All @@ -68,10 +64,6 @@ public struct RemindFeature {

public enum View: Equatable, BindableAction {
case binding(BindingAction<State>)
case bottomSheet(
delegate: PokitBottomSheet.Delegate,
content: BaseContentItem
)

/// - Button Tapped
case 알림_버튼_눌렀을때
Expand All @@ -80,41 +72,30 @@ public struct RemindFeature {
case 컨텐츠_항목_케밥_버튼_눌렀을때(content: BaseContentItem)
case 안읽음_목록_버튼_눌렀을때
case 즐겨찾기_목록_버튼_눌렀을때
case 링크_삭제_눌렀을때(content: BaseContentItem)

case 링크_공유_완료

case 뷰가_나타났을때
case 즐겨찾기_항목_이미지_조회(contentId: Int)
case 읽지않음_항목_이미지_조회(contentId: Int)
case 리마인드_항목_이미지오류_나타났을때(contentId: Int)
}
public enum InnerAction: Equatable {
case 바텀시트_해제
case 오늘의_리마인드_조회_API_반영(contents: [BaseContentItem])
case 읽지않음_컨텐츠_조회_API_반영(contentList: BaseContentListInquiry)
case 즐겨찾기_링크모음_조회_API_반영(contentList: BaseContentListInquiry)
case 즐겨찾기_이미지_조회_수행_반영(imageURL: String, index: Int)
case 읽지않음_이미지_조회_수행_반영(imageURL: String, index: Int)
case 리마인드_이미지_조회_수행_반영(imageURL: String, index: Int)
case 컨텐츠_삭제_API_반영(id: Int)

}
public enum AsyncAction: Equatable {
case 오늘의_리마인드_조회_API
case 읽지않음_컨텐츠_조회_API
case 즐겨찾기_링크모음_조회_API
case 컨텐츠_삭제_API(id: Int)
case 즐겨찾기_이미지_조회_수행(contentId: Int)
case 읽지않음_이미지_조회_수행(contentId: Int)
case 리마인드_이미지_조회_수행(contentId: Int)
}
public enum ScopeAction: Equatable {
case bottomSheet(
delegate: PokitBottomSheet.Delegate,
content: BaseContentItem
)
}
public enum ScopeAction: Equatable { case 없음 }
public enum DelegateAction: Equatable {
case 링크상세(content: BaseContentItem)
case alertButtonTapped
Expand Down Expand Up @@ -160,11 +141,6 @@ private extension RemindFeature {
switch action {
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 .검색_버튼_눌렀을때:
Expand All @@ -174,18 +150,11 @@ private extension RemindFeature {
case .안읽음_목록_버튼_눌렀을때:
return .send(.delegate(.링크목록_안읽음))
case .컨텐츠_항목_케밥_버튼_눌렀을때(let content):
state.bottomSheetItem = content
return .none
return .send(.delegate(.링크상세(content: content)))
case .컨텐츠_항목_눌렀을때(let content):
return .send(.delegate(.링크상세(content: content)))
case .링크_삭제_눌렀을때:
guard let id = state.alertItem?.id else { return .none }
return .send(.async(.컨텐츠_삭제_API(id: id)))
case .뷰가_나타났을때:
return allContentFetch(animation: .pokitDissolve)
case .링크_공유_완료:
state.shareSheetItem = nil
return .none
case let .즐겨찾기_항목_이미지_조회(contentId):
return .send(.async(.즐겨찾기_이미지_조회_수행(contentId: contentId)))
case let .읽지않음_항목_이미지_조회(contentId):
Expand All @@ -197,9 +166,6 @@ private extension RemindFeature {
/// - Inner Effect
func handleInnerAction(_ action: Action.InnerAction, state: inout State) -> Effect<Action> {
switch action {
case .바텀시트_해제:
state.bottomSheetItem = nil
return .none
case .오늘의_리마인드_조회_API_반영(contents: let contents):
state.domain.recommendedList = contents
return .none
Expand All @@ -209,12 +175,6 @@ private extension RemindFeature {
case .즐겨찾기_링크모음_조회_API_반영(contentList: let contentList):
state.domain.favoriteList = contentList
return .none
case .컨텐츠_삭제_API_반영(id: let contentId):
state.alertItem = nil
state.domain.recommendedList?.removeAll { $0.id == contentId }
state.domain.unreadList.data?.removeAll { $0.id == contentId }
state.domain.favoriteList.data?.removeAll { $0.id == contentId }
return .none
case let .즐겨찾기_이미지_조회_수행_반영(imageURL, index):
var content = state.domain.favoriteList.data?.remove(at: index)
content?.thumbNail = imageURL
Expand Down Expand Up @@ -265,11 +225,6 @@ private extension RemindFeature {
).toDomain()
await send(.inner(.즐겨찾기_링크모음_조회_API_반영(contentList: contentList)), animation: .pokitDissolve)
}
case .컨텐츠_삭제_API(id: let id):
return .run { send in
let _ = try await contentClient.컨텐츠_삭제("\(id)")
await send(.inner(.컨텐츠_삭제_API_반영(id: id)), animation: .pokitSpring)
}
case let .즐겨찾기_이미지_조회_수행(contentId):
return .run { [favoriteContents = state.favoriteContents] send in
guard let index = favoriteContents?.index(id: contentId),
Expand Down Expand Up @@ -321,21 +276,7 @@ private extension RemindFeature {
/// - Scope Effect
func handleScopeAction(_ action: Action.ScopeAction, state: inout State) -> Effect<Action> {
/// - 링크에 대한 `공유` / `수정` / `삭제` delegate
switch action {
case .bottomSheet(let delegate, let content):
switch delegate {
case .deleteCellButtonTapped:
state.alertItem = content
return .none
case .editCellButtonTapped:
return .send(.delegate(.링크수정(id: content.id)))
case .favoriteCellButtonTapped:
return .none
case .shareCellButtonTapped:
state.shareSheetItem = content
return .none
}
}
return .none
}
/// - Delegate Effect
func handleDelegateAction(_ action: Action.DelegateAction, state: inout State) -> Effect<Action> {
Expand Down
22 changes: 0 additions & 22 deletions Projects/Feature/FeatureRemind/Sources/Remind/RemindView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,6 @@ public extension RemindView {
.background(.pokit(.bg(.base)))
.ignoresSafeArea(edges: .bottom)
.navigationBarBackButtonHidden(true)
.sheet(item: $store.bottomSheetItem) { content in
PokitBottomSheet(
items: [.share, .edit, .delete],
height: 224
) { send(.bottomSheet(delegate: $0, content: content)) }
}
.sheet(item: $store.shareSheetItem) { content in
if let shareURL = URL(string: content.data) {
PokitShareSheet(
items: [shareURL],
completion: { send(.링크_공유_완료) }
)
.presentationDetents([.medium, .large])
}
}
.sheet(item: $store.alertItem) { content in
PokitAlert(
"링크를 정말 삭제하시겠습니까?",
message: "함께 저장한 모든 정보가 삭제되며, \n복구하실 수 없습니다.",
confirmText: "삭제"
) { send(.링크_삭제_눌렀을때(content: content)) }
}
.task { await send(.뷰가_나타났을때, animation: .pokitDissolve).finish() }
}
}
Expand Down

0 comments on commit 1cb5ff9

Please sign in to comment.