-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
b59f172
commit f8a1669
Showing
18 changed files
with
791 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
*.cer | ||
*.certSigningRequest | ||
|
11 changes: 11 additions & 0 deletions
11
OneSignal iOS Sample Widget/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
OneSignal iOS Sample Widget/Assets.xcassets/AppIcon.appiconset/Contents.json
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,13 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
OneSignal iOS Sample Widget/Assets.xcassets/WidgetBackground.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,11 @@ | ||
<?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>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.widgetkit-extension</string> | ||
</dict> | ||
</dict> | ||
</plist> |
59 changes: 59 additions & 0 deletions
59
OneSignal iOS Sample Widget/OneSignal_iOS_Sample_Widget.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> |
68 changes: 68 additions & 0 deletions
68
OneSignal iOS Sample Widget/OneSignal_iOS_Sample_Widget.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,68 @@ | ||
// | ||
// OneSignal_iOS_Sample_Widget.swift | ||
// OneSignal iOS Sample Widget | ||
// | ||
// Created by William Shepherd on 4/23/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) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
let date: Date | ||
let configuration: ConfigurationIntent | ||
} | ||
|
||
struct OneSignal_iOS_Sample_WidgetEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
Text(entry.date, style: .time) | ||
} | ||
} | ||
|
||
struct OneSignal_iOS_Sample_Widget: Widget { | ||
let kind: String = "OneSignal_iOS_Sample_Widget" | ||
|
||
var body: some WidgetConfiguration { | ||
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in | ||
OneSignal_iOS_Sample_WidgetEntryView(entry: entry) | ||
} | ||
.configurationDisplayName("My Widget") | ||
.description("This is an example widget.") | ||
} | ||
} | ||
|
||
struct OneSignal_iOS_Sample_Widget_Previews: PreviewProvider { | ||
static var previews: some View { | ||
OneSignal_iOS_Sample_WidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent())) | ||
.previewContext(WidgetPreviewContext(family: .systemSmall)) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
OneSignal iOS Sample Widget/OneSignal_iOS_Sample_WidgetBundle.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,17 @@ | ||
// | ||
// OneSignal_iOS_Sample_WidgetBundle.swift | ||
// OneSignal iOS Sample Widget | ||
// | ||
// Created by William Shepherd on 4/23/23. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct OneSignal_iOS_Sample_WidgetBundle: WidgetBundle { | ||
var body: some Widget { | ||
OneSignal_iOS_Sample_Widget() | ||
OneSignal_iOS_Sample_WidgetLiveActivity() | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
OneSignal iOS Sample Widget/OneSignal_iOS_Sample_WidgetLiveActivity.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,77 @@ | ||
// | ||
// OneSignal_iOS_Sample_WidgetLiveActivity.swift | ||
// OneSignal iOS Sample Widget | ||
// | ||
// Created by William Shepherd on 4/23/23. | ||
// | ||
|
||
import ActivityKit | ||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct OneSignal_iOS_Sample_WidgetAttributes: ActivityAttributes { | ||
public struct ContentState: Codable, Hashable { | ||
// Dynamic stateful properties about your activity go here! | ||
var value: Int | ||
} | ||
|
||
// Fixed non-changing properties about your activity go here! | ||
var name: String | ||
} | ||
|
||
struct OneSignal_iOS_Sample_WidgetLiveActivity: Widget { | ||
var body: some WidgetConfiguration { | ||
ActivityConfiguration(for: OneSignal_iOS_Sample_WidgetAttributes.self) { context in | ||
// Lock screen/banner UI goes here | ||
VStack { | ||
Text("Hello") | ||
} | ||
.activityBackgroundTint(Color.cyan) | ||
.activitySystemActionForegroundColor(Color.black) | ||
|
||
} dynamicIsland: { context in | ||
DynamicIsland { | ||
// Expanded UI goes here. Compose the expanded UI through | ||
// various regions, like leading/trailing/center/bottom | ||
DynamicIslandExpandedRegion(.leading) { | ||
Text("Leading") | ||
} | ||
DynamicIslandExpandedRegion(.trailing) { | ||
Text("Trailing") | ||
} | ||
DynamicIslandExpandedRegion(.bottom) { | ||
Text("Bottom") | ||
// more content | ||
} | ||
} compactLeading: { | ||
Text("L") | ||
} compactTrailing: { | ||
Text("T") | ||
} minimal: { | ||
Text("Min") | ||
} | ||
.widgetURL(URL(string: "http://www.apple.com")) | ||
.keylineTint(Color.red) | ||
} | ||
} | ||
} | ||
|
||
struct OneSignal_iOS_Sample_WidgetLiveActivity_Previews: PreviewProvider { | ||
static let attributes = OneSignal_iOS_Sample_WidgetAttributes(name: "Me") | ||
static let contentState = OneSignal_iOS_Sample_WidgetAttributes.ContentState(value: 3) | ||
|
||
static var previews: some View { | ||
attributes | ||
.previewContext(contentState, viewKind: .dynamicIsland(.compact)) | ||
.previewDisplayName("Island Compact") | ||
attributes | ||
.previewContext(contentState, viewKind: .dynamicIsland(.expanded)) | ||
.previewDisplayName("Island Expanded") | ||
attributes | ||
.previewContext(contentState, viewKind: .dynamicIsland(.minimal)) | ||
.previewDisplayName("Minimal") | ||
attributes | ||
.previewContext(contentState, viewKind: .content) | ||
.previewDisplayName("Notification") | ||
} | ||
} |
Oops, something went wrong.