-
Notifications
You must be signed in to change notification settings - Fork 0
/
DesktopReaderView.swift
58 lines (54 loc) · 2 KB
/
DesktopReaderView.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import ComposableArchitecture
import DirectoryCore
import SwiftUI
public struct DesktopReaderView: View {
let store: StoreOf<DesktopReader>
public init(store: StoreOf<DesktopReader>) {
self.store = store
}
public var body: some View {
WithViewStore(store, observe: { $0} ) { viewStore in
PageView(store: store.scope(state: \.page, action: DesktopReader.Action.page))
.toolbar {
ToolbarItem(placement: ToolbarItemPlacement.navigation) {
ToolbarDirectoryView(
store: store.scope(
state: \.toolbarDirectory,
action: DesktopReader.Action.toolbarDirectory
)
)
}
}
.overlay {
HStack {
Button {
viewStore.send(.page(.paginateChapter(forward: false)))
} label: {
Image(systemName: "arrow.left")
}
.keyboardShortcut(.leftArrow)
Spacer()
Button {
viewStore.send(.page(.paginateChapter(forward: true)))
} label: {
Image(systemName: "arrow.right")
}
.keyboardShortcut(.rightArrow)
}
.padding()
.buttonBorderShape(.roundedRectangle)
.buttonStyle(.borderedProminent)
.frame(maxHeight: .infinity, alignment: .bottom)
}
}
}
}
struct DesktopReaderView_Previews: PreviewProvider {
static var previews: some View {
DesktopReaderView(
store: Store(initialState: DesktopReader.State()) {
DesktopReader()
}
)
}
}