-
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
19 changed files
with
839 additions
and
47 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,14 @@ | ||
{ | ||
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles. | ||
// Pointez pour afficher la description des attributs existants. | ||
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "example", | ||
"cwd": "example", | ||
"request": "launch", | ||
"type": "dart", | ||
}, | ||
] | ||
} |
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,22 @@ | ||
PODS: | ||
- Flutter (1.0.0) | ||
- live_activities (0.0.1): | ||
- Flutter | ||
|
||
DEPENDENCIES: | ||
- Flutter (from `Flutter`) | ||
- live_activities (from `.symlinks/plugins/live_activities/ios`) | ||
|
||
EXTERNAL SOURCES: | ||
Flutter: | ||
:path: Flutter | ||
live_activities: | ||
:path: ".symlinks/plugins/live_activities/ios" | ||
|
||
SPEC CHECKSUMS: | ||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 | ||
live_activities: 9ff56a06a2d43ecd68f56deeed13b18a8304789c | ||
|
||
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 | ||
|
||
COCOAPODS: 1.11.3 |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?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>aps-environment</key> | ||
<string>development</string> | ||
</dict> | ||
</plist> |
11 changes: 11 additions & 0 deletions
11
example/ios/extension-example/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
example/ios/extension-example/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
example/ios/extension-example/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,13 @@ | ||
<?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> | ||
<key>NSSupportsLiveActivities</key> | ||
<true/> | ||
</dict> | ||
</plist> |
59 changes: 59 additions & 0 deletions
59
example/ios/extension-example/extension_example.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> |
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,164 @@ | ||
// | ||
// extension_example.swift | ||
// extension-example | ||
// | ||
// Created by Dimitri Dessus on 28/09/2022. | ||
// | ||
|
||
import ActivityKit | ||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct Widgets: WidgetBundle { | ||
var body: some Widget { | ||
if #available(iOS 16.1, *) { | ||
GroceryDeliveryApp() | ||
} | ||
} | ||
} | ||
|
||
class PizzaData { | ||
var name: String | ||
var description: String | ||
var quantity: Int | ||
var price: Double | ||
var deliverName: String | ||
var deliverStartDate: Date | ||
var deliverEndDate: Date | ||
var deliverDate: ClosedRange<Date> | ||
|
||
init?(JSONData data:[String: String]) { | ||
self.name = data["name"]! | ||
self.description = data["description"]! | ||
self.quantity = Int(data["quantity"]!)! | ||
self.price = Double(data["price"]!)! | ||
self.deliverName = data["deliverName"]! | ||
self.deliverStartDate = Date(timeIntervalSince1970: Double(data["deliverStartDate"]!)!) | ||
self.deliverEndDate = Date(timeIntervalSince1970: Double(data["deliverEndDate"]!)!) | ||
|
||
deliverDate = self.deliverStartDate...self.deliverEndDate | ||
} | ||
} | ||
|
||
struct LiveActivitiesAppAttributes: ActivityAttributes, Identifiable { | ||
public typealias LiveDeliveryData = ContentState | ||
|
||
public struct ContentState: Codable, Hashable { | ||
var data: Dictionary<String, String> | ||
} | ||
|
||
var id = UUID() | ||
} | ||
|
||
@available(iOSApplicationExtension 16.1, *) | ||
struct GroceryDeliveryApp: Widget { | ||
|
||
var body: some WidgetConfiguration { | ||
ActivityConfiguration(for: LiveActivitiesAppAttributes.self) { context in | ||
let pizza = PizzaData(JSONData: context.state.data) | ||
VStack(alignment: .leading) { | ||
HStack { | ||
VStack(alignment: .leading) { | ||
Text("Your \(pizza!.name) is on the way!") | ||
.font(.headline) | ||
ZStack { | ||
RoundedRectangle(cornerRadius: 15) | ||
.fill(.secondary) | ||
HStack { | ||
RoundedRectangle(cornerRadius: 15) | ||
.fill(.blue) | ||
.frame(width: 50) | ||
Image(systemName: "shippingbox.circle.fill") | ||
.foregroundColor(.white) | ||
.padding(.leading, -25) | ||
Image(systemName: "arrow.forward") | ||
.foregroundColor(.white.opacity(0.5)) | ||
Image(systemName: "ellipsis") | ||
.foregroundColor(.white.opacity(0.5)) | ||
Text(timerInterval: pizza!.deliverDate, countsDown: true) | ||
.bold() | ||
.font(.caption) | ||
.foregroundColor(.white.opacity(0.8)) | ||
.multilineTextAlignment(.center) | ||
Image(systemName: "ellipsis") | ||
.foregroundColor(.white.opacity(0.5)) | ||
Image(systemName: "arrow.forward") | ||
.foregroundColor(.white.opacity(0.5)) | ||
Image(systemName: "house.circle.fill") | ||
.foregroundColor(.green) | ||
.background(.white) | ||
.clipShape(Circle()) | ||
} | ||
} | ||
} | ||
Spacer() | ||
VStack { | ||
Text("\(pizza!.description) 🍕") | ||
.font(.title) | ||
.bold() | ||
Spacer() | ||
} | ||
}.padding(5) | ||
Text("You've already paid: \(pizza!.price) + $9.9 Delivery Fee 💸") | ||
.font(.caption) | ||
.foregroundColor(.secondary) | ||
.padding(.horizontal, 5) | ||
}.padding(15) | ||
} dynamicIsland: { context in | ||
let pizza = PizzaData(JSONData: context.state.data) | ||
|
||
return DynamicIsland { | ||
DynamicIslandExpandedRegion(.leading) { | ||
Label("\(pizza!.quantity) Pizzas", systemImage: "bag") | ||
.font(.title2) | ||
} | ||
DynamicIslandExpandedRegion(.trailing) { | ||
Label { | ||
Text(timerInterval: pizza!.deliverDate, countsDown: true) | ||
.multilineTextAlignment(.trailing) | ||
.frame(width: 50) | ||
.monospacedDigit() | ||
.font(.caption2) | ||
} icon: { | ||
Image(systemName: "timer") | ||
} | ||
.font(.title2) | ||
} | ||
DynamicIslandExpandedRegion(.center) { | ||
Text("\("context.state.driverName") is on his way!") | ||
.lineLimit(1) | ||
.font(.caption) | ||
} | ||
DynamicIslandExpandedRegion(.bottom) { | ||
Button { | ||
// Deep link into the app. | ||
} label: { | ||
Label("Contact driver", systemImage: "phone") | ||
} | ||
} | ||
} compactLeading: { | ||
Label { | ||
Text("\(pizza!.quantity) Pizzas") | ||
} icon: { | ||
Image(systemName: "bag") | ||
} | ||
.font(.caption2) | ||
} compactTrailing: { | ||
Text(timerInterval: pizza!.deliverDate, countsDown: true) | ||
.multilineTextAlignment(.center) | ||
.frame(width: 40) | ||
.font(.caption2) | ||
} minimal: { | ||
VStack(alignment: .center) { | ||
Image(systemName: "timer") | ||
Text(timerInterval: pizza!.deliverDate, countsDown: true) | ||
.multilineTextAlignment(.center) | ||
.monospacedDigit() | ||
.font(.caption2) | ||
} | ||
} | ||
.keylineTint(.accentColor) | ||
} | ||
} | ||
} |
Oops, something went wrong.