-
-
Notifications
You must be signed in to change notification settings - Fork 254
/
OverlayMenu.swift
180 lines (156 loc) · 5.23 KB
/
OverlayMenu.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//
import Defaults
import SwiftUI
import VLCUI
extension VideoPlayer.Overlay {
struct OverlayMenu: View {
@Default(.VideoPlayer.menuActionButtons)
private var menuActionButtons
@EnvironmentObject
private var splitContentViewProxy: SplitContentViewProxy
@EnvironmentObject
private var viewModel: VideoPlayerViewModel
@ViewBuilder
private var advancedButton: some View {
Button {
splitContentViewProxy.present()
} label: {
HStack {
Image(systemName: "gearshape.fill")
Text(L10n.advanced)
}
}
}
@ViewBuilder
private var aspectFillButton: some View {
ActionButtons.AspectFill { isAspectFilled in
HStack {
if isAspectFilled {
Image(systemName: "arrow.down.right.and.arrow.up.left")
} else {
Image(systemName: "arrow.up.left.and.arrow.down.right")
}
Text(L10n.aspectFill)
}
}
}
@ViewBuilder
private var audioTrackMenu: some View {
ActionButtons.Audio { audioTrackSelected in
HStack {
if audioTrackSelected {
Image(systemName: "speaker.wave.2.fill")
} else {
Image(systemName: "speaker.wave.2")
}
L10n.audio.text
}
}
}
@ViewBuilder
private var autoPlayButton: some View {
if viewModel.item.type == .episode {
ActionButtons.AutoPlay { autoPlayEnabled in
HStack {
if autoPlayEnabled {
Image(systemName: "play.circle.fill")
} else {
Image(systemName: "stop.circle")
}
L10n.autoPlay.text
}
}
}
}
@ViewBuilder
private var chaptersButton: some View {
if viewModel.chapters.isNotEmpty {
ActionButtons.Chapters {
HStack {
Image(systemName: "list.dash")
L10n.chapters.text
}
}
}
}
@ViewBuilder
private var playbackSpeedMenu: some View {
ActionButtons.PlaybackSpeedMenu {
HStack {
Image(systemName: "speedometer")
L10n.playbackSpeed.text
}
}
}
@ViewBuilder
private var playNextItemButton: some View {
if viewModel.item.type == .episode {
ActionButtons.PlayNextItem {
HStack {
Image(systemName: "chevron.right.circle")
Text(L10n.playNextItem)
}
}
}
}
@ViewBuilder
private var playPreviousItemButton: some View {
if viewModel.item.type == .episode {
ActionButtons.PlayPreviousItem {
HStack {
Image(systemName: "chevron.left.circle")
Text(L10n.playPreviousItem)
}
}
}
}
@ViewBuilder
private var subtitleTrackMenu: some View {
ActionButtons.Subtitles { subtitleTrackSelected in
HStack {
if subtitleTrackSelected {
Image(systemName: "captions.bubble.fill")
} else {
Image(systemName: "captions.bubble")
}
L10n.subtitles.text
}
}
}
var body: some View {
Menu {
ForEach(menuActionButtons) { actionButton in
switch actionButton {
// case .advanced:
// advancedButton
case .aspectFill:
aspectFillButton
case .audio:
audioTrackMenu
case .autoPlay:
autoPlayButton
case .chapters:
chaptersButton
case .playbackSpeed:
playbackSpeedMenu
case .playNextItem:
playNextItemButton
case .playPreviousItem:
playPreviousItemButton
case .subtitles:
subtitleTrackMenu
}
}
} label: {
Image(systemName: "ellipsis.circle")
}
.frame(width: 50, height: 50)
}
}
}