-
Notifications
You must be signed in to change notification settings - Fork 0
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
962b9ec
commit d75639a
Showing
80 changed files
with
4,567 additions
and
361 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
Hummingbird/BookWidget/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
Hummingbird/BookWidget/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
Hummingbird/BookWidget/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,66 @@ | ||
// | ||
// BookWidget.swift | ||
// BookWidget | ||
// | ||
// Created by Debbie Yuen on 5/28/23. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct Provider: TimelineProvider { | ||
func placeholder(in context: Context) -> SimpleEntry { | ||
SimpleEntry(date: Date()) | ||
} | ||
|
||
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { | ||
let entry = SimpleEntry(date: Date()) | ||
completion(entry) | ||
} | ||
|
||
func getTimeline(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) | ||
entries.append(entry) | ||
} | ||
|
||
let timeline = Timeline(entries: entries, policy: .atEnd) | ||
completion(timeline) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
let date: Date | ||
} | ||
|
||
struct BookWidgetEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
Text(entry.date, style: .time) | ||
} | ||
} | ||
|
||
struct BookWidget: Widget { | ||
let kind: String = "BookWidget" | ||
|
||
var body: some WidgetConfiguration { | ||
StaticConfiguration(kind: kind, provider: Provider()) { entry in | ||
BookWidgetEntryView(entry: entry) | ||
} | ||
.configurationDisplayName("My Widget") | ||
.description("This is an example widget.") | ||
} | ||
} | ||
|
||
struct BookWidget_Previews: PreviewProvider { | ||
static var previews: some View { | ||
BookWidgetEntryView(entry: SimpleEntry(date: Date())) | ||
.previewContext(WidgetPreviewContext(family: .systemSmall)) | ||
} | ||
} |
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 @@ | ||
// | ||
// BookWidgetBundle.swift | ||
// BookWidget | ||
// | ||
// Created by Debbie Yuen on 5/28/23. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct BookWidgetBundle: WidgetBundle { | ||
var body: some Widget { | ||
BookWidget() | ||
BookWidgetLiveActivity() | ||
} | ||
} |
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 @@ | ||
// | ||
// BookWidgetLiveActivity.swift | ||
// BookWidget | ||
// | ||
// Created by Debbie Yuen on 5/28/23. | ||
// | ||
|
||
import ActivityKit | ||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct BookWidgetAttributes: 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 BookWidgetLiveActivity: Widget { | ||
var body: some WidgetConfiguration { | ||
ActivityConfiguration(for: BookWidgetAttributes.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 BookWidgetLiveActivity_Previews: PreviewProvider { | ||
static let attributes = BookWidgetAttributes(name: "Me") | ||
static let contentState = BookWidgetAttributes.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") | ||
} | ||
} |
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> |
11 changes: 11 additions & 0 deletions
11
Hummingbird/CallWidget/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
Hummingbird/CallWidget/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
Hummingbird/CallWidget/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,66 @@ | ||
// | ||
// CallWidget.swift | ||
// CallWidget | ||
// | ||
// Created by Debbie Yuen on 5/28/23. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct Provider: TimelineProvider { | ||
func placeholder(in context: Context) -> SimpleEntry { | ||
SimpleEntry(date: Date()) | ||
} | ||
|
||
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { | ||
let entry = SimpleEntry(date: Date()) | ||
completion(entry) | ||
} | ||
|
||
func getTimeline(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) | ||
entries.append(entry) | ||
} | ||
|
||
let timeline = Timeline(entries: entries, policy: .atEnd) | ||
completion(timeline) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
let date: Date | ||
} | ||
|
||
struct CallWidgetEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
Text(entry.date, style: .time) | ||
} | ||
} | ||
|
||
struct CallWidget: Widget { | ||
let kind: String = "CallWidget" | ||
|
||
var body: some WidgetConfiguration { | ||
StaticConfiguration(kind: kind, provider: Provider()) { entry in | ||
CallWidgetEntryView(entry: entry) | ||
} | ||
.configurationDisplayName("My Widget") | ||
.description("This is an example widget.") | ||
} | ||
} | ||
|
||
struct CallWidget_Previews: PreviewProvider { | ||
static var previews: some View { | ||
CallWidgetEntryView(entry: SimpleEntry(date: Date())) | ||
.previewContext(WidgetPreviewContext(family: .systemSmall)) | ||
} | ||
} |
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 @@ | ||
// | ||
// CallWidgetBundle.swift | ||
// CallWidget | ||
// | ||
// Created by Debbie Yuen on 5/28/23. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct CallWidgetBundle: WidgetBundle { | ||
var body: some Widget { | ||
CallWidget() | ||
CallWidgetLiveActivity() | ||
} | ||
} |
Oops, something went wrong.