mirror of
https://github.com/yattee/yattee.git
synced 2025-01-10 23:07:10 +00:00
Limit available controls layout
This commit is contained in:
parent
8ac71a24c4
commit
95296b34b5
@ -1,5 +1,8 @@
|
|||||||
import Defaults
|
import Defaults
|
||||||
import Foundation
|
import Foundation
|
||||||
|
#if os(iOS)
|
||||||
|
import UIKit
|
||||||
|
#endif
|
||||||
|
|
||||||
enum PlayerControlsLayout: String, CaseIterable, Defaults.Serializable {
|
enum PlayerControlsLayout: String, CaseIterable, Defaults.Serializable {
|
||||||
case tvRegular
|
case tvRegular
|
||||||
@ -9,6 +12,36 @@ enum PlayerControlsLayout: String, CaseIterable, Defaults.Serializable {
|
|||||||
case small
|
case small
|
||||||
case smaller
|
case smaller
|
||||||
|
|
||||||
|
var available: Bool {
|
||||||
|
var isATV = false
|
||||||
|
var isIPad = false
|
||||||
|
#if os(tvOS)
|
||||||
|
isATV = true
|
||||||
|
#endif
|
||||||
|
#if os(iOS)
|
||||||
|
isIPad = UIDevice.current.userInterfaceIdiom == .pad
|
||||||
|
#endif
|
||||||
|
switch self {
|
||||||
|
case .tvRegular:
|
||||||
|
return isATV
|
||||||
|
case .veryLarge:
|
||||||
|
#if os(macOS)
|
||||||
|
return true
|
||||||
|
#else
|
||||||
|
return isIPad
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case .large:
|
||||||
|
return true
|
||||||
|
case .medium:
|
||||||
|
return true
|
||||||
|
case .small:
|
||||||
|
return true
|
||||||
|
case .smaller:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .tvRegular:
|
case .tvRegular:
|
||||||
|
@ -197,13 +197,13 @@ struct PlayerSettings: View {
|
|||||||
|
|
||||||
@ViewBuilder private var controlsLayoutFooter: some View {
|
@ViewBuilder private var controlsLayoutFooter: some View {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
Text("Large and bigger layouts are not suitable for all devices and using them may cause controls not to fit on the screen.")
|
Text("Large layout is not suitable for all devices and using it may cause controls not to fit on the screen.")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private var playerControlsLayoutPicker: some View {
|
private var playerControlsLayoutPicker: some View {
|
||||||
Picker("Regular Size", selection: $playerControlsLayout) {
|
Picker("Regular Size", selection: $playerControlsLayout) {
|
||||||
ForEach(PlayerControlsLayout.allCases, id: \.self) { layout in
|
ForEach(PlayerControlsLayout.allCases.filter(\.available), id: \.self) { layout in
|
||||||
Text(layout.description).tag(layout.rawValue)
|
Text(layout.description).tag(layout.rawValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ struct PlayerSettings: View {
|
|||||||
|
|
||||||
private var fullScreenPlayerControlsLayoutPicker: some View {
|
private var fullScreenPlayerControlsLayoutPicker: some View {
|
||||||
Picker("Fullscreen Size", selection: $fullScreenPlayerControlsLayout) {
|
Picker("Fullscreen Size", selection: $fullScreenPlayerControlsLayout) {
|
||||||
ForEach(PlayerControlsLayout.allCases, id: \.self) { layout in
|
ForEach(PlayerControlsLayout.allCases.filter(\.available), id: \.self) { layout in
|
||||||
Text(layout.description).tag(layout.rawValue)
|
Text(layout.description).tag(layout.rawValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user