-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDesktopReader.swift
38 lines (33 loc) · 1.09 KB
/
DesktopReader.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import DirectoryCore
import ComposableArchitecture
public struct DesktopReader: Reducer {
public init() { }
public struct State: Equatable {
var toolbarDirectory: ToolbarDirectory.State
var page: Page.State
public init(toolbarDirectory: ToolbarDirectory.State = .init(), page: Page.State = .init()) {
self.toolbarDirectory = toolbarDirectory
self.page = page
}
}
public enum Action: Equatable {
case toolbarDirectory(ToolbarDirectory.Action)
case page(Page.Action)
}
public var body: some ReducerOf<Self> {
Scope(state: \.toolbarDirectory, action: /Action.toolbarDirectory) {
ToolbarDirectory()
}
Scope(state: \.page, action: /Action.page) {
Page()
}
Reduce<State, Action> { state, action in
switch action {
case .toolbarDirectory(.select(let book, let chapter)):
return .send(.page(.jump(book, chapter)))
default:
return .none
}
}
}
}