Skip to content

Commit

Permalink
[desing] #154 NaivgationSplitView Content ์ œ๊ฑฐ
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Nov 6, 2024
1 parent ad32403 commit 9c9f4e0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
22 changes: 20 additions & 2 deletions Projects/App/Sources/MainTabSplit/Pokit/PokitSplitFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct PokitSplitFeature {
/// - State
@ObservableState
public struct State: Equatable {
var columnVisibility: NavigationSplitViewVisibility = .doubleColumn
var columnVisibility: NavigationSplitViewVisibility = UIDevice.current.orientation == .portrait ? .detailOnly : .all

var ํฌํ‚ท: PokitRootFeature.State = .init()
var ์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ: CategoryDetailFeature.State?
Expand Down Expand Up @@ -69,6 +69,7 @@ public struct PokitSplitFeature {
case binding(BindingAction<State>)

case ๋ทฐ๊ฐ€_๋‚˜ํƒ€๋‚ฌ์„๋•Œ
case ๋งํฌ์ถ”๊ฐ€_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ๊ฒ€์ƒ‰_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ์•Œ๋žŒ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
case ์„ค์ •_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ
Expand Down Expand Up @@ -168,7 +169,21 @@ public struct PokitSplitFeature {
private extension PokitSplitFeature {
/// - View Effect
func handleViewAction(_ action: Action.View, state: inout State) -> Effect<Action> {
return .none
switch action {
case .binding:
return .none
case .๋ทฐ๊ฐ€_๋‚˜ํƒ€๋‚ฌ์„๋•Œ:
return .none
case .๋งํฌ์ถ”๊ฐ€_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
state.columnVisibility = .all
return .none
case .๊ฒ€์ƒ‰_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
return .none
case .์•Œ๋žŒ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
return .none
case .์„ค์ •_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
return .none
}
}

/// - Inner Effect
Expand Down Expand Up @@ -200,6 +215,9 @@ private extension PokitSplitFeature {
case .์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ:
return .none

case .๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •(.delegate(.dismiss)):
state.columnVisibility = .detailOnly
return .none
case .๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •:
return .none

Expand Down
31 changes: 24 additions & 7 deletions Projects/App/Sources/MainTabSplit/Pokit/PokitSplitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,30 @@ public extension PokitSplitView {
WithPerceptionTracking {
NavigationSplitView(columnVisibility: $store.columnVisibility) {
ContentSettingView(store: store.scope(state: \.๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •, action: \.๋งํฌ์ถ”๊ฐ€๋ฐ์ˆ˜์ •))
} content: {
PokitRootView(store: store.scope(state: \.ํฌํ‚ท, action: \.ํฌํ‚ท))
.pokitNavigationBar { pokitNavigationBar }
.toolbar(.hidden, for: .navigationBar)
} detail: {
if let store = store.scope(state: \.์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ, action: \.์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ) {
CategoryDetailView(store: store)
}
detail
.toolbar(.hidden, for: .navigationBar)
}

}
}
}
//MARK: - Configure View
private extension PokitSplitView {
var detail: some View {
HStack(spacing: 0) {
PokitRootView(store: store.scope(state: \.ํฌํ‚ท, action: \.ํฌํ‚ท))
.pokitNavigationBar { pokitNavigationBar }
.frame(width: 400)

if let store = store.scope(state: \.์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ, action: \.์นดํ…Œ๊ณ ๋ฆฌ์ƒ์„ธ) {
CategoryDetailView(store: store)
} else {
Spacer()
}
}
}

var pokitNavigationBar: some View {
PokitHeader {
PokitHeaderItems(placement: .leading) {
Expand All @@ -59,6 +69,13 @@ private extension PokitSplitView {
}

PokitHeaderItems(placement: .trailing) {
if store.columnVisibility == .detailOnly {
PokitToolbarButton(
.icon(.edit),
action: { send(.๋งํฌ์ถ”๊ฐ€_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ) }
)
}

PokitToolbarButton(
.icon(.search),
action: { send(.๊ฒ€์ƒ‰_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ private extension ContentSettingFeature {

return .send(.delegate(.ํฌํ‚ท์ถ”๊ฐ€ํ•˜๊ธฐ))
case .๋’ค๋กœ๊ฐ€๊ธฐ_๋ฒ„ํŠผ_๋ˆŒ๋ €์„๋•Œ:
guard UIDevice.isPhone else {
return .send(.delegate(.dismiss))
}
return state.isShareExtension
? .send(.delegate(.dismiss))
: .run { _ in await dismiss() }
Expand Down

0 comments on commit 9c9f4e0

Please sign in to comment.