Skip to content
6 changes: 4 additions & 2 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public extension MainTabFeature {
/// - 포킷 `추가` 버튼 눌렀을 때
case .delegate(.포킷추가하기),
.path(.element(_, action: .링크추가및수정(.delegate(.포킷추가하기)))),
.pokit(.delegate(.포킷추가_버튼_눌렀을때)):
.pokit(.delegate(.포킷추가_버튼_눌렀을때)),
.recommend(.delegate(.포킷_추가하기_버튼_눌렀을때)):
state.path.append(.포킷추가및수정(PokitCategorySettingFeature.State(type: .추가)))
return .none

Expand Down Expand Up @@ -130,7 +131,6 @@ public extension MainTabFeature {
/// - 링크상세 바텀시트에서 링크수정으로 이동
case let .contentDetail(.presented(.delegate(.editButtonTapped(id)))),
let .pokit(.delegate(.링크수정하기(id))),
let .recommend(.delegate(.추가하기_버튼_눌렀을때(id))),
let .path(.element(_, action: .카테고리상세(.delegate(.링크수정(id))))),
let .path(.element(_, action: .링크목록(.delegate(.링크수정(id))))),
let .path(.element(_, action: .검색(.delegate(.링크수정(id))))),
Expand Down Expand Up @@ -193,6 +193,8 @@ public extension MainTabFeature {
default:
return .send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구))), animation: .pokitSpring)
}
case .recommend(.delegate(.저장하기_완료)):
return .send(.inner(.링크팝업_활성화(.success(title: Constants.링크_저장_완료_문구))), animation: .pokitSpring)
/// - 각 화면에서 링크 복사 감지했을 때 (링크 추가 및 수정 화면 제외)
case let .path(.element(_, action: .알림함(.delegate(.linkCopyDetected(url))))),
let .path(.element(_, action: .검색(.delegate(.linkCopyDetected(url))))),
Expand Down
2 changes: 1 addition & 1 deletion Projects/DSKit/Sources/Foundation/PokitButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension PokitButtonStyle.State {
red: 67 / 255,
green: 67 / 255,
blue: 67 / 255
).opacity(0.4)
).opacity(0.7)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Projects/DSKit/Sources/Foundation/PokitImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum PokitImage {
case .trash:
return DSKitAsset.iconTrash.swiftUIImage
case .plusR:
return DSKitAsset.iconPlus.swiftUIImage
return DSKitAsset.iconPlusR.swiftUIImage
case .remind:
return DSKitAsset.iconRemind.swiftUIImage
case .reminder:
Expand Down
9 changes: 9 additions & 0 deletions Projects/Domain/Sources/Recommend/Recommend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public struct Recommend: Equatable {
public var pageable: BasePageable
public var myInterests: [BaseInterest]
public var interests: [BaseInterest]
/// 카테고리(포킷) 리스트
public var categoryListInQuiry: BaseCategoryListInquiry

public init() {
self.contentList = .init(
Expand All @@ -28,5 +30,12 @@ public struct Recommend: Equatable {
)
self.myInterests = []
self.interests = []
self.categoryListInQuiry = BaseCategoryListInquiry(
data: [],
page: 0,
size: 0,
sort: [],
hasNext: false
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public extension PokitCategorySettingView {
action: { send(.키워드_선택_버튼_눌렀을때($0)) }
)
}
.ignoresSafeArea(.container, edges: .bottom)
.task { await send(.뷰가_나타났을때).finish() }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public struct RecommendFeature {
private var contentClient
@Dependency(UserClient.self)
private var userClient
@Dependency(CategoryClient.self)
private var categoryClient
@Dependency(\.openURL)
private var openURL
/// - State
Expand All @@ -43,13 +45,19 @@ public struct RecommendFeature {
array.append(contentsOf: domain.myInterests)
return array
}
var pokitList: [BaseCategoryItem]? {
get { domain.categoryListInQuiry.data }
}
var isLoading: Bool = true
var selectedInterest: BaseInterest?
var shareContent: BaseContentItem?
var interests: [BaseInterest] { domain.interests }
var showKeywordSheet: Bool = false
var selectedInterestList = Set<BaseInterest>()
var reportContent: BaseContentItem?
var showSelectSheet: Bool = false
var selectedPokit: BaseCategoryItem?
var addContent: BaseContentItem?
}

/// - Action
Expand Down Expand Up @@ -81,14 +89,17 @@ public struct RecommendFeature {
case 알림_버튼_눌렀을때
case 추천_컨텐츠_눌렀을때(String)
case 경고시트_dismiss
case 포킷선택_항목_눌렀을때(pokit: BaseCategoryItem)
case 포킷_추가하기_버튼_눌렀을때
}

public enum InnerAction: Equatable {
public enum InnerAction {
case 추천_조회_API_반영(BaseContentListInquiry)
case 추천_조회_페이징_API_반영(BaseContentListInquiry)
case 유저_관심사_조회_API_반영([BaseInterest])
case 관심사_조회_API_반영([BaseInterest])
case 컨텐츠_신고_API_반영(Int)
case 카테고리_목록_조회_API_반영(categoryList: BaseCategoryListInquiry)
}

public enum AsyncAction: Equatable {
Expand All @@ -97,15 +108,18 @@ public struct RecommendFeature {
case 유저_관심사_조회_API
case 관심사_조회_API
case 컨텐츠_신고_API(Int)
case 카테고리_목록_조회_API
case 컨텐츠_추가_API
}

public enum ScopeAction: Equatable { case doNothing }

public enum DelegateAction: Equatable {
case 추가하기_버튼_눌렀을때(Int)
case 저장하기_완료
case 검색_버튼_눌렀을때
case 알림_버튼_눌렀을때
case 컨텐츠_신고_API_반영
case 포킷_추가하기_버튼_눌렀을때
}
}

Expand Down Expand Up @@ -158,7 +172,9 @@ private extension RecommendFeature {
case .pagination:
return shared(.async(.추천_조회_페이징_API), state: &state)
case let .추가하기_버튼_눌렀을때(content):
return .send(.delegate(.추가하기_버튼_눌렀을때(content.id)))
state.addContent = content
state.showSelectSheet = true
return shared(.async(.카테고리_목록_조회_API), state: &state)
case let .공유하기_버튼_눌렀을때(content):
state.shareContent = content
return .none
Expand All @@ -170,6 +186,7 @@ private extension RecommendFeature {
return .none
case let .전체보기_버튼_눌렀을때(proxy):
guard state.selectedInterest != nil else { return .none }
state.domain.contentList.data = nil

state.selectedInterest = nil
let leading = 20 / UIScreen.main.bounds.width
Expand All @@ -178,19 +195,13 @@ private extension RecommendFeature {
y: UnitPoint.leading.y
)
proxy.scrollTo("전체보기", anchor: anchor)
state.domain.contentList.data = nil
return shared(.async(.추천_조회_API), state: &state)
case let .관심사_버튼_눌렀을때(interest, proxy):
guard state.selectedInterest != interest else { return .none }
state.domain.contentList.data = nil

state.selectedInterest = interest
let leading = 20 / UIScreen.main.bounds.width
let anchor = UnitPoint(
x: leading,
y: UnitPoint.leading.y
)
proxy.scrollTo(interest.description, anchor: anchor)
state.domain.contentList.data = nil
proxy.scrollTo(interest.description, anchor: .leading)
return shared(.async(.추천_조회_API), state: &state)
case .링크_공유_완료되었을때:
state.shareContent = nil
Expand All @@ -216,6 +227,13 @@ private extension RecommendFeature {
case .경고시트_dismiss:
state.reportContent = nil
return .none
case .포킷선택_항목_눌렀을때(pokit: let pokit):
state.selectedPokit = pokit
state.showSelectSheet = false
return shared(.async(.컨텐츠_추가_API), state: &state)
case .포킷_추가하기_버튼_눌렀을때:
state.showSelectSheet = false
return .send(.delegate(.포킷_추가하기_버튼_눌렀을때))
}
}

Expand Down Expand Up @@ -247,6 +265,30 @@ private extension RecommendFeature {
case let .컨텐츠_신고_API_반영(contentId):
state.domain.contentList.data?.removeAll(where: { $0.id == contentId })
return .send(.delegate(.컨텐츠_신고_API_반영))
case .카테고리_목록_조회_API_반영(categoryList: let categoryList):
/// - `카테고리_목록_조회`의 filter 옵션을 `false`로 해두었기 때문에 `미분류` 카테고리 또한 항목에서 조회가 가능함

/// [1]. `미분류`에 해당하는 인덱스 번호와 항목을 체크, 없다면 목록갱신이 불가함
guard
let unclassifiedItemIdx = categoryList.data?.firstIndex(where: {
$0.categoryName == "미분류"
})
else { return .none }
guard
let unclassifiedItem = categoryList.data?.first(where: {
$0.categoryName == "미분류"
})
else { return .none }

/// [2]. 새로운 list변수를 만들어주고 카테고리 항목 순서를 재배치 (최신순 정렬 시 미분류는 항상 맨 마지막)
var list = categoryList
list.data?.remove(at: unclassifiedItemIdx)
list.data?.insert(unclassifiedItem, at: 0)

/// [3]. 도메인 항목 리스트에 list 할당
state.domain.categoryListInQuiry = list
state.selectedPokit = unclassifiedItem
return .none
}
}

Expand Down Expand Up @@ -291,6 +333,33 @@ private extension RecommendFeature {
animation: .pokitSpring
)
}
case .카테고리_목록_조회_API:
let request = BasePageableRequest(
page: state.domain.pageable.page,
size: 30,
sort: state.domain.pageable.sort
)
return categoryListFetch(request: request)
case .컨텐츠_추가_API:
guard
let categoryId = state.selectedPokit?.id,
let category = state.domain.categoryListInQuiry.data?.first(where: {
$0.id == categoryId
}),
let content = state.addContent
else { return .none }
let request = ContentBaseRequest(
data: content.data,
title: content.title,
categoryId: categoryId,
memo: content.memo ?? "",
alertYn: "NO",
thumbNail: content.thumbNail
)
return .run { send in
let content = try await contentClient.컨텐츠_추가(request)
await send(.delegate(.저장하기_완료))
}
}
}

Expand Down Expand Up @@ -353,4 +422,11 @@ private extension RecommendFeature {
await send(.inner(.추천_조회_API_반영(contentItems)), animation: .pokitDissolve)
}
}

func categoryListFetch(request: BasePageableRequest) -> Effect<Action> {
return .run { send in
let categoryList = try await categoryClient.카테고리_목록_조회(request, false, true).toDomain()
await send(.inner(.카테고리_목록_조회_API_반영(categoryList: categoryList)), animation: .pokitDissolve)
}
}
Comment on lines +426 to +431
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public struct RecommendView: View {
public extension RecommendView {
var body: some View {
WithPerceptionTracking {
VStack(spacing: 10) {
VStack(spacing: 0) {
interestList
.background(.pokit(.bg(.base)))

list
}
.background(.pokit(.bg(.primary)))
.ignoresSafeArea(edges: .bottom)
.sheet(item: $store.shareContent) { content in
if let shareURL = URL(string: content.data) {
Expand Down Expand Up @@ -58,6 +60,20 @@ public extension RecommendView {
cancelAction: { send(.경고시트_dismiss) }
)
}
.sheet(isPresented: $store.showSelectSheet) {
PokitSelectSheet(
list: store.pokitList,
selectedItem: .constant(nil),
itemSelected: { item in
send(.포킷선택_항목_눌렀을때(pokit: item))
},
pokitAddAction: { send(.포킷_추가하기_버튼_눌렀을때) }
)
.presentationDragIndicator(.visible)
.pokitPresentationCornerRadius()
.presentationDetents([.height(564)])
.pokitPresentationBackground()
}
}
}
}
Expand Down Expand Up @@ -180,6 +196,7 @@ private extension RecommendView {
}
.padding(.horizontal, 20)
.padding(.bottom, 150)
.padding(.top, 12)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,6 @@ private extension PokitSearchView {

var resultList: some View {
VStack(alignment: .leading, spacing: 20) {
PokitIconLTextLink(
store.isResultAscending ? "오래된순" : "최신순",
icon: .icon(.align),
action: { send(.정렬_버튼_눌렀을때) }
)
.contentTransition(.numericText())
.padding(.horizontal, 20)

if !store.isLoading {
ScrollView {
LazyVStack(spacing: 0) {
Expand Down