From cf0975d8bf9fc7bd44bf2fb2d1a8b351798da3f9 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 23 Oct 2021 14:12:53 +0200 Subject: [PATCH] Add services settings --- Shared/Defaults.swift | 2 ++ Shared/Settings/ServicesSettings.swift | 26 ++++++++++++++++++-------- Shared/Settings/SettingsView.swift | 11 ++++++++++- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 3eec9922..aba78741 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -18,6 +18,8 @@ extension Defaults.Keys { static let lastAccountID = Key("lastAccountID") static let lastInstanceID = Key("lastInstanceID") + static let sponsorBlockInstance = Key("sponsorBlockInstance", default: "https://sponsor.ajay.app") + static let quality = Key("quality", default: .hd720pFirstThenBest) static let recentlyOpened = Key<[RecentItem]>("recentlyOpened", default: []) diff --git a/Shared/Settings/ServicesSettings.swift b/Shared/Settings/ServicesSettings.swift index 660c7c78..b6478956 100644 --- a/Shared/Settings/ServicesSettings.swift +++ b/Shared/Settings/ServicesSettings.swift @@ -1,15 +1,25 @@ -// -// ServicesSettings.swift -// Pearvidious -// -// Created by Arkadiusz Fal on 23/10/2021. -// - +import Defaults import SwiftUI struct ServicesSettings: View { + @Default(.sponsorBlockInstance) private var sponsorBlock var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + Section(header: Text("SponsorBlock API")) { + TextField( + "SponsorBlock API Instance", + text: $sponsorBlock, + prompt: Text("SponsorBlock API URL, leave blank to disable") + ) + .labelsHidden() + #if !os(macOS) + .autocapitalization(.none) + .keyboardType(.URL) + #endif + + #if os(macOS) + Spacer() + #endif + } } } diff --git a/Shared/Settings/SettingsView.swift b/Shared/Settings/SettingsView.swift index ce88c873..a36459c2 100644 --- a/Shared/Settings/SettingsView.swift +++ b/Shared/Settings/SettingsView.swift @@ -5,7 +5,7 @@ import SwiftUI struct SettingsView: View { #if os(macOS) private enum Tabs: Hashable { - case playback, instances + case playback, services, instances } #endif @@ -24,6 +24,14 @@ struct SettingsView: View { } .tag(Tabs.instances) + Form { + ServicesSettings() + } + .tabItem { + Label("Services", systemImage: "puzzlepiece.extension") + } + .tag(Tabs.services) + Form { PlaybackSettings() } @@ -41,6 +49,7 @@ struct SettingsView: View { AccountSelectionView() #endif InstancesSettings() + ServicesSettings() PlaybackSettings() } .navigationTitle("Settings")