mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add setting for disabling thumbnails rounding
This commit is contained in:
parent
b5d187c52f
commit
4e88f2baf8
@ -41,12 +41,13 @@ extension Defaults.Keys {
|
|||||||
#endif
|
#endif
|
||||||
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 showHistoryInPlayer = Key<Bool>("showHistoryInPlayer", default: false)
|
static let roundedThumbnails = Key<Bool>("roundedThumbnails", default: true)
|
||||||
|
|
||||||
static let quality = Key<ResolutionSetting>("quality", default: .best)
|
static let quality = Key<ResolutionSetting>("quality", default: .best)
|
||||||
static let playerSidebar = Key<PlayerSidebarSetting>("playerSidebar", default: PlayerSidebarSetting.defaultValue)
|
static let playerSidebar = Key<PlayerSidebarSetting>("playerSidebar", default: PlayerSidebarSetting.defaultValue)
|
||||||
static let playerInstanceID = Key<Instance.ID?>("playerInstance")
|
static let playerInstanceID = Key<Instance.ID?>("playerInstance")
|
||||||
static let showKeywords = Key<Bool>("showKeywords", default: false)
|
static let showKeywords = Key<Bool>("showKeywords", default: false)
|
||||||
|
static let showHistoryInPlayer = Key<Bool>("showHistoryInPlayer", default: false)
|
||||||
static let showChannelSubscribers = Key<Bool>("showChannelSubscribers", default: true)
|
static let showChannelSubscribers = Key<Bool>("showChannelSubscribers", default: true)
|
||||||
static let commentsInstanceID = Key<Instance.ID?>("commentsInstance", default: kavinPipedInstanceID)
|
static let commentsInstanceID = Key<Instance.ID?>("commentsInstance", default: kavinPipedInstanceID)
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
@ -104,7 +105,7 @@ enum ResolutionSetting: String, CaseIterable, Defaults.Serializable {
|
|||||||
var description: String {
|
var description: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .best:
|
case .best:
|
||||||
return "Best available"
|
return "Best available quality"
|
||||||
default:
|
default:
|
||||||
return value.name
|
return value.name
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import SwiftUI
|
|||||||
struct BrowsingSettings: View {
|
struct BrowsingSettings: View {
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
@Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername
|
@Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername
|
||||||
|
@Default(.roundedThumbnails) private var roundedThumbnails
|
||||||
#endif
|
#endif
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
|
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
|
||||||
@ -14,61 +15,101 @@ struct BrowsingSettings: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
Section(header: SettingsHeader(text: "Browsing")) {
|
#if os(macOS)
|
||||||
#if !os(tvOS)
|
sections
|
||||||
Toggle("Show username in the account picker button", isOn: $accountPickerDisplaysUsername)
|
#else
|
||||||
#endif
|
List {
|
||||||
|
sections
|
||||||
|
}
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
Toggle("Lock portrait mode", isOn: $lockPortraitWhenBrowsing)
|
.listStyle(.insetGrouped)
|
||||||
.onChange(of: lockPortraitWhenBrowsing) { lock in
|
|
||||||
if lock {
|
|
||||||
Orientation.lockOrientation(.portrait, andRotateTo: .portrait)
|
|
||||||
} else {
|
|
||||||
Orientation.lockOrientation(.allButUpsideDown)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
Toggle("Show channel name on thumbnail", isOn: $channelOnThumbnail)
|
#endif
|
||||||
Toggle("Show video length on thumbnail", isOn: $timeOnThumbnail)
|
|
||||||
}
|
|
||||||
Section(header: SettingsHeader(text: "Sections")) {
|
|
||||||
#if os(macOS)
|
|
||||||
let list = ForEach(VisibleSection.allCases, id: \.self) { section in
|
|
||||||
VisibleSectionSelectionRow(
|
|
||||||
title: section.title,
|
|
||||||
selected: visibleSections.contains(section)
|
|
||||||
) { value in
|
|
||||||
toggleSection(section, value: value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Group {
|
|
||||||
if #available(macOS 12.0, *) {
|
|
||||||
list
|
|
||||||
.listStyle(.inset(alternatesRowBackgrounds: true))
|
|
||||||
} else {
|
|
||||||
list
|
|
||||||
.listStyle(.inset)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
ForEach(VisibleSection.allCases, id: \.self) { section in
|
|
||||||
VisibleSectionSelectionRow(
|
|
||||||
title: section.title,
|
|
||||||
selected: visibleSections.contains(section)
|
|
||||||
) { value in
|
|
||||||
toggleSection(section, value: value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#if os(tvOS)
|
||||||
|
.frame(maxWidth: 1000)
|
||||||
|
#else
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||||
|
#endif
|
||||||
|
.navigationTitle("Browsing")
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleSection(_ section: VisibleSection, value: Bool) {
|
private var sections: some View {
|
||||||
|
Group {
|
||||||
|
#if !os(tvOS)
|
||||||
|
interfaceSettings
|
||||||
|
#endif
|
||||||
|
thumbnailsSettings
|
||||||
|
visibleSectionsSettings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var interfaceSettings: some View {
|
||||||
|
Section(header: SettingsHeader(text: "Interface")) {
|
||||||
|
#if os(iOS)
|
||||||
|
Toggle("Lock portrait mode", isOn: $lockPortraitWhenBrowsing)
|
||||||
|
.onChange(of: lockPortraitWhenBrowsing) { lock in
|
||||||
|
if lock {
|
||||||
|
Orientation.lockOrientation(.portrait, andRotateTo: .portrait)
|
||||||
|
} else {
|
||||||
|
Orientation.lockOrientation(.allButUpsideDown)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
Toggle("Show account username", isOn: $accountPickerDisplaysUsername)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var thumbnailsSettings: some View {
|
||||||
|
Section(header: SettingsHeader(text: "Thumbnails")) {
|
||||||
|
#if !os(tvOS)
|
||||||
|
Toggle("Round corners", isOn: $roundedThumbnails)
|
||||||
|
#endif
|
||||||
|
Toggle("Show channel name", isOn: $channelOnThumbnail)
|
||||||
|
Toggle("Show video length", isOn: $timeOnThumbnail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var visibleSectionsSettings: some View {
|
||||||
|
Section(header: SettingsHeader(text: "Sections")) {
|
||||||
|
#if os(macOS)
|
||||||
|
let list = ForEach(VisibleSection.allCases, id: \.self) { section in
|
||||||
|
VisibleSectionSelectionRow(
|
||||||
|
title: section.title,
|
||||||
|
selected: visibleSections.contains(section)
|
||||||
|
) { value in
|
||||||
|
toggleSection(section, value: value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Group {
|
||||||
|
if #available(macOS 12.0, *) {
|
||||||
|
list
|
||||||
|
.listStyle(.inset(alternatesRowBackgrounds: true))
|
||||||
|
} else {
|
||||||
|
list
|
||||||
|
.listStyle(.inset)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ForEach(VisibleSection.allCases, id: \.self) { section in
|
||||||
|
VisibleSectionSelectionRow(
|
||||||
|
title: section.title,
|
||||||
|
selected: visibleSections.contains(section)
|
||||||
|
) { value in
|
||||||
|
toggleSection(section, value: value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func toggleSection(_ section: VisibleSection, value: Bool) {
|
||||||
if value {
|
if value {
|
||||||
visibleSections.insert(section)
|
visibleSections.insert(section)
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,6 +18,7 @@ struct VideoCell: View {
|
|||||||
|
|
||||||
@Default(.channelOnThumbnail) private var channelOnThumbnail
|
@Default(.channelOnThumbnail) private var channelOnThumbnail
|
||||||
@Default(.timeOnThumbnail) private var timeOnThumbnail
|
@Default(.timeOnThumbnail) private var timeOnThumbnail
|
||||||
|
@Default(.roundedThumbnails) private var roundedThumbnails
|
||||||
@Default(.saveHistory) private var saveHistory
|
@Default(.saveHistory) private var saveHistory
|
||||||
@Default(.showWatchingProgress) private var showWatchingProgress
|
@Default(.showWatchingProgress) private var showWatchingProgress
|
||||||
@Default(.watchedVideoStyle) private var watchedVideoStyle
|
@Default(.watchedVideoStyle) private var watchedVideoStyle
|
||||||
@ -39,7 +40,7 @@ struct VideoCell: View {
|
|||||||
}
|
}
|
||||||
.opacity(contentOpacity)
|
.opacity(contentOpacity)
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.contentShape(RoundedRectangle(cornerRadius: 12))
|
.contentShape(RoundedRectangle(cornerRadius: thumbnailRoundingCornerRadius))
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
VideoContextMenuView(
|
VideoContextMenuView(
|
||||||
video: video,
|
video: video,
|
||||||
@ -49,6 +50,14 @@ struct VideoCell: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var thumbnailRoundingCornerRadius: Double {
|
||||||
|
#if os(tvOS)
|
||||||
|
return Double(12)
|
||||||
|
#else
|
||||||
|
return Double(roundedThumbnails ? 12 : 0)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private func playAction() {
|
private func playAction() {
|
||||||
if watchingNow {
|
if watchingNow {
|
||||||
if !player.playingInPictureInPicture {
|
if !player.playingInPictureInPicture {
|
||||||
@ -389,7 +398,7 @@ struct VideoCell: View {
|
|||||||
.font(.system(size: 30))
|
.font(.system(size: 30))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.mask(RoundedRectangle(cornerRadius: 12))
|
.mask(RoundedRectangle(cornerRadius: thumbnailRoundingCornerRadius))
|
||||||
.modifier(AspectRatioModifier())
|
.modifier(AspectRatioModifier())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user