Ferrite-backup/Ferrite/Views/ComponentViews/Settings/SettingsKodiView.swift
kingbri b8799be896 Ferrite: Add Kodi support
Adds support for playing links on a preset Kodi server. This is
less featured than the Ferrite companion, but should still work
without a problem.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-03-05 14:11:52 -05:00

61 lines
2 KiB
Swift

//
// SettingsKodiView.swift
// Ferrite
//
// Created by Brian Dashore on 3/4/23.
//
import SwiftUI
struct SettingsKodiView: View {
@AppStorage("ExternalServices.KodiUrl") var kodiUrl: String = ""
@AppStorage("ExternalServices.KodiUsername") var kodiUsername: String = ""
@AppStorage("ExternalServices.KodiPassword") var kodiPassword: String = ""
@State private var showPassword = false
var body: some View {
NavView {
List {
Section(header: InlineHeader("Description")) {
VStack(alignment: .leading, spacing: 10) {
Text("Kodi is an external application that is used to manage a local media library and playback.")
Link("Website", destination: URL(string: "https://kodi.tv")!)
}
}
Section(
header: InlineHeader("Base URL"),
footer: Text("Enter your Kodi server's http URL here including the port.")
) {
TextField("http://...", text: $kodiUrl, onEditingChanged: { isFocused in
if !isFocused && kodiUrl.last == "/" {
kodiUrl = String(kodiUrl.dropLast())
}
})
.keyboardType(.URL)
.autocorrectionDisabled(true)
.autocapitalization(.none)
}
Section(
header: InlineHeader("Credentials"),
footer: Text("Enter your kodi username and password here (if applicable)")
) {
TextField("Username", text: $kodiUsername)
HybridSecureField(text: $kodiPassword)
}
}
.navigationTitle("Kodi")
.navigationBarTitleDisplayMode(.inline)
}
}
}
struct SettingsKodiView_Previews: PreviewProvider {
static var previews: some View {
SettingsKodiView()
}
}