-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
517a208
commit 6d5e154
Showing
2 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
220 changes: 220 additions & 0 deletions
220
Projects/App/Sources/MainTabSplit/Pokit/PokitSplitFeature.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
// | ||
// PokitSplitFeature.swift | ||
// App | ||
// | ||
// Created by ๊น๋ํ on 10/24/24. | ||
|
||
import ComposableArchitecture | ||
import FeaturePokit | ||
import FeatureCategoryDetail | ||
import FeatureCategorySetting | ||
import FeatureCategorySharing | ||
import FeatureSetting | ||
import FeatureContentSetting | ||
import FeatureContentDetail | ||
import FeatureRemind | ||
import FeatureContentDetail | ||
import Domain | ||
import Util | ||
|
||
@Reducer | ||
public struct PokitSplitFeature { | ||
/// - Dependency | ||
|
||
/// - State | ||
@ObservableState | ||
public struct State: Equatable { | ||
var ํฌํท: PokitRootFeature.State = .init() | ||
var ์นดํ ๊ณ ๋ฆฌ์์ธ: CategoryDetailFeature.State? | ||
var ๋งํฌ์ถ๊ฐ๋ฐ์์ : ContentSettingFeature.State = .init() | ||
|
||
@Presents | ||
var ํฌํท์ถ๊ฐ๋ฐ์์ : PokitCategorySettingFeature.State? | ||
@Presents | ||
var ๊ฒ์: PokitSearchFeature.State? | ||
@Presents | ||
var ์ค์ : PokitSettingFeature.State? | ||
@Presents | ||
var ๋งํฌ์์ธ: ContentDetailFeature.State? | ||
|
||
@Shared(.inMemory("SelectCategory")) | ||
var categoryId: Int? | ||
@Shared(.inMemory("PushTapped")) | ||
var isPushTapped: Bool = false | ||
|
||
public init() {} | ||
} | ||
|
||
/// - Action | ||
public enum Action: FeatureAction, ViewAction { | ||
case view(View) | ||
case inner(InnerAction) | ||
case async(AsyncAction) | ||
case scope(ScopeAction) | ||
case delegate(DelegateAction) | ||
case ํฌํท(PokitRootFeature.Action) | ||
case ์นดํ ๊ณ ๋ฆฌ์์ธ(CategoryDetailFeature.Action) | ||
case ๋งํฌ์ถ๊ฐ๋ฐ์์ (ContentSettingFeature.Action) | ||
case ํฌํท์ถ๊ฐ๋ฐ์์ (PokitCategorySettingFeature.Action) | ||
case ๊ฒ์(PokitSearchFeature.Action) | ||
case ์ค์ (PokitSettingFeature.Action) | ||
case ๋งํฌ์์ธ(ContentDetailFeature.Action) | ||
|
||
@CasePathable | ||
public enum View: Equatable { | ||
case ๋ทฐ๊ฐ_๋ํ๋ฌ์๋ | ||
} | ||
|
||
public enum InnerAction: Equatable { | ||
case ์นดํ ๊ณ ๋ฆฌ_์์ธ_ํ์ฑํ(BaseCategoryItem) | ||
} | ||
|
||
public enum AsyncAction: Equatable { case doNothing } | ||
|
||
public enum ScopeAction { | ||
case ํฌํท(PokitRootFeature.Action) | ||
case ์นดํ ๊ณ ๋ฆฌ์์ธ(CategoryDetailFeature.Action) | ||
case ๋งํฌ์ถ๊ฐ๋ฐ์์ (ContentSettingFeature.Action) | ||
case ํฌํท์ถ๊ฐ๋ฐ์์ (PokitCategorySettingFeature.Action) | ||
case ๊ฒ์(PokitSearchFeature.Action) | ||
case ์ค์ (PokitSettingFeature.Action) | ||
case ๋งํฌ์์ธ(ContentDetailFeature.Action) | ||
} | ||
|
||
public enum DelegateAction: Equatable { case ์์ } | ||
} | ||
|
||
/// - Initiallizer | ||
public init() {} | ||
|
||
/// - Reducer Core | ||
private func core(into state: inout State, action: Action) -> Effect<Action> { | ||
switch action { | ||
/// - View | ||
case .view(let viewAction): | ||
return handleViewAction(viewAction, state: &state) | ||
|
||
/// - Inner | ||
case .inner(let innerAction): | ||
return handleInnerAction(innerAction, state: &state) | ||
|
||
/// - Async | ||
case .async(let asyncAction): | ||
return handleAsyncAction(asyncAction, state: &state) | ||
|
||
/// - Scope | ||
case .scope(let scopeAction): | ||
return handleScopeAction(scopeAction, state: &state) | ||
|
||
/// - Delegate | ||
case .delegate(let delegateAction): | ||
return handleDelegateAction(delegateAction, state: &state) | ||
case .ํฌํท(let pokitAction): | ||
return .send(.scope(.ํฌํท(pokitAction))) | ||
case .์นดํ ๊ณ ๋ฆฌ์์ธ(let categoryDetailAction): | ||
return .send(.scope(.์นดํ ๊ณ ๋ฆฌ์์ธ(categoryDetailAction))) | ||
case .๋งํฌ์ถ๊ฐ๋ฐ์์ (let contentSettingAction): | ||
return .send(.scope(.๋งํฌ์ถ๊ฐ๋ฐ์์ (contentSettingAction))) | ||
case .ํฌํท์ถ๊ฐ๋ฐ์์ (let categorySettingAction): | ||
return .send(.scope(.ํฌํท์ถ๊ฐ๋ฐ์์ (categorySettingAction))) | ||
case .๊ฒ์(let searchAction): | ||
return .send(.scope(.๊ฒ์(searchAction))) | ||
case .์ค์ (let settingAction): | ||
return .send(.scope(.์ค์ (settingAction))) | ||
case .๋งํฌ์์ธ(let contentDetailAction): | ||
return .send(.scope(.๋งํฌ์์ธ(contentDetailAction))) | ||
} | ||
} | ||
|
||
/// - Reducer body | ||
public var body: some ReducerOf<Self> { | ||
Scope(state: \.ํฌํท, action: \.ํฌํท) { | ||
PokitRootFeature() | ||
} | ||
Scope(state: \.๋งํฌ์ถ๊ฐ๋ฐ์์ , action: \.๋งํฌ์ถ๊ฐ๋ฐ์์ ) { | ||
ContentSettingFeature() | ||
} | ||
|
||
Reduce(self.core) | ||
.ifLet(\.์นดํ ๊ณ ๋ฆฌ์์ธ, action: \.์นดํ ๊ณ ๋ฆฌ์์ธ) { | ||
CategoryDetailFeature() | ||
} | ||
.ifLet(\.ํฌํท์ถ๊ฐ๋ฐ์์ , action: \.ํฌํท์ถ๊ฐ๋ฐ์์ ) { | ||
PokitCategorySettingFeature() | ||
} | ||
.ifLet(\.๊ฒ์, action: \.๊ฒ์) { | ||
PokitSearchFeature() | ||
} | ||
.ifLet(\.์ค์ , action: \.์ค์ ) { | ||
PokitSettingFeature() | ||
} | ||
.ifLet(\.๋งํฌ์์ธ, action: \.๋งํฌ์์ธ) { | ||
ContentDetailFeature() | ||
} | ||
} | ||
} | ||
//MARK: - FeatureAction Effect | ||
private extension PokitSplitFeature { | ||
/// - View Effect | ||
func handleViewAction(_ action: Action.View, state: inout State) -> Effect<Action> { | ||
return .none | ||
} | ||
|
||
/// - Inner Effect | ||
func handleInnerAction(_ action: Action.InnerAction, state: inout State) -> Effect<Action> { | ||
switch action { | ||
case let .์นดํ ๊ณ ๋ฆฌ_์์ธ_ํ์ฑํ(category): | ||
state.์นดํ ๊ณ ๋ฆฌ์์ธ = .init(category: category) | ||
return .none | ||
} | ||
} | ||
|
||
/// - Async Effect | ||
func handleAsyncAction(_ action: Action.AsyncAction, state: inout State) -> Effect<Action> { | ||
return .none | ||
} | ||
|
||
/// - Scope Effect | ||
func handleScopeAction(_ action: Action.ScopeAction, state: inout State) -> Effect<Action> { | ||
switch action { | ||
case let .ํฌํท(.delegate(.categoryTapped(category))): | ||
state.categoryId = category.id | ||
return .send(.inner(.์นดํ ๊ณ ๋ฆฌ_์์ธ_ํ์ฑํ(category))) | ||
case .ํฌํท(.delegate(.์นดํ ๊ณ ๋ฆฌ_์ญ์ )): | ||
state.์นดํ ๊ณ ๋ฆฌ์์ธ = nil | ||
return .none | ||
case .ํฌํท: | ||
return .none | ||
|
||
case .์นดํ ๊ณ ๋ฆฌ์์ธ: | ||
return .none | ||
|
||
case .๋งํฌ์ถ๊ฐ๋ฐ์์ : | ||
return .none | ||
|
||
case .ํฌํท์ถ๊ฐ๋ฐ์์ : | ||
return .none | ||
|
||
case .๊ฒ์: | ||
return .none | ||
|
||
case .์ค์ : | ||
return .none | ||
|
||
case .๋งํฌ์์ธ: | ||
return .none | ||
} | ||
} | ||
|
||
/// - Delegate Effect | ||
func handleDelegateAction(_ action: Action.DelegateAction, state: inout State) -> Effect<Action> { | ||
return .none | ||
} | ||
} | ||
|
||
extension PokitSplitFeature { | ||
@Reducer | ||
enum Path { | ||
case ์๋ฆผํจ(PokitAlertBoxFeature) | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
Projects/App/Sources/MainTabSplit/Pokit/PokitSplitView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// | ||
// PokitSplitView.swift | ||
// App | ||
// | ||
// Created by ๊น๋ํ on 10/24/24. | ||
|
||
import SwiftUI | ||
|
||
import ComposableArchitecture | ||
import FeaturePokit | ||
import FeatureRemind | ||
import FeatureSetting | ||
import FeatureCategorySetting | ||
import FeatureContentDetail | ||
import FeatureContentSetting | ||
import FeatureCategoryDetail | ||
import FeatureContentList | ||
import FeatureCategorySharing | ||
|
||
@ViewAction(for: PokitSplitFeature.self) | ||
public struct PokitSplitView: View { | ||
/// - Properties | ||
public var store: StoreOf<PokitSplitFeature> | ||
|
||
/// - Initializer | ||
public init(store: StoreOf<PokitSplitFeature>) { | ||
self.store = store | ||
} | ||
} | ||
//MARK: - View | ||
public extension PokitSplitView { | ||
var body: some View { | ||
WithPerceptionTracking { | ||
NavigationSplitView(columnVisibility: .constant(.all)) { | ||
PokitRootView(store: store.scope(state: \.ํฌํท, action: \.ํฌํท)) | ||
.toolbar(.hidden, for: .navigationBar) | ||
} detail: { | ||
detail | ||
.toolbar(.hidden, for: .navigationBar) | ||
} | ||
} | ||
} | ||
} | ||
//MARK: - Configure View | ||
private extension PokitSplitView { | ||
var detail: some View { | ||
HStack(spacing: 0) { | ||
if let store = store.scope(state: \.์นดํ ๊ณ ๋ฆฌ์์ธ, action: \.์นดํ ๊ณ ๋ฆฌ์์ธ) { | ||
CategoryDetailView(store: store) | ||
} else { | ||
Spacer() | ||
} | ||
|
||
ContentSettingView(store: store.scope(state: \.๋งํฌ์ถ๊ฐ๋ฐ์์ , action: \.๋งํฌ์ถ๊ฐ๋ฐ์์ )) | ||
.frame(width: 375) | ||
} | ||
} | ||
} | ||
//MARK: - Preview | ||
#Preview { | ||
PokitSplitView( | ||
store: Store( | ||
initialState: .init(), | ||
reducer: { PokitSplitFeature() } | ||
) | ||
) | ||
} | ||
|
||
|