mirror of
https://github.com/yattee/yattee.git
synced 2024-12-14 22:30:32 +05:30
Add setting for thumbnails quality
This commit is contained in:
parent
280f90e4c6
commit
accd78be92
@ -1,3 +1,4 @@
|
|||||||
|
import Defaults
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
final class ThumbnailsModel: ObservableObject {
|
final class ThumbnailsModel: ObservableObject {
|
||||||
@ -16,9 +17,7 @@ final class ThumbnailsModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func best(_ video: Video) -> URL? {
|
func best(_ video: Video) -> URL? {
|
||||||
let qualities = [Thumbnail.Quality.maxresdefault, .medium, .default]
|
for quality in availableQualitites {
|
||||||
|
|
||||||
for quality in qualities {
|
|
||||||
let url = video.thumbnailURL(quality: quality)
|
let url = video.thumbnailURL(quality: quality)
|
||||||
if !isUnloadable(url) {
|
if !isUnloadable(url) {
|
||||||
return url
|
return url
|
||||||
@ -27,4 +26,15 @@ final class ThumbnailsModel: ObservableObject {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var availableQualitites: [Thumbnail.Quality] {
|
||||||
|
switch Defaults[.thumbnailsQuality] {
|
||||||
|
case .highest:
|
||||||
|
return [.maxresdefault, .medium, .default]
|
||||||
|
case .medium:
|
||||||
|
return [.medium, .default]
|
||||||
|
case .low:
|
||||||
|
return [.default]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ extension Defaults.Keys {
|
|||||||
static let channelOnThumbnail = Key<Bool>("channelOnThumbnail", default: true)
|
static let channelOnThumbnail = Key<Bool>("channelOnThumbnail", default: true)
|
||||||
static let timeOnThumbnail = Key<Bool>("timeOnThumbnail", default: true)
|
static let timeOnThumbnail = Key<Bool>("timeOnThumbnail", default: true)
|
||||||
static let roundedThumbnails = Key<Bool>("roundedThumbnails", default: true)
|
static let roundedThumbnails = Key<Bool>("roundedThumbnails", default: true)
|
||||||
|
static let thumbnailsQuality = Key<ThumbnailsQuality>("thumbnailsQuality", default: .highest)
|
||||||
|
|
||||||
static let activeBackend = Key<PlayerBackendType>("activeBackend", default: .mpv)
|
static let activeBackend = Key<PlayerBackendType>("activeBackend", default: .mpv)
|
||||||
static let quality = Key<ResolutionSetting>("quality", default: .best)
|
static let quality = Key<ResolutionSetting>("quality", default: .best)
|
||||||
@ -218,3 +219,7 @@ enum PlayerDetailsPageButtonLabelStyle: String, CaseIterable, Defaults.Serializa
|
|||||||
self == .iconAndText
|
self == .iconAndText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ThumbnailsQuality: String, CaseIterable, Defaults.Serializable {
|
||||||
|
case highest, medium, low
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@ struct BrowsingSettings: View {
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
|
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
|
||||||
#endif
|
#endif
|
||||||
|
@Default(.thumbnailsQuality) private var thumbnailsQuality
|
||||||
@Default(.channelOnThumbnail) private var channelOnThumbnail
|
@Default(.channelOnThumbnail) private var channelOnThumbnail
|
||||||
@Default(.timeOnThumbnail) private var timeOnThumbnail
|
@Default(.timeOnThumbnail) private var timeOnThumbnail
|
||||||
@Default(.visibleSections) private var visibleSections
|
@Default(.visibleSections) private var visibleSections
|
||||||
@ -65,6 +66,7 @@ struct BrowsingSettings: View {
|
|||||||
|
|
||||||
private var thumbnailsSettings: some View {
|
private var thumbnailsSettings: some View {
|
||||||
Section(header: SettingsHeader(text: "Thumbnails")) {
|
Section(header: SettingsHeader(text: "Thumbnails")) {
|
||||||
|
thumbnailsQualityPicker
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
Toggle("Round corners", isOn: $roundedThumbnails)
|
Toggle("Round corners", isOn: $roundedThumbnails)
|
||||||
#endif
|
#endif
|
||||||
@ -73,6 +75,21 @@ struct BrowsingSettings: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var thumbnailsQualityPicker: some View {
|
||||||
|
Picker("Quality", selection: $thumbnailsQuality) {
|
||||||
|
ForEach(ThumbnailsQuality.allCases, id: \.self) { quality in
|
||||||
|
Text(quality.rawValue.capitalized + " quality").tag(quality)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.labelsHidden()
|
||||||
|
|
||||||
|
#if os(iOS)
|
||||||
|
.pickerStyle(.automatic)
|
||||||
|
#elseif os(tvOS)
|
||||||
|
.pickerStyle(.inline)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private var visibleSectionsSettings: some View {
|
private var visibleSectionsSettings: some View {
|
||||||
Section(header: SettingsHeader(text: "Sections")) {
|
Section(header: SettingsHeader(text: "Sections")) {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
|
Loading…
Reference in New Issue
Block a user