Comments (fixes #4)

This commit is contained in:
Arkadiusz Fal
2021-12-04 20:35:41 +01:00
parent eb537676e6
commit 19a3f08336
29 changed files with 688 additions and 68 deletions

View File

@@ -57,7 +57,7 @@ struct PlaybackSettings: View {
Text("Best available stream").tag(String?.none)
ForEach(instances) { instance in
Text(instance.longDescription).tag(Optional(instance.id))
Text(instance.description).tag(Optional(instance.id))
}
}
.labelsHidden()

View File

@@ -4,8 +4,13 @@ import SwiftUI
struct ServicesSettings: View {
@Default(.sponsorBlockInstance) private var sponsorBlockInstance
@Default(.sponsorBlockCategories) private var sponsorBlockCategories
@Default(.commentsInstanceID) private var commentsInstanceID
var body: some View {
Section(header: SettingsHeader(text: "Comments")) {
commentsInstancePicker
}
Section(header: SettingsHeader(text: "SponsorBlock API")) {
TextField(
"SponsorBlock API Instance",
@@ -52,6 +57,22 @@ struct ServicesSettings: View {
}
}
private var commentsInstancePicker: some View {
Picker("Comments", selection: $commentsInstanceID) {
Text("Disabled").tag(String?.none)
ForEach(InstancesModel.all.filter { $0.app.supportsComments }) { instance in
Text(instance.description).tag(Optional(instance.id))
}
}
.labelsHidden()
#if os(iOS)
.pickerStyle(.automatic)
#elseif os(tvOS)
.pickerStyle(.inline)
#endif
}
func toggleCategory(_ category: String, value: Bool) {
if let index = sponsorBlockCategories.firstIndex(where: { $0 == category }), !value {
sponsorBlockCategories.remove(at: index)