-
-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathPlaybackFullControlsView.swift
111 lines (104 loc) · 3.51 KB
/
PlaybackFullControlsView.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// PlaybackFullControlsView.swift
// BookPlayerWatch
//
// Created by Gianni Carlo on 25/11/24.
// Copyright © 2024 BookPlayer LLC. All rights reserved.
//
import BookPlayerWatchKit
import SwiftUI
struct PlaybackFullControlsView: View {
@ObservedObject var model: PlaybackFullControlsViewModel
@AppStorage(Constants.UserDefaults.globalSpeedEnabled) var globalSpeedEnabled: Bool = false
@AppStorage(Constants.UserDefaults.boostVolumeEnabled) var boostVolumeEnabled: Bool = false
@AppStorage(Constants.UserDefaults.autoplayEnabled) var autoplayEnabled: Bool = true
@AppStorage(Constants.UserDefaults.rewindInterval) var rewindInterval: TimeInterval = 30
@AppStorage(Constants.UserDefaults.forwardInterval) var forwardInterval: TimeInterval = 30
var body: some View {
GeometryReader { metrics in
List {
Section("speed_title".localized.uppercased()) {
VStack {
HStack {
Spacer()
Button {
model.handleNewSpeed(model.rate - 0.1)
} label: {
ResizeableImageView(name: "minus.circle")
}
.buttonStyle(PlainButtonStyle())
.accessibilityLabel("➖")
.frame(width: metrics.size.width * 0.15)
Spacer()
.padding([.leading], 5)
Button {
model.handleNewSpeedJump()
} label: {
Text("\(model.rate, specifier: "%.2f")x")
.padding()
.frame(maxWidth: .infinity)
.background(Color.black.brightness(0.2))
.cornerRadius(5)
}
.buttonStyle(PlainButtonStyle())
.frame(width: metrics.size.width * 0.4)
Spacer()
.padding([.leading], 5)
Button {
model.handleNewSpeed(model.rate + 0.1)
} label: {
ResizeableImageView(name: "plus.circle")
}
.buttonStyle(PlainButtonStyle())
.accessibilityLabel("➕")
.frame(width: metrics.size.width * 0.15)
Spacer()
}
}
}
.listRowBackground(Color.clear)
Section {
Toggle(
"settings_globalspeed_title",
isOn: $globalSpeedEnabled
)
Toggle(
"settings_boostvolume_title",
isOn: $boostVolumeEnabled
)
Toggle(
"settings_autoplay_section_title".localized.capitalized,
isOn: $autoplayEnabled
)
}
Section("settings_skip_title") {
NavigationLink {
SkipDurationListView(skipDirection: .back)
} label: {
HStack {
Text("settings_skip_rewind_title")
Spacer()
Text(TimeParser.formatDuration(rewindInterval))
Image(systemName: "chevron.forward")
}
}
NavigationLink {
SkipDurationListView(skipDirection: .forward)
} label: {
HStack {
Text("settings_skip_forward_title")
Spacer()
Text(TimeParser.formatDuration(forwardInterval))
Image(systemName: "chevron.forward")
}
}
}
}
.environment(\.defaultMinListRowHeight, 40)
.onChange(of: boostVolumeEnabled) { boostVolume in
model.handleBoostVolumeToggle(boostVolume)
}
}
.navigationTitle("settings_controls_title")
}
}