2023-03-01 23:49:38 -08:00
|
|
|
////
|
|
|
|
|
//// Widgets.swift
|
|
|
|
|
//// Widgets
|
|
|
|
|
////
|
|
|
|
|
//// Created by Garth Vander Houwen on 2/28/23.
|
|
|
|
|
////
|
2023-02-28 21:02:50 -08:00
|
|
|
//
|
2023-03-06 10:33:18 -08:00
|
|
|
// import WidgetKit
|
|
|
|
|
// import SwiftUI
|
2023-03-01 23:49:38 -08:00
|
|
|
//
|
2023-03-06 10:33:18 -08:00
|
|
|
// struct Provider: TimelineProvider {
|
2023-03-01 23:49:38 -08:00
|
|
|
// 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)
|
|
|
|
|
// }
|
2023-03-06 10:33:18 -08:00
|
|
|
// }
|
2023-03-01 23:49:38 -08:00
|
|
|
//
|
2023-03-06 10:33:18 -08:00
|
|
|
// struct SimpleEntry: TimelineEntry {
|
2023-03-01 23:49:38 -08:00
|
|
|
// let date: Date
|
2023-03-06 10:33:18 -08:00
|
|
|
// }
|
2023-03-01 23:49:38 -08:00
|
|
|
//
|
2023-03-06 10:33:18 -08:00
|
|
|
// struct WidgetsEntryView : View {
|
2023-03-01 23:49:38 -08:00
|
|
|
// var entry: Provider.Entry
|
|
|
|
|
//
|
|
|
|
|
// var body: some View {
|
|
|
|
|
// Text(entry.date, style: .time)
|
|
|
|
|
// }
|
2023-03-06 10:33:18 -08:00
|
|
|
// }
|
2023-03-01 23:49:38 -08:00
|
|
|
//
|
2023-03-06 10:33:18 -08:00
|
|
|
// struct Widgets: Widget {
|
2023-03-01 23:49:38 -08:00
|
|
|
// let kind: String = "Widgets"
|
|
|
|
|
//
|
|
|
|
|
// var body: some WidgetConfiguration {
|
|
|
|
|
// StaticConfiguration(kind: kind, provider: Provider()) { entry in
|
|
|
|
|
// WidgetsEntryView(entry: entry)
|
|
|
|
|
// }
|
|
|
|
|
// .configurationDisplayName("My Widget")
|
|
|
|
|
// .description("This is an example widget.")
|
|
|
|
|
// }
|
2023-03-06 10:33:18 -08:00
|
|
|
// }
|
2023-03-01 23:49:38 -08:00
|
|
|
//
|
2023-03-06 10:33:18 -08:00
|
|
|
// struct Widgets_Previews: PreviewProvider {
|
2023-03-01 23:49:38 -08:00
|
|
|
// static var previews: some View {
|
|
|
|
|
// WidgetsEntryView(entry: SimpleEntry(date: Date()))
|
|
|
|
|
// .previewContext(WidgetPreviewContext(family: .systemSmall))
|
|
|
|
|
// }
|
2023-03-06 10:33:18 -08:00
|
|
|
// }
|