Skip to content

Commit

Permalink
Merge pull request #189 from YAPP-Github/feat/#183-pokit-detail
Browse files Browse the repository at this point in the history
feat: [2.0.0] ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ์— ๋”ฐ๋ฅธ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ ๋ฐ ์ˆ˜์ •(์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์„ธ)
  • Loading branch information
stealmh authored Feb 4, 2025
2 parents 9aca4aa + dc6a8d5 commit 842a4a9
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 73 deletions.
5 changes: 5 additions & 0 deletions Projects/App/Sources/MainTab/MainTabPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ public extension MainTabFeature {
state.path.append(.๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •(ContentSettingFeature.State(urlText: state.link)))
state.link = nil
return .none

case let .path(.element(_, action: .์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ(.delegate(.๋งํฌ์ถ”๊ฐ€(categoryId))))):
state.categoryId = categoryId
state.path.append(.๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •(ContentSettingFeature.State()))
return .none

/// - ๋งํฌ์ถ”๊ฐ€ ๋ฐ ์ˆ˜์ •์—์„œ ์ €์žฅํ•˜๊ธฐ ๋ˆŒ๋ €์„ ๋•Œ
case let .path(.element(stackElementId, action: .๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •(.delegate(.์ €์žฅํ•˜๊ธฐ_์™„๋ฃŒ(contentId))))):
Expand Down
30 changes: 28 additions & 2 deletions Projects/DSKit/Sources/Components/PokitBottomSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import SwiftUI

public struct PokitBottomSheet: View {
@State
private var height: CGFloat
private let items: [Item]
private let height: CGFloat
private let delegateSend: ((PokitBottomSheet.Delegate) -> Void)?

public init(
items: [Item],
height: CGFloat,
height: CGFloat = 0,
delegateSend: ((PokitBottomSheet.Delegate) -> Void)?
) {
self.items = items
Expand All @@ -30,6 +31,16 @@ public struct PokitBottomSheet: View {
.presentationDetents([.height(height)])
.pokitPresentationCornerRadius()
.pokitPresentationBackground()
.readHeight()
.onPreferenceChange(HeightPreferenceKey.self) { height in
if let height {
print("height:", height)
self.height = height
}
}
.ignoresSafeArea(.all)
.padding(.top, 12)
.padding(.bottom, -20)
}

@ViewBuilder
Expand Down Expand Up @@ -120,3 +131,18 @@ public extension PokitBottomSheet {
}
}

@available(iOS 18.0, *)
#Preview {
@Previewable
@State var isPresented: Bool = true

ZStack {
Color.green.ignoresSafeArea()
}
.sheet(isPresented: $isPresented) {
PokitBottomSheet(
items: [.share, .edit, .delete],
delegateSend: { _ in }
)
}
}
12 changes: 8 additions & 4 deletions Projects/DSKit/Sources/Components/PokitCaution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import SwiftUI
public enum CautionType {
case ์นดํ…Œ๊ณ ๋ฆฌ์—†์Œ
case ๋ฏธ๋ถ„๋ฅ˜_๋งํฌ์—†์Œ
case ํฌํ‚ท์ƒ์„ธ_๋งํฌ์—†์Œ
case ๋งํฌ์—†์Œ
case ์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์—†์Œ
case ๋งํฌ๋ถ€์กฑ
case ์•Œ๋ฆผ์—†์Œ

var image: PokitImage.Character {
switch self {
case .์นดํ…Œ๊ณ ๋ฆฌ์—†์Œ, .๋งํฌ์—†์Œ, .์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์—†์Œ, .๋ฏธ๋ถ„๋ฅ˜_๋งํฌ์—†์Œ:
return .empty
case .๋งํฌ๋ถ€์กฑ:
return .sad

case .์•Œ๋ฆผ์—†์Œ:
return .pooki

default: return .empty
}
}

Expand All @@ -32,7 +34,7 @@ public enum CautionType {
return "์ €์žฅ๋œ ํฌํ‚ท์ด ์—†์–ด์š”!"
case .๋ฏธ๋ถ„๋ฅ˜_๋งํฌ์—†์Œ:
return "๋ฏธ๋ถ„๋ฅ˜ ๋งํฌ๊ฐ€ ์—†์–ด์š”!"
case .๋งํฌ์—†์Œ:
case .๋งํฌ์—†์Œ, .ํฌํ‚ท์ƒ์„ธ_๋งํฌ์—†์Œ:
return "์ €์žฅ๋œ ๋งํฌ๊ฐ€ ์—†์–ด์š”!"
case .์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์—†์Œ:
return "์ฆ๊ฒจ์ฐพ๊ธฐ ๋งํฌ๊ฐ€ ์—†์–ด์š”!"
Expand All @@ -49,6 +51,8 @@ public enum CautionType {
return "ํฌํ‚ท์„ ์ƒ์„ฑํ•ด ๋งํฌ๋ฅผ ์ €์žฅํ•ด๋ณด์„ธ์š”"
case .๋ฏธ๋ถ„๋ฅ˜_๋งํฌ์—†์Œ:
return "๋งํฌ๋ฅผ ํฌํ‚ท์— ๊น”๋”ํ•˜๊ฒŒ ๋ถ„๋ฅ˜ํ•˜์…จ์–ด์š”"
case .ํฌํ‚ท์ƒ์„ธ_๋งํฌ์—†์Œ:
return "ํฌํ‚ท์— ๋งํฌ๋ฅผ ์ €์žฅํ•ด๋ณด์„ธ์š”"
case .๋งํฌ์—†์Œ:
return "๋‹ค์–‘ํ•œ ๋งํฌ๋ฅผ ํ•œ ๊ณณ์— ์ €์žฅํ•ด๋ณด์„ธ์š”"
case .์ฆ๊ฒจ์ฐพ๊ธฐ_๋งํฌ์—†์Œ:
Expand All @@ -64,7 +68,7 @@ public enum CautionType {
switch self {
case .์นดํ…Œ๊ณ ๋ฆฌ์—†์Œ:
return "ํฌํ‚ท ์ถ”๊ฐ€ํ•˜๊ธฐ"
case .๋ฏธ๋ถ„๋ฅ˜_๋งํฌ์—†์Œ:
case .๋ฏธ๋ถ„๋ฅ˜_๋งํฌ์—†์Œ, .ํฌํ‚ท์ƒ์„ธ_๋งํฌ์—†์Œ:
return "๋งํฌ ์ถ”๊ฐ€ํ•˜๊ธฐ"
default: return nil
}
Expand Down
44 changes: 44 additions & 0 deletions Projects/DSKit/Sources/Modifiers/PokitFloatButtonModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// PokitFloatButtonModifier.swift
// DSKit
//
// Created by ๊น€๋ฏผํ˜ธ on 1/16/25.
//
import SwiftUI

private struct PokitFloatButtonModifier: ViewModifier {
let action: () -> Void

func body(content: Content) -> some View {
content
.overlay(alignment: .bottomTrailing) {
Button(action: action) {
Image(.icon(.plus))
.resizable()
.frame(width: 36, height: 36)
.padding(12)
.foregroundStyle(.pokit(.icon(.inverseWh)))
.background {
RoundedRectangle(cornerRadius: 9999, style: .continuous)
.fill(.pokit(.bg(.brand)))
}
.frame(width: 60, height: 60)
}
.padding(.trailing, 20)
.padding(.bottom, 39)
}
}
}

public extension View {
func pokitFloatButton(action: @escaping () -> Void) -> some View {
return self.modifier(PokitFloatButtonModifier(action: action))
}
}

#Preview {
ZStack {
Color.black.ignoresSafeArea()
.pokitFloatButton(action: {})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public struct CategoryDetailFeature {
var isFavoriteFiltered: Bool {
get { domain.condition.isFavoriteFlitered }
}
var isFavoriteCategory: Bool {
get { domain.category.isFavorite }
}

var sortType: SortType = .์ตœ์‹ ์ˆœ
var categories: IdentifiedArrayOf<BaseCategoryItem>? {
Expand All @@ -57,7 +60,6 @@ public struct CategoryDetailFeature {
var isCategorySheetPresented: Bool = false
var isCategorySelectSheetPresented: Bool = false
var isPokitDeleteSheetPresented: Bool = false
var isFilterSheetPresented: Bool = false
/// pagenation
var hasNext: Bool {
domain.contentList.hasNext
Expand All @@ -83,11 +85,16 @@ public struct CategoryDetailFeature {
case binding(BindingAction<State>)
case dismiss
case pagenation

/// ์ฆ๊ฒจ์ฐพ๊ธฐ or ์•ˆ์ฝ์Œ ๋ฒ„ํŠผ ๋ˆŒ๋ €์„ ๋•Œ
case ๋ถ„๋ฅ˜_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ(SortCollectType)
case ์ •๋ ฌ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ๊ณต์œ _๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ์นดํ…Œ๊ณ ๋ฆฌ_์ผ€๋ฐฅ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ์นดํ…Œ๊ณ ๋ฆฌ_์„ ํƒ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ์นดํ…Œ๊ณ ๋ฆฌ_์„ ํƒํ–ˆ์„๋•Œ(BaseCategoryItem)
case ํ•„ํ„ฐ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ๋ทฐ๊ฐ€_๋‚˜ํƒ€๋‚ฌ์„๋•Œ
case ๋งํฌ_์ถ”๊ฐ€_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
}

public enum InnerAction: Equatable {
Expand All @@ -111,14 +118,14 @@ public struct CategoryDetailFeature {
public enum ScopeAction {
case categoryBottomSheet(PokitBottomSheet.Delegate)
case categoryDeleteBottomSheet(PokitDeleteBottomSheet.Delegate)
case filterBottomSheet(CategoryFilterSheet.Delegate)
case contents(IdentifiedActionOf<ContentCardFeature>)
}

public enum DelegateAction: Equatable {
case contentItemTapped(BaseContentItem)
case linkCopyDetected(URL?)
case ๋งํฌ์ˆ˜์ •(contentId: Int)
case ๋งํฌ์ถ”๊ฐ€(categoryId: Int)
case ํฌํ‚ท์‚ญ์ œ
case ํฌํ‚ท์ˆ˜์ •(BaseCategoryItem)
case ํฌํ‚ท๊ณต์œ 
Expand Down Expand Up @@ -174,6 +181,45 @@ private extension CategoryDetailFeature {
case .binding:
return .none

case .์ •๋ ฌ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
state.sortType = state.sortType == .์ตœ์‹ ์ˆœ
? .์˜ค๋ž˜๋œ์ˆœ
: .์ตœ์‹ ์ˆœ

state.domain.pageable.sort = [
state.sortType == .์ตœ์‹ ์ˆœ ? "createdAt,desc" : "createdAt,asc"
]

return .concatenate(
.send(.inner(.pagenation_์ดˆ๊ธฐํ™”), animation: .pokitDissolve),
.send(.async(.์นดํ…Œ๊ณ ๋ฆฌ_๋‚ด_์ปจํ…์ธ _๋ชฉ๋ก_์กฐํšŒ_API))
)

case let .๋ถ„๋ฅ˜_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ(type):
if type == .์ฆ๊ฒจ์ฐพ๊ธฐ {
state.domain.condition.isFavoriteFlitered.toggle()
} else {
state.domain.condition.isUnreadFlitered.toggle()
}
return .concatenate(
.send(.inner(.pagenation_์ดˆ๊ธฐํ™”), animation: .pokitDissolve),
.send(.async(.์นดํ…Œ๊ณ ๋ฆฌ_๋‚ด_์ปจํ…์ธ _๋ชฉ๋ก_์กฐํšŒ_API))
)

case .๊ณต์œ _๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
kakaoShareClient.์นดํ…Œ๊ณ ๋ฆฌ_์นด์นด์˜คํ†ก_๊ณต์œ (
CategoryKaKaoShareModel(
categoryName: state.domain.category.categoryName,
categoryId: state.domain.category.id,
imageURL: state.domain.category.categoryImage.imageURL
)
)
return .none

case .๋งํฌ_์ถ”๊ฐ€_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
let id = state.category.id
return .send(.delegate(.๋งํฌ์ถ”๊ฐ€(categoryId: id)))

case .์นดํ…Œ๊ณ ๋ฆฌ_์ผ€๋ฐฅ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
return .run { send in await send(.inner(.์นดํ…Œ๊ณ ๋ฆฌ_์‹œํŠธ_ํ™œ์„ฑํ™”(true))) }

Expand All @@ -188,10 +234,6 @@ private extension CategoryDetailFeature {
await send(.inner(.์นดํ…Œ๊ณ ๋ฆฌ_์„ ํƒ_์‹œํŠธ_ํ™œ์„ฑํ™”(false)))
}

case .ํ•„ํ„ฐ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
state.isFilterSheetPresented.toggle()
return .none

case .dismiss:
return .run { _ in await dismiss() }

Expand Down Expand Up @@ -347,16 +389,6 @@ private extension CategoryDetailFeature {
/// - ์นดํ…Œ๊ณ ๋ฆฌ์— ๋Œ€ํ•œ `๊ณต์œ ` / `์ˆ˜์ •` / `์‚ญ์ œ` Delegate
case .categoryBottomSheet(let delegateAction):
switch delegateAction {
case .shareCellButtonTapped:
kakaoShareClient.์นดํ…Œ๊ณ ๋ฆฌ_์นด์นด์˜คํ†ก_๊ณต์œ (
CategoryKaKaoShareModel(
categoryName: state.domain.category.categoryName,
categoryId: state.domain.category.id,
imageURL: state.domain.category.categoryImage.imageURL
)
)
state.isCategorySheetPresented = false
return .none
case .editCellButtonTapped:
return .run { [category = state.category] send in
await send(.inner(.์นดํ…Œ๊ณ ๋ฆฌ_์‹œํŠธ_ํ™œ์„ฑํ™”(false)))
Expand Down Expand Up @@ -384,25 +416,6 @@ private extension CategoryDetailFeature {
try await categoryClient.์นดํ…Œ๊ณ ๋ฆฌ_์‚ญ์ œ(categoryId)
}
}
/// - ํ•„ํ„ฐ ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ
case .filterBottomSheet(let delegateAction):
switch delegateAction {
case .dismiss:
state.isFilterSheetPresented.toggle()
return .none
case let .ํ™•์ธ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ(type, bookMarkSelected, unReadSelected):
state.isFilterSheetPresented.toggle()
state.domain.pageable.sort = [
type == .์ตœ์‹ ์ˆœ ? "createdAt,desc" : "createdAt,asc"
]
state.sortType = type
state.domain.condition.isFavoriteFlitered = bookMarkSelected
state.domain.condition.isUnreadFlitered = unReadSelected
return .concatenate(
.send(.inner(.pagenation_์ดˆ๊ธฐํ™”), animation: .pokitDissolve),
.send(.async(.์นดํ…Œ๊ณ ๋ฆฌ_๋‚ด_์ปจํ…์ธ _๋ชฉ๋ก_์กฐํšŒ_API))
)
}

case let .contents(.element(id: _, action: .delegate(.์ปจํ…์ธ _ํ•ญ๋ชฉ_์ผ€๋ฐฅ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ(content)))):
return .send(.delegate(.contentItemTapped(content)))
Expand Down
Loading

0 comments on commit 842a4a9

Please sign in to comment.