diff --git a/VanControlWidget/AppIntent.swift b/VanControlWidget/AppIntent.swift deleted file mode 100644 index 7cc69bf..0000000 --- a/VanControlWidget/AppIntent.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// AppIntent.swift -// VanControlWidget -// -// Created by Christopher Helberg on 02.09.26. -// - -import WidgetKit -import AppIntents - -struct ConfigurationAppIntent: WidgetConfigurationIntent { - static var title: LocalizedStringResource { "Configuration" } - static var description: IntentDescription { "This is an example widget." } - - // An example configurable parameter. - @Parameter(title: "Favorite Emoji", default: "😃") - var favoriteEmoji: String -} diff --git a/VanControlWidget/VanControlWidget.swift b/VanControlWidget/VanControlWidget.swift deleted file mode 100644 index 27b8f59..0000000 --- a/VanControlWidget/VanControlWidget.swift +++ /dev/null @@ -1,90 +0,0 @@ -// -// VanControlWidget.swift -// VanControlWidget -// -// Created by Christopher Helberg on 02.09.26. -// - -import WidgetKit -import SwiftUI - -struct Provider: AppIntentTimelineProvider { - func placeholder(in context: Context) -> SimpleEntry { - SimpleEntry(date: Date(), configuration: ConfigurationAppIntent()) - } - - func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { - SimpleEntry(date: Date(), configuration: configuration) - } - - func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline { - var entries: [SimpleEntry] = [] - - // Generate a timeline consisting of five entries an hour apart, starting from the current date. - let currentDate = Date() - for hourOffset in 0 ..< 5 { - let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! - let entry = SimpleEntry(date: entryDate, configuration: configuration) - entries.append(entry) - } - - return Timeline(entries: entries, policy: .atEnd) - } - -// func relevances() async -> WidgetRelevances { -// // Generate a list containing the contexts this widget is relevant in. -// } -} - -struct SimpleEntry: TimelineEntry { - let date: Date - let configuration: ConfigurationAppIntent -} - -struct VanControlWidgetEntryView : View { - var entry: Provider.Entry - - var body: some View { - VStack { - Text("Time:") - Text(entry.date, style: .time) - - Text("Favorite Emoji:") - Text(entry.configuration.favoriteEmoji) - - } - } -} - -struct VanControlWidget: Widget { - let kind: String = "VanControlWidget" - - var body: some WidgetConfiguration { - AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in - VanControlWidgetEntryView(entry: entry) - .containerBackground(.fill.tertiary, for: .widget) - - } - } -} - -extension ConfigurationAppIntent { - fileprivate static var smiley: ConfigurationAppIntent { - let intent = ConfigurationAppIntent() - intent.favoriteEmoji = "😀" - return intent - } - - fileprivate static var starEyes: ConfigurationAppIntent { - let intent = ConfigurationAppIntent() - intent.favoriteEmoji = "🤩" - return intent - } -} - -#Preview(as: .systemSmall) { - VanControlWidget() -} timeline: { - SimpleEntry(date: .now, configuration: .smiley) - SimpleEntry(date: .now, configuration: .starEyes) -} diff --git a/VanControlWidget/VanControlWidgetBundle.swift b/VanControlWidget/VanControlWidgetBundle.swift index 7194d2a..80e0479 100644 --- a/VanControlWidget/VanControlWidgetBundle.swift +++ b/VanControlWidget/VanControlWidgetBundle.swift @@ -11,8 +11,6 @@ import SwiftUI @main struct VanControlWidgetBundle: WidgetBundle { var body: some Widget { - VanControlWidget() - VanControlWidgetControl() VanControlWidgetLiveActivity() } } diff --git a/VanControlWidget/VanControlWidgetControl.swift b/VanControlWidget/VanControlWidgetControl.swift deleted file mode 100644 index d544d45..0000000 --- a/VanControlWidget/VanControlWidgetControl.swift +++ /dev/null @@ -1,77 +0,0 @@ -// -// 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() - } -}