This commit is contained in:
Trey t
2022-01-19 09:54:52 -06:00
parent 031de0c933
commit d68db75f87
53 changed files with 567 additions and 13 deletions

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90AF4278C7DE0001C4FEA"
BuildableName = "iFeel.app"
BlueprintName = "Feels (iOS)"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90B01278C7DE0001C4FEA"
BuildableName = "Tests iOS.xctest"
BlueprintName = "Tests iOS"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90AF4278C7DE0001C4FEA"
BuildableName = "iFeel.app"
BlueprintName = "Feels (iOS)"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90AF4278C7DE0001C4FEA"
BuildableName = "iFeel.app"
BlueprintName = "Feels (iOS)"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90B44278C7E7A001C4FEA"
BuildableName = "FeelsWidgetExtension.appex"
BlueprintName = "FeelsWidgetExtension"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90AF4278C7DE0001C4FEA"
BuildableName = "iFeel.app"
BlueprintName = "Feels (iOS)"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
askForAppToLaunch = "Yes"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
launchAutomaticallySubstyle = "2">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.springboard">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90B44278C7E7A001C4FEA"
BuildableName = "FeelsWidgetExtension.appex"
BlueprintName = "FeelsWidgetExtension"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90AF4278C7DE0001C4FEA"
BuildableName = "iFeel.app"
BlueprintName = "Feels (iOS)"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "_XCWidgetKind"
value = "FeelsGraphicWidget"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "_XCWidgetDefaultView"
value = "timeline"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "_XCWidgetFamily"
value = "small"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1CD90AF4278C7DE0001C4FEA"
BuildableName = "iFeel.app"
BlueprintName = "Feels (iOS)"
ReferencedContainer = "container:Feels.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -24,7 +24,7 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>5</integer>
<integer>4</integer>
</dict>
<key>PlaygroundChart (Playground) 10.xcscheme</key>
<dict>
@@ -66,7 +66,7 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>6</integer>
<integer>5</integer>
</dict>
<key>PlaygroundChart (Playground) 3.xcscheme</key>
<dict>
@@ -122,7 +122,25 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>4</integer>
<integer>3</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>1CD90AF4278C7DE0001C4FEA</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>1CD90B01278C7DE0001C4FEA</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>1CD90B44278C7E7A001C4FEA</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "AverageGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "BadGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "GoodGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "GreatGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "HorribleGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "MissingGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

View File

@@ -13,13 +13,15 @@ import CoreData
class WatchTimelineView: Identifiable {
let id = UUID()
let image: Image
let graphic: Image
let date: Date
let color: Color
init(image: Image, date: Date, color: Color) {
init(image: Image, date: Date, color: Color, graphic: Image) {
self.image = image
self.date = date
self.color = color
self.graphic = graphic
}
}
@@ -51,13 +53,20 @@ struct TimeLineCreator {
return day == entryDay && month == entryMonth && year == entryYear
}).first {
let timeLineView = WatchTimelineView(image: item.mood.icon, date: pastDate, color: item.mood.color)
let timeLineView = WatchTimelineView(image: item.mood.icon,
date: pastDate,
color: item.mood.color,
graphic: item.mood.graphic)
returnViews.append(timeLineView)
} else {
let timeLineView = WatchTimelineView(image: Mood.missing.icon, date: pastDate, color: Mood.missing.color)
let timeLineView = WatchTimelineView(image: Mood.missing.icon,
date: pastDate,
color: Mood.missing.color,
graphic: Mood.missing.graphic)
returnViews.append(timeLineView)
}
}
returnViews = returnViews.sorted(by: { $0.date > $1.date })
return returnViews
}
}
@@ -72,7 +81,7 @@ struct Provider: IntentTimelineProvider {
for pastDay in 0...10 {
let pastDate = Calendar.current.date(byAdding: .day, value: -pastDay, to: Date())!
let mood = Mood.allValues.randomElement()!
sampleViews.append( WatchTimelineView(image: mood.icon, date: pastDate, color: mood.color) )
sampleViews.append(WatchTimelineView(image: mood.icon, date: pastDate, color: mood.color, graphic: mood.graphic))
}
return SimpleEntry(date: Date(), configuration: ConfigurationIntent(), timeLineViews: sampleViews)
}
@@ -84,7 +93,7 @@ struct Provider: IntentTimelineProvider {
for pastDay in 0...10 {
let pastDate = Calendar.current.date(byAdding: .day, value: -pastDay, to: Date())!
let mood = Mood.allValues.randomElement()!
timeLineViews.append( WatchTimelineView(image: mood.icon, date: pastDate, color: mood.color) )
timeLineViews.append( WatchTimelineView(image: mood.icon, date: pastDate, color: mood.color, graphic: mood.graphic))
}
} else {
let data = TimeLineCreator.getData()
@@ -148,6 +157,22 @@ 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 {
var entry: Provider.Entry
@@ -167,6 +192,18 @@ struct SmallWidgetView: View {
}
}
struct SmallGraphicWidgetView: View {
var entry: Provider.Entry
var body: some View {
GeometryReader { geo in
entry.timeLineViews.first!.graphic
.resizable()
.scaledToFit()
}
}
}
struct TimeHeaderView: View {
let startDate: Date
let endDate: Date
@@ -275,6 +312,13 @@ struct EntryCard: View {
}
@main
struct FeelsBundle: WidgetBundle {
var body: some Widget {
FeelsWidget()
FeelsGraphicWidget()
}
}
struct FeelsWidget: Widget {
let kind: String = "FeelsWidget"
@@ -290,6 +334,21 @@ struct FeelsWidget: Widget {
}
}
struct FeelsGraphicWidget: Widget {
let kind: String = "FeelsGraphicWidget"
var body: some WidgetConfiguration {
IntentConfiguration(kind: kind,
intent: ConfigurationIntent.self,
provider: Provider()) { entry in
FeelsGraphicWidgetEntryView(entry: entry)
}
.configurationDisplayName("Feels")
.description("")
.supportedFamilies([.systemSmall])
}
}
struct FeelsWidget_Previews: PreviewProvider {
static var data: [WatchTimelineView] {
var data = PersistenceController.shared.randomEntries(count: 10)

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "AverageGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "BadGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "GoodGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "GreatGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "HorribleGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

View File

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "MissingGraphic.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

View File

@@ -71,6 +71,24 @@ enum Mood: Int {
return Image("missing", bundle: .main)
}
}
var graphic: Image {
switch self {
case .horrible:
return Image("HorribleGraphic", bundle: .main)
case .bad:
return Image("BadGraphic", bundle: .main)
case .average:
return Image("AverageGraphic", bundle: .main)
case .good:
return Image("GoodGraphic", bundle: .main)
case .great:
return Image("GreatGraphic", bundle: .main)
case .missing:
return Image("MissingGraphic", bundle: .main)
}
}
}
extension Mood: Identifiable {

View File

@@ -62,11 +62,6 @@ class PersistenceController {
try! viewContext.setQueryGenerationFrom(.current)
viewContext.refreshAllObjects()
let fakeRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
let fakeData = try! viewContext.fetch(fakeRequest)
for item in fakeData {
print(item.forDate!)
}
var includedDays16 = [Int16]()
if includedDays.isEmpty {