-
-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathPlaybackControlsView.swift
72 lines (67 loc) · 2.01 KB
/
PlaybackControlsView.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
//
// PlaybackControlsView.swift
// BookPlayerWatch Extension
//
// Created by gianni.carlo on 20/2/22.
// Copyright © 2022 BookPlayer LLC. All rights reserved.
//
import SwiftUI
struct PlaybackControlsView: View {
@EnvironmentObject var contextManager: ContextManager
var body: some View {
GeometryReader { metrics in
VStack {
HStack {
Spacer()
Button {
contextManager.handleNewSpeed(contextManager.applicationContext.rate - 0.1)
} label: {
ResizeableImageView(name: "minus.circle")
}
.buttonStyle(PlainButtonStyle())
.frame(width: metrics.size.width * 0.15)
Spacer()
.padding([.leading], 5)
Button {
contextManager.handleNewSpeedJump()
} label: {
Text("\(contextManager.applicationContext.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 {
contextManager.handleNewSpeed(contextManager.applicationContext.rate + 0.1)
} label: {
ResizeableImageView(name: "plus.circle")
}
.buttonStyle(PlainButtonStyle())
.frame(width: metrics.size.width * 0.15)
Spacer()
}
.padding([.top], 10)
List {
Toggle("settings_boostvolume_title", isOn: .init(
get: { contextManager.applicationContext.boostVolume },
set: { _ in
contextManager.handleBoostVolumeToggle()
}
))
}
.padding([.top], 10)
Spacer()
}
}
.navigationTitle("settings_controls_title")
}
}
struct PlaybackControlsView_Previews: PreviewProvider {
static var previews: some View {
PlaybackControlsView()
}
}