Add unlock complication, improve info display
This commit is contained in:
@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"platform" : "watchos",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
6
Sesame-Widget/Assets.xcassets/Contents.json
Normal file
6
Sesame-Widget/Assets.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
11
Sesame-Widget/Info.plist
Normal file
11
Sesame-Widget/Info.plist
Normal file
@ -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>
|
58
Sesame-Widget/Sesame_Widget.swift
Normal file
58
Sesame-Widget/Sesame_Widget.swift
Normal file
@ -0,0 +1,58 @@
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
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>) -> ()) {
|
||||
let entries = [Entry(date: .now), Entry(date: .distantFuture)]
|
||||
completion(Timeline(entries: entries, policy: .atEnd))
|
||||
}
|
||||
}
|
||||
|
||||
struct SimpleEntry: TimelineEntry {
|
||||
let date: Date
|
||||
}
|
||||
|
||||
struct Sesame_WidgetEntryView : View {
|
||||
|
||||
var entry: Provider.Entry
|
||||
|
||||
var body: some View {
|
||||
Image(systemSymbol: .lock)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.padding()
|
||||
.fontWeight(.thin)
|
||||
.widgetURL(URL(string: "sesame:///open")!)
|
||||
}
|
||||
}
|
||||
|
||||
@main
|
||||
struct Sesame_Widget: Widget {
|
||||
let kind: String = "SesameOpen"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: Provider()) { entry in
|
||||
Sesame_WidgetEntryView(entry: entry)
|
||||
}
|
||||
.configurationDisplayName("Open")
|
||||
.description("This widget can be used to unlock the door with a single tap.")
|
||||
}
|
||||
}
|
||||
|
||||
struct Sesame_Widget_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Sesame_WidgetEntryView(entry: SimpleEntry(date: Date()))
|
||||
.previewContext(WidgetPreviewContext(family: .accessoryRectangular))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user