-
Notifications
You must be signed in to change notification settings - Fork 62
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
17 changed files
with
486 additions
and
29 deletions.
There are no files selected for viewing
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
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
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,18 @@ | ||
// | ||
// AppIntent.swift | ||
// ExampleWidgets | ||
// | ||
// Created by Ryan Lepinski on 9/26/24. | ||
// | ||
|
||
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 | ||
} |
11 changes: 11 additions & 0 deletions
11
example/ios/ExampleWidgets/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 | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
example/ios/ExampleWidgets/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,35 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "tinted" | ||
} | ||
], | ||
"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
example/ios/ExampleWidgets/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,18 @@ | ||
// | ||
// ExampleWidgetsAttributes.swift | ||
// AirshipExample | ||
// | ||
// Created by Ryan Lepinski on 9/26/24. | ||
// | ||
import ActivityKit | ||
|
||
|
||
struct ExampleWidgetsAttributes: ActivityAttributes { | ||
public struct ContentState: Codable, Hashable { | ||
// Dynamic stateful properties about your activity go here! | ||
var emoji: String | ||
} | ||
|
||
// Fixed non-changing properties about your activity go here! | ||
var name: String | ||
} |
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,16 @@ | ||
// | ||
// ExampleWidgetsBundle.swift | ||
// ExampleWidgets | ||
// | ||
// Created by Ryan Lepinski on 9/26/24. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct ExampleWidgetsBundle: WidgetBundle { | ||
var body: some Widget { | ||
ExampleWidgetsLiveActivity() | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
example/ios/ExampleWidgets/ExampleWidgetsLiveActivity.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,72 @@ | ||
// | ||
// ExampleWidgetsLiveActivity.swift | ||
// ExampleWidgets | ||
// | ||
// Created by Ryan Lepinski on 9/26/24. | ||
// | ||
|
||
import ActivityKit | ||
import WidgetKit | ||
import SwiftUI | ||
|
||
|
||
|
||
struct ExampleWidgetsLiveActivity: Widget { | ||
var body: some WidgetConfiguration { | ||
ActivityConfiguration(for: ExampleWidgetsAttributes.self) { context in | ||
// Lock screen/banner UI goes here | ||
VStack { | ||
Text("Hello \(context.state.emoji)") | ||
} | ||
.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 \(context.state.emoji)") | ||
// more content | ||
} | ||
} compactLeading: { | ||
Text("L") | ||
} compactTrailing: { | ||
Text("T \(context.state.emoji)") | ||
} minimal: { | ||
Text(context.state.emoji) | ||
} | ||
.widgetURL(URL(string: "http://www.apple.com")) | ||
.keylineTint(Color.red) | ||
} | ||
} | ||
} | ||
|
||
extension ExampleWidgetsAttributes { | ||
fileprivate static var preview: ExampleWidgetsAttributes { | ||
ExampleWidgetsAttributes(name: "World") | ||
} | ||
} | ||
|
||
extension ExampleWidgetsAttributes.ContentState { | ||
fileprivate static var smiley: ExampleWidgetsAttributes.ContentState { | ||
ExampleWidgetsAttributes.ContentState(emoji: "😀") | ||
} | ||
|
||
fileprivate static var starEyes: ExampleWidgetsAttributes.ContentState { | ||
ExampleWidgetsAttributes.ContentState(emoji: "🤩") | ||
} | ||
} | ||
|
||
#Preview("Notification", as: .content, using: ExampleWidgetsAttributes.preview) { | ||
ExampleWidgetsLiveActivity() | ||
} contentStates: { | ||
ExampleWidgetsAttributes.ContentState.smiley | ||
ExampleWidgetsAttributes.ContentState.starEyes | ||
} |
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> |
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
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
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
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
Oops, something went wrong.