play with widgets
add different widgets for large icon and last day made images smaller to avoid memory issues
@@ -80,7 +80,7 @@
|
|||||||
<EnvironmentVariables>
|
<EnvironmentVariables>
|
||||||
<EnvironmentVariable
|
<EnvironmentVariable
|
||||||
key = "_XCWidgetKind"
|
key = "_XCWidgetKind"
|
||||||
value = "FeelsGraphicWidget"
|
value = "FeelsWidget"
|
||||||
isEnabled = "YES">
|
isEnabled = "YES">
|
||||||
</EnvironmentVariable>
|
</EnvironmentVariable>
|
||||||
<EnvironmentVariable
|
<EnvironmentVariable
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 155 KiB |
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 187 KiB |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "meh-regular.svg",
|
"filename" : "meh-regular.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
FeelsWidget/Assets.xcassets/average.imageset/meh-regular.png
vendored
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="meh" class="svg-inline--fa fa-meh fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 610 B |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "frown-regular.svg",
|
"filename" : "frown-regular.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
FeelsWidget/Assets.xcassets/bad.imageset/frown-regular.png
vendored
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="frown" class="svg-inline--fa fa-frown fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 748 B |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "grin-regular.svg",
|
"filename" : "grin-regular.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
FeelsWidget/Assets.xcassets/good.imageset/grin-regular.png
vendored
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="grin" class="svg-inline--fa fa-grin fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm105.6-151.4c-25.9 8.3-64.4 13.1-105.6 13.1s-79.6-4.8-105.6-13.1c-9.9-3.1-19.4 5.4-17.7 15.3 7.9 47.1 71.3 80 123.3 80s115.3-32.9 123.3-80c1.6-9.8-7.7-18.4-17.7-15.3zM168 240c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 690 B |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "smile-beam-regular.svg",
|
"filename" : "smile-beam-regular.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
FeelsWidget/Assets.xcassets/great.imageset/smile-beam-regular.png
vendored
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="smile-beam" class="svg-inline--fa fa-smile-beam fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm84-143.4c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.6-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.2-8.4-25.3-7.1-33.8 3.1zM136.5 211c7.7-13.7 19.2-21.6 31.5-21.6s23.8 7.9 31.5 21.6l9.5 17c2.1 3.7 6.2 4.7 9.3 3.7 3.6-1.1 6-4.5 5.7-8.3-3.3-42.1-32.2-71.4-56-71.4s-52.7 29.3-56 71.4c-.3 3.7 2.1 7.2 5.7 8.3 3.4 1.1 7.4-.5 9.3-3.7l9.5-17zM328 152c-23.8 0-52.7 29.3-56 71.4-.3 3.7 2.1 7.2 5.7 8.3 3.5 1.1 7.4-.5 9.3-3.7l9.5-17c7.7-13.7 19.2-21.6 31.5-21.6s23.8 7.9 31.5 21.6l9.5 17c2.1 3.7 6.2 4.7 9.3 3.7 3.6-1.1 6-4.5 5.7-8.3-3.3-42.1-32.2-71.4-56-71.4z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.0 KiB |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "sad-tear-regular.svg",
|
"filename" : "sad-tear-regular.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
FeelsWidget/Assets.xcassets/horrible.imageset/sad-tear-regular.png
vendored
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="sad-tear" class="svg-inline--fa fa-sad-tear fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm8-152c-13.2 0-24 10.8-24 24s10.8 24 24 24c23.8 0 46.3 10.5 61.6 28.8 8.1 9.8 23.2 11.9 33.8 3.1 10.2-8.5 11.6-23.6 3.1-33.8C330 320.8 294.1 304 256 304zm-88-64c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-165.6 98.8C151 290.1 126 325.4 126 342.9c0 22.7 18.8 41.1 42 41.1s42-18.4 42-41.1c0-17.5-25-52.8-36.4-68.1-2.8-3.7-8.4-3.7-11.2 0z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 817 B |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "times-solid.svg",
|
"filename" : "times-solid.png",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
@@ -17,5 +17,8 @@
|
|||||||
"info" : {
|
"info" : {
|
||||||
"author" : "xcode",
|
"author" : "xcode",
|
||||||
"version" : 1
|
"version" : 1
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
FeelsWidget/Assets.xcassets/missing.imageset/times-solid.png
vendored
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="times" class="svg-inline--fa fa-times fa-w-11" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512"><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 645 B |
@@ -26,21 +26,22 @@ class WatchTimelineView: Identifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct TimeLineCreator {
|
struct TimeLineCreator {
|
||||||
static func getData() -> [MoodEntry] {
|
public func getLastTen() -> [MoodEntry] {
|
||||||
let dateAtEnd = Calendar.current.date(bySettingHour: 23, minute: 59, second: 59, of: Date())!
|
let dateAtEnd = Calendar.current.date(bySettingHour: 23, minute: 59, second: 59, of: Date())!
|
||||||
var tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: dateAtEnd)!
|
var tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: dateAtEnd)!
|
||||||
tenDaysAgo = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: tenDaysAgo)!
|
tenDaysAgo = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: tenDaysAgo)!
|
||||||
let moodEntry = PersistenceController.shared.getData(startDate: tenDaysAgo, endDate: dateAtEnd, includedDays: [1,2,3,4,5,6,7])
|
let moodEntry = PersistenceController.shared.getData(startDate: tenDaysAgo, endDate: dateAtEnd, includedDays: [1,2,3,4,5,6,7])
|
||||||
|
|
||||||
return moodEntry
|
return moodEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
static func createTimeLineViews(fromEntries: [MoodEntry]) -> [WatchTimelineView] {
|
func createTimeLineViewsfrom(entries: [MoodEntry]) -> [WatchTimelineView] {
|
||||||
var returnViews = [WatchTimelineView]()
|
var returnViews = [WatchTimelineView]()
|
||||||
|
|
||||||
for pastDays in 0...10 {
|
for pastDays in 0...10 {
|
||||||
let pastDate = Calendar.current.date(byAdding: .day, value: -pastDays, to: Date())!
|
let pastDate = Calendar.current.date(byAdding: .day, value: -pastDays, to: Date())!
|
||||||
|
|
||||||
if let item = fromEntries.filter({ entry in
|
if let item = entries.filter({ entry in
|
||||||
let components = Calendar.current.dateComponents([.day, .month, .year], from: pastDate)
|
let components = Calendar.current.dateComponents([.day, .month, .year], from: pastDate)
|
||||||
let day = components.day
|
let day = components.day
|
||||||
let month = components.month
|
let month = components.month
|
||||||
@@ -55,13 +56,13 @@ struct TimeLineCreator {
|
|||||||
}).first {
|
}).first {
|
||||||
let timeLineView = WatchTimelineView(image: item.mood.icon,
|
let timeLineView = WatchTimelineView(image: item.mood.icon,
|
||||||
date: pastDate,
|
date: pastDate,
|
||||||
color: item.mood.color,
|
color: item.mood == Mood.missing ? Color(UIColor.label) : item.mood.color,
|
||||||
graphic: item.mood.graphic)
|
graphic: item.mood.graphic)
|
||||||
returnViews.append(timeLineView)
|
returnViews.append(timeLineView)
|
||||||
} else {
|
} else {
|
||||||
let timeLineView = WatchTimelineView(image: Mood.missing.icon,
|
let timeLineView = WatchTimelineView(image: Mood.missing.icon,
|
||||||
date: pastDate,
|
date: pastDate,
|
||||||
color: Mood.missing.color,
|
color: Color(UIColor.label),
|
||||||
graphic: Mood.missing.graphic)
|
graphic: Mood.missing.graphic)
|
||||||
returnViews.append(timeLineView)
|
returnViews.append(timeLineView)
|
||||||
}
|
}
|
||||||
@@ -72,6 +73,8 @@ struct TimeLineCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Provider: IntentTimelineProvider {
|
struct Provider: IntentTimelineProvider {
|
||||||
|
let timeLineCreator = TimeLineCreator()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
placeholder for widget, no data
|
placeholder for widget, no data
|
||||||
gets redacted auto
|
gets redacted auto
|
||||||
@@ -88,6 +91,7 @@ struct Provider: IntentTimelineProvider {
|
|||||||
|
|
||||||
func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
|
func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
|
||||||
var timeLineViews = [WatchTimelineView]()
|
var timeLineViews = [WatchTimelineView]()
|
||||||
|
let lastTenEntries = timeLineCreator.getLastTen()
|
||||||
|
|
||||||
if context.isPreview {
|
if context.isPreview {
|
||||||
for pastDay in 0...10 {
|
for pastDay in 0...10 {
|
||||||
@@ -96,8 +100,7 @@ struct Provider: IntentTimelineProvider {
|
|||||||
timeLineViews.append( WatchTimelineView(image: mood.icon, date: pastDate, color: mood.color, graphic: mood.graphic))
|
timeLineViews.append( WatchTimelineView(image: mood.icon, date: pastDate, color: mood.color, graphic: mood.graphic))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let data = TimeLineCreator.getData()
|
timeLineViews = timeLineCreator.createTimeLineViewsfrom(entries: lastTenEntries)
|
||||||
timeLineViews = TimeLineCreator.createTimeLineViews(fromEntries: data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let entry = SimpleEntry(date: Date(), configuration: configuration, timeLineViews: timeLineViews)
|
let entry = SimpleEntry(date: Date(), configuration: configuration, timeLineViews: timeLineViews)
|
||||||
@@ -105,10 +108,12 @@ struct Provider: IntentTimelineProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
||||||
let data = TimeLineCreator.getData()
|
let lastTenEntries = timeLineCreator.getLastTen()
|
||||||
let views = TimeLineCreator.createTimeLineViews(fromEntries: data)
|
let views = timeLineCreator.createTimeLineViewsfrom(entries: lastTenEntries)
|
||||||
|
|
||||||
let entry = SimpleEntry(date: Date(), configuration: configuration, timeLineViews: views)
|
let entry = SimpleEntry(date: Date(), configuration: configuration, timeLineViews: views)
|
||||||
|
|
||||||
|
// TODO: make this update time make more sense
|
||||||
let timeline = Timeline(entries: [entry], policy: .after(Random.tomorrowMidnightThirty))
|
let timeline = Timeline(entries: [entry], policy: .after(Random.tomorrowMidnightThirty))
|
||||||
completion(timeline)
|
completion(timeline)
|
||||||
}
|
}
|
||||||
@@ -127,7 +132,7 @@ struct SimpleEntry: TimelineEntry {
|
|||||||
self.showStats = showStats
|
self.showStats = showStats
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**********************************************************/
|
||||||
struct FeelsWidgetEntryView : View {
|
struct FeelsWidgetEntryView : View {
|
||||||
@Environment(\.sizeCategory) var sizeCategory
|
@Environment(\.sizeCategory) var sizeCategory
|
||||||
@Environment(\.widgetFamily) var family
|
@Environment(\.widgetFamily) var family
|
||||||
@@ -157,22 +162,6 @@ struct FeelsWidgetEntryView : View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FeelsGraphicWidgetEntryView : View {
|
|
||||||
@Environment(\.sizeCategory) var sizeCategory
|
|
||||||
@Environment(\.widgetFamily) var family
|
|
||||||
|
|
||||||
var entry: Provider.Entry
|
|
||||||
|
|
||||||
@ViewBuilder
|
|
||||||
var body: some View {
|
|
||||||
SmallGraphicWidgetView(entry: entry)
|
|
||||||
.onReceive(NotificationCenter.default.publisher(for: .NSPersistentStoreRemoteChange)) { _ in
|
|
||||||
// make sure you don't call this too often
|
|
||||||
WidgetCenter.shared.reloadAllTimelines()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SmallWidgetView: View {
|
struct SmallWidgetView: View {
|
||||||
var entry: Provider.Entry
|
var entry: Provider.Entry
|
||||||
|
|
||||||
@@ -192,6 +181,47 @@ struct SmallWidgetView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct MediumWidgetView: View {
|
||||||
|
var entry: Provider.Entry
|
||||||
|
|
||||||
|
var firstGroup: [WatchTimelineView] {
|
||||||
|
Array(self.entry.timeLineViews.prefix(5))
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
TimeHeaderView(startDate: firstGroup.first!.date, endDate: firstGroup.last!.date)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
.multilineTextAlignment(.leading)
|
||||||
|
|
||||||
|
TimeBodyView(group: firstGroup)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||||
|
.frame(minHeight: 0, maxHeight: 55)
|
||||||
|
.padding()
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**********************************************************/
|
||||||
|
struct FeelsGraphicWidgetEntryView : View {
|
||||||
|
@Environment(\.sizeCategory) var sizeCategory
|
||||||
|
@Environment(\.widgetFamily) var family
|
||||||
|
|
||||||
|
var entry: Provider.Entry
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
var body: some View {
|
||||||
|
SmallGraphicWidgetView(entry: entry)
|
||||||
|
.onReceive(NotificationCenter.default.publisher(for: .NSPersistentStoreRemoteChange)) { _ in
|
||||||
|
// make sure you don't call this too often
|
||||||
|
WidgetCenter.shared.reloadAllTimelines()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct SmallGraphicWidgetView: View {
|
struct SmallGraphicWidgetView: View {
|
||||||
var entry: Provider.Entry
|
var entry: Provider.Entry
|
||||||
|
|
||||||
@@ -203,7 +233,31 @@ struct SmallGraphicWidgetView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**********************************************************/
|
||||||
|
struct FeelsIconWidgetEntryView : View {
|
||||||
|
@Environment(\.sizeCategory) var sizeCategory
|
||||||
|
@Environment(\.widgetFamily) var family
|
||||||
|
|
||||||
|
var entry: Provider.Entry
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
var body: some View {
|
||||||
|
SmallIconView(entry: entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SmallIconView: View {
|
||||||
|
var entry: Provider.Entry
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
GeometryReader { geo in
|
||||||
|
Mood.missing.graphic
|
||||||
|
.resizable()
|
||||||
|
.scaledToFit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**********************************************************/
|
||||||
struct TimeHeaderView: View {
|
struct TimeHeaderView: View {
|
||||||
let startDate: Date
|
let startDate: Date
|
||||||
let endDate: Date
|
let endDate: Date
|
||||||
@@ -242,30 +296,7 @@ struct TimeBodyView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MediumWidgetView: View {
|
|
||||||
var entry: Provider.Entry
|
|
||||||
|
|
||||||
var firstGroup: [WatchTimelineView] {
|
|
||||||
Array(self.entry.timeLineViews.prefix(5))
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
VStack {
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
TimeHeaderView(startDate: firstGroup.first!.date, endDate: firstGroup.last!.date)
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity)
|
|
||||||
.multilineTextAlignment(.leading)
|
|
||||||
|
|
||||||
TimeBodyView(group: firstGroup)
|
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
|
||||||
.frame(minHeight: 0, maxHeight: 55)
|
|
||||||
.padding()
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//struct LargeWidgetView: View {
|
//struct LargeWidgetView: View {
|
||||||
// var entry: Provider.Entry
|
// var entry: Provider.Entry
|
||||||
@@ -316,6 +347,7 @@ struct FeelsBundle: WidgetBundle {
|
|||||||
var body: some Widget {
|
var body: some Widget {
|
||||||
FeelsWidget()
|
FeelsWidget()
|
||||||
FeelsGraphicWidget()
|
FeelsGraphicWidget()
|
||||||
|
FeelsIconWidget()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,6 +366,21 @@ struct FeelsWidget: Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FeelsIconWidget: Widget {
|
||||||
|
let kind: String = "FeelsIconWidget"
|
||||||
|
|
||||||
|
var body: some WidgetConfiguration {
|
||||||
|
IntentConfiguration(kind: kind,
|
||||||
|
intent: ConfigurationIntent.self,
|
||||||
|
provider: Provider()) { entry in
|
||||||
|
FeelsIconWidgetEntryView(entry: entry)
|
||||||
|
}
|
||||||
|
.configurationDisplayName("Feels Icon")
|
||||||
|
.description("")
|
||||||
|
.supportedFamilies([.systemSmall])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct FeelsGraphicWidget: Widget {
|
struct FeelsGraphicWidget: Widget {
|
||||||
let kind: String = "FeelsGraphicWidget"
|
let kind: String = "FeelsGraphicWidget"
|
||||||
|
|
||||||
@@ -343,7 +390,7 @@ struct FeelsGraphicWidget: Widget {
|
|||||||
provider: Provider()) { entry in
|
provider: Provider()) { entry in
|
||||||
FeelsGraphicWidgetEntryView(entry: entry)
|
FeelsGraphicWidgetEntryView(entry: entry)
|
||||||
}
|
}
|
||||||
.configurationDisplayName("Feels")
|
.configurationDisplayName("Mood Graphic")
|
||||||
.description("")
|
.description("")
|
||||||
.supportedFamilies([.systemSmall])
|
.supportedFamilies([.systemSmall])
|
||||||
}
|
}
|
||||||
@@ -353,7 +400,7 @@ struct FeelsWidget_Previews: PreviewProvider {
|
|||||||
static var data: [WatchTimelineView] {
|
static var data: [WatchTimelineView] {
|
||||||
var data = PersistenceController.shared.randomEntries(count: 10)
|
var data = PersistenceController.shared.randomEntries(count: 10)
|
||||||
data.remove(at: 2)
|
data.remove(at: 2)
|
||||||
let views = TimeLineCreator.createTimeLineViews(fromEntries: data)
|
let views = TimeLineCreator().createTimeLineViewsfrom(entries: data)
|
||||||
return views
|
return views
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||