From f443d434f2d2375544f06c1cafbc68a5d89477a2 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Mon, 6 Jul 2026 22:03:37 +0200 Subject: [PATCH] Removed boilerplated widget source code from the Attendi widget target. --- Attendi.xcodeproj/project.pbxproj | 2 - .../Sources/Bundle/AttendiWidgetBundle.swift | 1 - .../Attendi/Sources/Intents/AppIntent.swift | 18 ---- .../Sources/Widgets/AttendiWidget.swift | 91 ------------------- 4 files changed, 112 deletions(-) delete mode 100644 Widgets/Attendi/Sources/Intents/AppIntent.swift delete mode 100644 Widgets/Attendi/Sources/Widgets/AttendiWidget.swift diff --git a/Attendi.xcodeproj/project.pbxproj b/Attendi.xcodeproj/project.pbxproj index ac55a75..7b62627 100644 --- a/Attendi.xcodeproj/project.pbxproj +++ b/Attendi.xcodeproj/project.pbxproj @@ -83,7 +83,6 @@ Attendi/Catalogs/Localizable.xcstrings, Attendi/Sources/Bundle/AttendiWidgetBundle.swift, "Attendi/Sources/Extensions/Image+Symbols.swift", - Attendi/Sources/Intents/AppIntent.swift, Attendi/Sources/Intents/DiscardRecordingIntent.swift, Attendi/Sources/Intents/ProcessRecordingIntent.swift, Attendi/Sources/Intents/ToggleRecordingIntent.swift, @@ -92,7 +91,6 @@ Attendi/Sources/Views/RecordingLiveActivityView.swift, Attendi/Sources/Views/RecordingStateLabel.swift, Attendi/Sources/Views/RecordingTimerText.swift, - Attendi/Sources/Widgets/AttendiWidget.swift, Attendi/Sources/Widgets/RecordingLiveActivity.swift, ); target = 0296F7ED2FFAB1B600D2C5FC /* AttendiWidgetExtension */; diff --git a/Widgets/Attendi/Sources/Bundle/AttendiWidgetBundle.swift b/Widgets/Attendi/Sources/Bundle/AttendiWidgetBundle.swift index a6e3a73..34dc8a7 100644 --- a/Widgets/Attendi/Sources/Bundle/AttendiWidgetBundle.swift +++ b/Widgets/Attendi/Sources/Bundle/AttendiWidgetBundle.swift @@ -8,7 +8,6 @@ struct AttendiWidgetBundle: WidgetBundle { /// The widgets and Live Activities the bundle exposes. var body: some Widget { - AttendiWidget() RecordingLiveActivity() } diff --git a/Widgets/Attendi/Sources/Intents/AppIntent.swift b/Widgets/Attendi/Sources/Intents/AppIntent.swift deleted file mode 100644 index 35556f4..0000000 --- a/Widgets/Attendi/Sources/Intents/AppIntent.swift +++ /dev/null @@ -1,18 +0,0 @@ -import WidgetKit -import AppIntents - -/// The configuration intent of the ``AttendiWidget`` placeholder, as scaffolded by the Xcode widget template. -struct ConfigurationAppIntent: WidgetConfigurationIntent { - - // MARK: Constants - - static var title: LocalizedStringResource { "Configuration" } - static var description: IntentDescription { "This is an example widget." } - - // MARK: Properties - - /// An example configurable parameter. - @Parameter(title: "Favorite Emoji", default: "😃") - var favoriteEmoji: String - -} diff --git a/Widgets/Attendi/Sources/Widgets/AttendiWidget.swift b/Widgets/Attendi/Sources/Widgets/AttendiWidget.swift deleted file mode 100644 index 766ffb0..0000000 --- a/Widgets/Attendi/Sources/Widgets/AttendiWidget.swift +++ /dev/null @@ -1,91 +0,0 @@ -import WidgetKit -import SwiftUI - -/// The timeline provider of the ``AttendiWidget`` placeholder, producing entries from the widget's configuration intent. -struct Provider: AppIntentTimelineProvider { - - /// Returns a generic entry the system shows while the widget loads. - func placeholder(in context: Context) -> SimpleEntry { - SimpleEntry(date: Date(), configuration: ConfigurationAppIntent()) - } - - /// Returns a single entry for the given configuration, shown in transient contexts like the widget gallery. - func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { - SimpleEntry(date: Date(), configuration: configuration) - } - - /// Returns a timeline of five entries an hour apart, starting from the current date. - 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. -// } -} - -/// A timeline entry of the ``AttendiWidget`` placeholder. -struct SimpleEntry: TimelineEntry { - /// The instant the entry applies to. - let date: Date - /// The configuration of the widget at the time of the entry. - let configuration: ConfigurationAppIntent -} - -/// The view rendering a timeline entry of the ``AttendiWidget`` placeholder: the entry's time and the configured emoji. -struct AttendiWidgetEntryView : View { - /// The timeline entry to render. - var entry: Provider.Entry - - var body: some View { - Text("Time:") - Text(entry.date, style: .time) - - Text("Favorite Emoji:") - Text(entry.configuration.favoriteEmoji) - } -} - -/// The placeholder Home Screen widget scaffolded by the Xcode widget template, yet to be replaced by the app's own widget. -struct AttendiWidget: Widget { - /// The identifier of the widget's kind. - let kind: String = "AttendiWidget" - - var body: some WidgetConfiguration { - AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in - AttendiWidgetEntryView(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) { - AttendiWidget() -} timeline: { - SimpleEntry(date: .now, configuration: .smiley) - SimpleEntry(date: .now, configuration: .starEyes) -}