mirror of
https://github.com/yattee/yattee.git
synced 2025-08-08 19:54:07 +00:00
Add settings for frontend instance URL
This commit is contained in:
@@ -7,8 +7,17 @@ extension Defaults.Keys {
|
||||
static let privateAccountID = "default-private-invidious-account"
|
||||
|
||||
static let instances = Key<[Instance]>("instances", default: [
|
||||
.init(app: .piped, id: pipedInstanceID, name: "Public", url: "https://pipedapi.kavin.rocks"),
|
||||
.init(app: .invidious, id: invidiousInstanceID, name: "Private", url: "https://invidious.home.arekf.net")
|
||||
.init(
|
||||
app: .piped,
|
||||
id: pipedInstanceID,
|
||||
name: "Public",
|
||||
apiURL: "https://pipedapi.kavin.rocks",
|
||||
frontendURL: "https://piped.kavin.rocks"
|
||||
),
|
||||
.init(app: .invidious,
|
||||
id: invidiousInstanceID,
|
||||
name: "Private",
|
||||
apiURL: "https://invidious.home.arekf.net")
|
||||
])
|
||||
static let accounts = Key<[Account]>("accounts", default: [
|
||||
.init(
|
||||
|
@@ -133,8 +133,8 @@ struct AccountForm: View {
|
||||
private var validator: AccountValidator {
|
||||
AccountValidator(
|
||||
app: .constant(instance.app),
|
||||
url: instance.url,
|
||||
account: Account(instanceID: instance.id, url: instance.url, sid: sid),
|
||||
url: instance.apiURL,
|
||||
account: Account(instanceID: instance.id, url: instance.apiURL, sid: sid),
|
||||
id: $sid,
|
||||
isValid: $isValid,
|
||||
isValidated: $isValidated,
|
||||
|
@@ -6,6 +6,8 @@ struct AccountsSettings: View {
|
||||
@State private var accountsChanged = false
|
||||
@State private var presentingAccountForm = false
|
||||
|
||||
@State private var frontendURL = ""
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var model
|
||||
@EnvironmentObject<InstancesModel> private var instances
|
||||
|
||||
@@ -14,56 +16,81 @@ struct AccountsSettings: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if instance.app.supportsAccounts {
|
||||
accounts
|
||||
} else {
|
||||
Text("Accounts are not supported for the application of this instance")
|
||||
.foregroundColor(.secondary)
|
||||
List {
|
||||
if instance.app.hasFrontendURL {
|
||||
Section(header: Text("Frontend URL")) {
|
||||
TextField(
|
||||
"Frontend URL",
|
||||
text: $frontendURL,
|
||||
prompt: Text("To enable videos, channels and playlists sharing")
|
||||
)
|
||||
.onAppear {
|
||||
frontendURL = instance.frontendURL ?? ""
|
||||
}
|
||||
.onChange(of: frontendURL) { newValue in
|
||||
InstancesModel.setFrontendURL(instance, newValue)
|
||||
}
|
||||
.labelsHidden()
|
||||
.autocapitalization(.none)
|
||||
.keyboardType(.URL)
|
||||
}
|
||||
}
|
||||
|
||||
Section(header: Text("Accounts"), footer: sectionFooter) {
|
||||
if instance.app.supportsAccounts {
|
||||
accounts
|
||||
} else {
|
||||
Text("Accounts are not supported for the application of this instance")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle(instance.shortDescription)
|
||||
#if os(tvOS)
|
||||
.frame(maxWidth: 1000)
|
||||
#endif
|
||||
|
||||
.navigationTitle(instance.description)
|
||||
}
|
||||
|
||||
var accounts: some View {
|
||||
List {
|
||||
Section(header: Text("Accounts"), footer: sectionFooter) {
|
||||
ForEach(InstancesModel.accounts(instanceID), id: \.self) { account in
|
||||
#if os(tvOS)
|
||||
Button(account.description) {}
|
||||
.contextMenu {
|
||||
Button("Remove", role: .destructive) { removeAccount(account) }
|
||||
Button("Cancel", role: .cancel) {}
|
||||
}
|
||||
#else
|
||||
Text(account.description)
|
||||
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
|
||||
Button("Remove", role: .destructive) { removeAccount(account) }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.redrawOn(change: accountsChanged)
|
||||
Group {
|
||||
ForEach(InstancesModel.accounts(instanceID), id: \.self) { account in
|
||||
#if os(tvOS)
|
||||
Button(account.description) {}
|
||||
.contextMenu {
|
||||
Button("Remove", role: .destructive) { removeAccount(account) }
|
||||
Button("Cancel", role: .cancel) {}
|
||||
}
|
||||
#else
|
||||
Text(account.description)
|
||||
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
|
||||
Button("Remove", role: .destructive) { removeAccount(account) }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.redrawOn(change: accountsChanged)
|
||||
|
||||
Button("Add account...") {
|
||||
presentingAccountForm = true
|
||||
}
|
||||
Button("Add account...") {
|
||||
presentingAccountForm = true
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $presentingAccountForm, onDismiss: { accountsChanged.toggle() }) {
|
||||
AccountForm(instance: instance)
|
||||
}
|
||||
#if os(iOS)
|
||||
#if !os(tvOS)
|
||||
.listStyle(.insetGrouped)
|
||||
#elseif os(tvOS)
|
||||
.frame(maxWidth: 1000)
|
||||
#endif
|
||||
}
|
||||
|
||||
private var sectionFooter: some View {
|
||||
if !instance.app.supportsAccounts {
|
||||
return Text("")
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
Text("Swipe to remove account")
|
||||
return Text("Swipe to remove account")
|
||||
#else
|
||||
Text("Tap and hold to remove account")
|
||||
return Text("Tap and hold to remove account")
|
||||
.foregroundColor(.secondary)
|
||||
#endif
|
||||
}
|
||||
|
@@ -82,7 +82,8 @@ struct InstanceForm: View {
|
||||
TextField("Name", text: $name, prompt: Text("Instance Name (optional)"))
|
||||
.focused($nameFieldFocused)
|
||||
|
||||
TextField("URL", text: $url, prompt: Text("https://invidious.home.net"))
|
||||
TextField("API URL", text: $url, prompt: Text("https://invidious.home.net"))
|
||||
|
||||
#if !os(macOS)
|
||||
.autocapitalization(.none)
|
||||
.keyboardType(.URL)
|
||||
|
@@ -19,7 +19,7 @@ struct ServicesSettings: View {
|
||||
#endif
|
||||
}
|
||||
|
||||
Section(header: Text("SponsorBlock Categories to Skip")) {
|
||||
Section(header: Text("Categories to Skip")) {
|
||||
#if os(macOS)
|
||||
List(SponsorBlockAPI.categories, id: \.self) { category in
|
||||
SponsorBlockCategorySelectionRow(
|
||||
|
Reference in New Issue
Block a user