Skip to content

Commit

Permalink
Sign In Screen and Widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
debbieyuen committed May 28, 2023
1 parent 962b9ec commit d75639a
Show file tree
Hide file tree
Showing 80 changed files with 4,567 additions and 361 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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
}
}
6 changes: 6 additions & 0 deletions Hummingbird/BookWidget/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
66 changes: 66 additions & 0 deletions Hummingbird/BookWidget/BookWidget.swift
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))
}
}
17 changes: 17 additions & 0 deletions Hummingbird/BookWidget/BookWidgetBundle.swift
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()
}
}
77 changes: 77 additions & 0 deletions Hummingbird/BookWidget/BookWidgetLiveActivity.swift
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")
}
}
11 changes: 11 additions & 0 deletions Hummingbird/BookWidget/Info.plist
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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
}
}
6 changes: 6 additions & 0 deletions Hummingbird/CallWidget/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
66 changes: 66 additions & 0 deletions Hummingbird/CallWidget/CallWidget.swift
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))
}
}
17 changes: 17 additions & 0 deletions Hummingbird/CallWidget/CallWidgetBundle.swift
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()
}
}
Loading

0 comments on commit d75639a

Please sign in to comment.