You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Musubi/App/Sources/SettingsView.swift

48 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import DesignSystem
import MusubiCore
import Remote
import SwiftUI
struct SettingsView: View {
let coordinator: Coordinator
@State private var interfaces: [NetworkInterfaces.Info] = []
@State private var launchAtLogin = false
private var settings: AppSettings { coordinator.settings }
var body: some View {
Form {
Picker("Rolle", selection: Binding(get: { settings.role }, set: { settings.role = $0; restart() })) {
Text("Regie – steuert Knoten, verwaltet Szenen").tag(Role.control)
Text("Knoten – folgt der Regie").tag(Role.node)
}
Picker("Technik-Netz", selection: Binding(get: { settings.interfaceName }, set: { settings.interfaceName = $0; restart() })) {
ForEach(interfaces) { interface in
Text(verbatim: "\(interface.name) · \(interface.kind)").tag(interface.name)
}
if !interfaces.contains(where: { $0.name == settings.interfaceName }) {
Text(verbatim: "\(settings.interfaceName) · nicht verbunden").tag(settings.interfaceName)
}
}
Text("Regie und Knoten finden sich nur über diese Schnittstelle.")
.font(Theme.Font.caption)
.foregroundStyle(Theme.Color.nezumi)
Toggle("Beim Anmelden starten", isOn: Binding(get: { launchAtLogin }, set: {
settings.launchAtLogin = $0
launchAtLogin = settings.launchAtLogin
}))
LabeledContent("Name im Netz") { Text(verbatim: settings.machineName) }
}
.formStyle(.grouped)
.frame(width: 460)
.task {
interfaces = await NetworkInterfaces.available()
launchAtLogin = settings.launchAtLogin
}
}
private func restart() {
Task { await coordinator.startRemote() }
}
}

Powered by TurnKey Linux.