mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add setting for displaying comments in separate tab or below description
This commit is contained in:
parent
f7fc2369e3
commit
3624c9619a
@ -29,6 +29,12 @@ final class CommentsModel: ObservableObject {
|
|||||||
!Defaults[.commentsInstanceID].isNil && !Defaults[.commentsInstanceID]!.isEmpty
|
!Defaults[.commentsInstanceID].isNil && !Defaults[.commentsInstanceID]!.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
static var placement: CommentsPlacement {
|
||||||
|
Defaults[.commentsPlacement]
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
var nextPageAvailable: Bool {
|
var nextPageAvailable: Bool {
|
||||||
!(nextPage?.isEmpty ?? true)
|
!(nextPage?.isEmpty ?? true)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@ extension Defaults.Keys {
|
|||||||
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 commentsInstanceID = Key<Instance.ID?>("commentsInstance", default: kavinPipedInstanceID)
|
static let commentsInstanceID = Key<Instance.ID?>("commentsInstance", default: kavinPipedInstanceID)
|
||||||
|
#if !os(tvOS)
|
||||||
|
static let commentsPlacement = Key<CommentsPlacement>("commentsPlacement", default: .separate)
|
||||||
|
#endif
|
||||||
|
|
||||||
static let recentlyOpened = Key<[RecentItem]>("recentlyOpened", default: [])
|
static let recentlyOpened = Key<[RecentItem]>("recentlyOpened", default: [])
|
||||||
|
|
||||||
@ -129,3 +132,9 @@ enum VisibleSection: String, CaseIterable, Comparable, Defaults.Serializable {
|
|||||||
lhs.sortOrder < rhs.sortOrder
|
lhs.sortOrder < rhs.sortOrder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
enum CommentsPlacement: String, CaseIterable, Defaults.Serializable {
|
||||||
|
case info, separate
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -65,7 +65,7 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
if CommentsModel.enabled {
|
if CommentsModel.enabled, CommentsModel.placement == .separate {
|
||||||
pagePicker
|
pagePicker
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
@ -245,13 +245,13 @@ struct VideoDetails: View {
|
|||||||
Picker("Page", selection: $currentPage) {
|
Picker("Page", selection: $currentPage) {
|
||||||
if !video.isNil {
|
if !video.isNil {
|
||||||
Text("Info").tag(Page.info)
|
Text("Info").tag(Page.info)
|
||||||
if !sidebarQueue {
|
if CommentsModel.enabled, CommentsModel.placement == .separate {
|
||||||
Text("Related").tag(Page.related)
|
|
||||||
}
|
|
||||||
if CommentsModel.enabled {
|
|
||||||
Text("Comments")
|
Text("Comments")
|
||||||
.tag(Page.comments)
|
.tag(Page.comments)
|
||||||
}
|
}
|
||||||
|
if !sidebarQueue {
|
||||||
|
Text("Related").tag(Page.related)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !sidebarQueue {
|
if !sidebarQueue {
|
||||||
Text("Queue").tag(Page.queue)
|
Text("Queue").tag(Page.queue)
|
||||||
@ -365,6 +365,7 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var detailsPage: some View {
|
var detailsPage: some View {
|
||||||
|
Group {
|
||||||
Group {
|
Group {
|
||||||
if let video = player.currentItem?.video {
|
if let video = player.currentItem?.video {
|
||||||
Group {
|
Group {
|
||||||
@ -393,7 +394,6 @@ struct VideoDetails: View {
|
|||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.font(.system(size: 14))
|
.font(.system(size: 14))
|
||||||
.lineSpacing(3)
|
.lineSpacing(3)
|
||||||
.padding(.bottom, 4)
|
|
||||||
} else {
|
} else {
|
||||||
Text("No description")
|
Text("No description")
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
@ -423,8 +423,24 @@ struct VideoDetails: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !video.isNil, CommentsModel.placement == .info {
|
||||||
|
Divider()
|
||||||
|
#if os(macOS)
|
||||||
|
.padding(.bottom, 20)
|
||||||
|
#else
|
||||||
|
.padding(.vertical, 10)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
|
Group {
|
||||||
|
if !video.isNil, CommentsModel.placement == .info {
|
||||||
|
CommentsView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func videoDetail(label: String, value: String, symbol: String) -> some View {
|
func videoDetail(label: String, value: String, symbol: String) -> some View {
|
||||||
|
@ -6,9 +6,17 @@ struct ServicesSettings: View {
|
|||||||
@Default(.sponsorBlockCategories) private var sponsorBlockCategories
|
@Default(.sponsorBlockCategories) private var sponsorBlockCategories
|
||||||
@Default(.commentsInstanceID) private var commentsInstanceID
|
@Default(.commentsInstanceID) private var commentsInstanceID
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
@Default(.commentsPlacement) private var commentsPlacement
|
||||||
|
#endif
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Section(header: SettingsHeader(text: "Comments")) {
|
Section(header: SettingsHeader(text: "Comments")) {
|
||||||
commentsInstancePicker
|
commentsInstancePicker
|
||||||
|
#if !os(tvOS)
|
||||||
|
commentsPlacementPicker
|
||||||
|
.disabled(!CommentsModel.enabled)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Section(header: SettingsHeader(text: "SponsorBlock API")) {
|
Section(header: SettingsHeader(text: "SponsorBlock API")) {
|
||||||
@ -58,7 +66,7 @@ struct ServicesSettings: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var commentsInstancePicker: some View {
|
private var commentsInstancePicker: some View {
|
||||||
Picker("Comments", selection: $commentsInstanceID) {
|
Picker("Source", selection: $commentsInstanceID) {
|
||||||
Text("Disabled").tag(Optional(""))
|
Text("Disabled").tag(Optional(""))
|
||||||
|
|
||||||
ForEach(InstancesModel.all.filter { $0.app.supportsComments }) { instance in
|
ForEach(InstancesModel.all.filter { $0.app.supportsComments }) { instance in
|
||||||
@ -73,6 +81,19 @@ struct ServicesSettings: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !os(tvOS)
|
||||||
|
private var commentsPlacementPicker: some View {
|
||||||
|
Picker("Placement", selection: $commentsPlacement) {
|
||||||
|
Text("Below video description").tag(CommentsPlacement.info)
|
||||||
|
Text("Separate tab").tag(CommentsPlacement.separate)
|
||||||
|
}
|
||||||
|
.labelsHidden()
|
||||||
|
#if os(iOS)
|
||||||
|
.pickerStyle(.automatic)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
func toggleCategory(_ category: String, value: Bool) {
|
func toggleCategory(_ category: String, value: Bool) {
|
||||||
if let index = sponsorBlockCategories.firstIndex(where: { $0 == category }), !value {
|
if let index = sponsorBlockCategories.firstIndex(where: { $0 == category }), !value {
|
||||||
sponsorBlockCategories.remove(at: index)
|
sponsorBlockCategories.remove(at: index)
|
||||||
|
Loading…
Reference in New Issue
Block a user