-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
191 additions
and
178 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
117 changes: 53 additions & 64 deletions
117
Tests/XcodeTests/UIKitProject/UIKitProject.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
59 changes: 59 additions & 0 deletions
59
Tests/XcodeTests/UIKitProject/WatchWidget/WatchWidget.intentdefinition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>INEnums</key> | ||
<array/> | ||
<key>INIntentDefinitionModelVersion</key> | ||
<string>1.2</string> | ||
<key>INIntentDefinitionNamespace</key> | ||
<string>88xZPY</string> | ||
<key>INIntentDefinitionSystemVersion</key> | ||
<string>20A294</string> | ||
<key>INIntentDefinitionToolsBuildVersion</key> | ||
<string>12A6144</string> | ||
<key>INIntentDefinitionToolsVersion</key> | ||
<string>12.0</string> | ||
<key>INIntents</key> | ||
<array> | ||
<dict> | ||
<key>INIntentCategory</key> | ||
<string>information</string> | ||
<key>INIntentDescriptionID</key> | ||
<string>tVvJ9c</string> | ||
<key>INIntentEligibleForWidgets</key> | ||
<true/> | ||
<key>INIntentIneligibleForSuggestions</key> | ||
<true/> | ||
<key>INIntentName</key> | ||
<string>Configuration</string> | ||
<key>INIntentResponse</key> | ||
<dict> | ||
<key>INIntentResponseCodes</key> | ||
<array> | ||
<dict> | ||
<key>INIntentResponseCodeName</key> | ||
<string>success</string> | ||
<key>INIntentResponseCodeSuccess</key> | ||
<true/> | ||
</dict> | ||
<dict> | ||
<key>INIntentResponseCodeName</key> | ||
<string>failure</string> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>INIntentTitle</key> | ||
<string>Configuration</string> | ||
<key>INIntentTitleID</key> | ||
<string>gpCwrM</string> | ||
<key>INIntentType</key> | ||
<string>Custom</string> | ||
<key>INIntentVerb</key> | ||
<string>View</string> | ||
</dict> | ||
</array> | ||
<key>INTypes</key> | ||
<array/> | ||
</dict> | ||
</plist> |
75 changes: 75 additions & 0 deletions
75
Tests/XcodeTests/UIKitProject/WatchWidget/WatchWidget.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// WatchWidget.swift | ||
// WatchWidget | ||
// | ||
// Created by Ian Leitch on 30.10.23. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
import Intents | ||
|
||
struct Provider: IntentTimelineProvider { | ||
func placeholder(in context: Context) -> SimpleEntry { | ||
SimpleEntry(date: Date(), configuration: ConfigurationIntent()) | ||
} | ||
|
||
func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) { | ||
let entry = SimpleEntry(date: Date(), configuration: configuration) | ||
completion(entry) | ||
} | ||
|
||
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | ||
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) | ||
} | ||
|
||
let timeline = Timeline(entries: entries, policy: .atEnd) | ||
completion(timeline) | ||
} | ||
|
||
func recommendations() -> [IntentRecommendation<ConfigurationIntent>] { | ||
return [ | ||
IntentRecommendation(intent: ConfigurationIntent(), description: "My Intent Widget") | ||
] | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
let date: Date | ||
let configuration: ConfigurationIntent | ||
} | ||
|
||
struct WatchWidgetEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
Text(entry.date, style: .time) | ||
} | ||
} | ||
|
||
@main | ||
struct WatchWidget: Widget { | ||
let kind: String = "WatchWidget" | ||
|
||
var body: some WidgetConfiguration { | ||
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in | ||
WatchWidgetEntryView(entry: entry) | ||
} | ||
.configurationDisplayName("My Widget") | ||
.description("This is an example widget.") | ||
} | ||
} | ||
|
||
struct WatchWidget_Previews: PreviewProvider { | ||
static var previews: some View { | ||
WatchWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent())) | ||
.previewContext(WidgetPreviewContext(family: .accessoryRectangular)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters