forked from fritob/Camper-Monitor
CamperMonitor (Haupt-Repo) und VanAligneiOS (aus dem gemergten solar-integration-Branch) liefen unter zwei verschiedenen internen Namen, obwohl die App nach aussen längst einheitlich "VanControl Pro" heisst. Jetzt durchgängig VanControl: - Ordner: CamperMonitor/, CamperMonitorWatch/, CamperMonitorComplication/, VanAligneiOSWidget/ → VanControl/, VanControlWatch/, VanControlComplication/, VanControlWidget/ - Xcode-Projekt: CamperMonitor.xcodeproj → VanControl.xcodeproj, alle Targets/Schemes/Produktnamen entsprechend umbenannt - Bundle-Identifier auf Wunsch mitgeändert: de.s0.fototeddy.VanControl* (App noch nicht veröffentlicht); dabei auch die WKCompanionAppBundleIdentifier-Werte korrigiert, die noch das alte de.fritob-Präfix statt des tatsächlichen de.s0.fototeddy-Präfixes trugen - Swift-Dateien/Typen: CamperMonitorApp → VanControlApp, VanAligneiOSWidget* → VanControlWidget* - Config/*-Info.plist umbenannt, README.md/Tools/README.md/run-tests.sh auf die neuen Pfade angepasst Bewusst unverändert: firmware/vanalign und alle Bezüge auf "VanAlign" als Namen der Neigungsmesser-Hardware (eigenständiges Produkt, kein App-Name) sowie der komplette Android/-Ordner. Build (App, Watch, Debug) und Protokoll-Testlauf grün. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
78 lines
2.0 KiB
Swift
78 lines
2.0 KiB
Swift
//
|
|
// VanControlWidgetControl.swift
|
|
// VanControlWidget
|
|
//
|
|
// Created by Christopher Helberg on 02.09.26.
|
|
//
|
|
|
|
import AppIntents
|
|
import SwiftUI
|
|
import WidgetKit
|
|
|
|
struct VanControlWidgetControl: ControlWidget {
|
|
static let kind: String = "fototeddy.VanControl.VanControlWidget"
|
|
|
|
var body: some ControlWidgetConfiguration {
|
|
AppIntentControlConfiguration(
|
|
kind: Self.kind,
|
|
provider: Provider()
|
|
) { value in
|
|
ControlWidgetToggle(
|
|
"Start Timer",
|
|
isOn: value.isRunning,
|
|
action: StartTimerIntent(value.name)
|
|
) { isRunning in
|
|
Label(isRunning ? "On" : "Off", systemImage: "timer")
|
|
}
|
|
}
|
|
.displayName("Timer")
|
|
.description("A an example control that runs a timer.")
|
|
}
|
|
}
|
|
|
|
extension VanControlWidgetControl {
|
|
struct Value {
|
|
var isRunning: Bool
|
|
var name: String
|
|
}
|
|
|
|
struct Provider: AppIntentControlValueProvider {
|
|
func previewValue(configuration: TimerConfiguration) -> Value {
|
|
VanControlWidgetControl.Value(isRunning: false, name: configuration.timerName)
|
|
}
|
|
|
|
func currentValue(configuration: TimerConfiguration) async throws -> Value {
|
|
let isRunning = true // Check if the timer is running
|
|
return VanControlWidgetControl.Value(isRunning: isRunning, name: configuration.timerName)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct TimerConfiguration: ControlConfigurationIntent {
|
|
static let title: LocalizedStringResource = "Timer Name Configuration"
|
|
|
|
@Parameter(title: "Timer Name", default: "Timer")
|
|
var timerName: String
|
|
}
|
|
|
|
struct StartTimerIntent: SetValueIntent {
|
|
static let title: LocalizedStringResource = "Start a timer"
|
|
|
|
@Parameter(title: "Timer Name")
|
|
var name: String
|
|
|
|
@Parameter(title: "Timer is running")
|
|
var value: Bool
|
|
|
|
init() {}
|
|
|
|
init(_ name: String) {
|
|
self.name = name
|
|
}
|
|
|
|
func perform() async throws -> some IntentResult {
|
|
// Start the timer…
|
|
return .result()
|
|
}
|
|
}
|