Skip to content

Commit

Permalink
🌱 :: [#118] MusicFeature / MusicFeature Scene Seed files
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Jul 26, 2023
1 parent 2519965 commit daf0962
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Moordinator

struct MusicFactoryImpl: MusicFactory {
func makeMoordinator() -> Moordinator {
MusicMoordinator()
let store = MusicStore()
let viewController = MusicViewController(store: store)
return MusicMoordinator(musicViewController: viewController)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import UIKit

final class MusicMoordinator: Moordinator {
private let rootVC = UINavigationController()

private let musicViewController: any StoredViewControllable
var root: Presentable {
rootVC
}

init(musicViewController: any StoredViewControllable) {
self.musicViewController = musicViewController
}

func route(to path: RoutePath) -> MoordinatorContributors {
guard let path = path.asDotori else { return .none }
switch path {
Expand All @@ -25,8 +29,12 @@ final class MusicMoordinator: Moordinator {

private extension MusicMoordinator {
func coordinateToMusic() -> MoordinatorContributors {
let musicWebViewController = DWebViewController(urlString: "https://www.dotori-gsm.com/song")
self.rootVC.setViewControllers([musicWebViewController], animated: true)
return .none
self.rootVC.setViewControllers([self.musicViewController], animated: true)
return .one(
.contribute(
withNextPresentable: self.musicViewController,
withNextRouter: self.musicViewController.store
)
)
}
}
33 changes: 33 additions & 0 deletions Projects/Feature/MusicFeature/Sources/Scene/MusicStore.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import BaseFeature
import Combine
import Store
import Moordinator

final class MusicStore: BaseStore {
var route: PassthroughSubject<RoutePath, Never> = .init()
var subscription: Set<AnyCancellable> = .init()
var initialState: State
var stateSubject: CurrentValueSubject<State, Never>

init() {
self.initialState = .init()
self.stateSubject = .init(initialState)
}

struct State {}
enum Action {}
enum Mutation {}
}

extension MusicStore {
func mutate(state: State, action: Action) -> SideEffect<Mutation, Never> {
.none
}
}

extension MusicStore {
func reduce(state: State, mutate: Mutation) -> State {
var newState = state
return newState
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import BaseFeature

final class MusicViewController: BaseStoredViewController<MusicStore> {
}

0 comments on commit daf0962

Please sign in to comment.