WIP - Sharing
This commit is contained in:
@@ -17,12 +17,11 @@
|
|||||||
1C26190327960CE500FDC148 /* ChartDataBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190227960CE500FDC148 /* ChartDataBuildable.swift */; };
|
1C26190327960CE500FDC148 /* ChartDataBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190227960CE500FDC148 /* ChartDataBuildable.swift */; };
|
||||||
1C26190727960DC900FDC148 /* ChartViewItemBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */; };
|
1C26190727960DC900FDC148 /* ChartViewItemBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */; };
|
||||||
1C358FAD27ADD0C3002C83A6 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FAC27ADD0C3002C83A6 /* Theme.swift */; };
|
1C358FAD27ADD0C3002C83A6 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FAC27ADD0C3002C83A6 /* Theme.swift */; };
|
||||||
1C358FB127B0AD87002C83A6 /* SharingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB027B0AD87002C83A6 /* SharingView.swift */; };
|
1C358FB127B0AD87002C83A6 /* SharingListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB027B0AD87002C83A6 /* SharingListView.swift */; };
|
||||||
1C358FB327B0ADA4002C83A6 /* SharingTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB227B0ADA4002C83A6 /* SharingTemplate.swift */; };
|
1C358FB327B0ADA4002C83A6 /* SharingTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB227B0ADA4002C83A6 /* SharingTemplate.swift */; };
|
||||||
1C358FB627B0AE15002C83A6 /* AllMoodsTotalTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB527B0AE15002C83A6 /* AllMoodsTotalTemplate.swift */; };
|
1C358FB627B0AE15002C83A6 /* AllMoodsTotalTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB527B0AE15002C83A6 /* AllMoodsTotalTemplate.swift */; };
|
||||||
1C358FB827B0AEE3002C83A6 /* LongestStreakTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB727B0AEE3002C83A6 /* LongestStreakTemplate.swift */; };
|
1C358FB827B0AEE3002C83A6 /* LongestStreakTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB727B0AEE3002C83A6 /* LongestStreakTemplate.swift */; };
|
||||||
1C358FBA27B35252002C83A6 /* ActivityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB927B35252002C83A6 /* ActivityViewController.swift */; };
|
1C358FBA27B35252002C83A6 /* ActivityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FB927B35252002C83A6 /* ActivityViewController.swift */; };
|
||||||
1C358FBC27B352B1002C83A6 /* ShareButtonview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FBB27B352B1002C83A6 /* ShareButtonview.swift */; };
|
|
||||||
1C358FBE27B4D1F2002C83A6 /* CurrentStreakTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FBD27B4D1F2002C83A6 /* CurrentStreakTemplate.swift */; };
|
1C358FBE27B4D1F2002C83A6 /* CurrentStreakTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FBD27B4D1F2002C83A6 /* CurrentStreakTemplate.swift */; };
|
||||||
1C358FC027B4D20C002C83A6 /* MonthTotalTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FBF27B4D20C002C83A6 /* MonthTotalTemplate.swift */; };
|
1C358FC027B4D20C002C83A6 /* MonthTotalTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FBF27B4D20C002C83A6 /* MonthTotalTemplate.swift */; };
|
||||||
1C358FC227B4D227002C83A6 /* WeekTotalTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FC127B4D227002C83A6 /* WeekTotalTemplate.swift */; };
|
1C358FC227B4D227002C83A6 /* WeekTotalTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C358FC127B4D227002C83A6 /* WeekTotalTemplate.swift */; };
|
||||||
@@ -51,6 +50,8 @@
|
|||||||
1CAD603C27A5C1C800C520BD /* HeaderStatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603327A5C1C800C520BD /* HeaderStatsView.swift */; };
|
1CAD603C27A5C1C800C520BD /* HeaderStatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603327A5C1C800C520BD /* HeaderStatsView.swift */; };
|
||||||
1CAD603E27A6ECCD00C520BD /* SwitchableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */; };
|
1CAD603E27A6ECCD00C520BD /* SwitchableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */; };
|
||||||
1CB101C527B62A2D00D1C033 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB101C427B62A2D00D1C033 /* EmptyView.swift */; };
|
1CB101C527B62A2D00D1C033 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB101C427B62A2D00D1C033 /* EmptyView.swift */; };
|
||||||
|
1CB101C727B81CAC00D1C033 /* MoodMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB101C627B81CAC00D1C033 /* MoodMetrics.swift */; };
|
||||||
|
1CB101C827B81CAC00D1C033 /* MoodMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB101C627B81CAC00D1C033 /* MoodMetrics.swift */; };
|
||||||
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469A9278F30A0003E0C6E /* BGTask.swift */; };
|
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469A9278F30A0003E0C6E /* BGTask.swift */; };
|
||||||
1CC469AC27907D48003E0C6E /* DayChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469AB27907D48003E0C6E /* DayChartView.swift */; };
|
1CC469AC27907D48003E0C6E /* DayChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC469AB27907D48003E0C6E /* DayChartView.swift */; };
|
||||||
1CD90B07278C7DE0001C4FEA /* Tests_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD90B06278C7DE0001C4FEA /* Tests_iOS.swift */; };
|
1CD90B07278C7DE0001C4FEA /* Tests_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD90B06278C7DE0001C4FEA /* Tests_iOS.swift */; };
|
||||||
@@ -132,12 +133,11 @@
|
|||||||
1C26190227960CE500FDC148 /* ChartDataBuildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartDataBuildable.swift; sourceTree = "<group>"; };
|
1C26190227960CE500FDC148 /* ChartDataBuildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartDataBuildable.swift; sourceTree = "<group>"; };
|
||||||
1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartViewItemBuildable.swift; sourceTree = "<group>"; };
|
1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartViewItemBuildable.swift; sourceTree = "<group>"; };
|
||||||
1C358FAC27ADD0C3002C83A6 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
|
1C358FAC27ADD0C3002C83A6 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
|
||||||
1C358FB027B0AD87002C83A6 /* SharingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingView.swift; sourceTree = "<group>"; };
|
1C358FB027B0AD87002C83A6 /* SharingListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingListView.swift; sourceTree = "<group>"; };
|
||||||
1C358FB227B0ADA4002C83A6 /* SharingTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingTemplate.swift; sourceTree = "<group>"; };
|
1C358FB227B0ADA4002C83A6 /* SharingTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingTemplate.swift; sourceTree = "<group>"; };
|
||||||
1C358FB527B0AE15002C83A6 /* AllMoodsTotalTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllMoodsTotalTemplate.swift; sourceTree = "<group>"; };
|
1C358FB527B0AE15002C83A6 /* AllMoodsTotalTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllMoodsTotalTemplate.swift; sourceTree = "<group>"; };
|
||||||
1C358FB727B0AEE3002C83A6 /* LongestStreakTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongestStreakTemplate.swift; sourceTree = "<group>"; };
|
1C358FB727B0AEE3002C83A6 /* LongestStreakTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongestStreakTemplate.swift; sourceTree = "<group>"; };
|
||||||
1C358FB927B35252002C83A6 /* ActivityViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityViewController.swift; sourceTree = "<group>"; };
|
1C358FB927B35252002C83A6 /* ActivityViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityViewController.swift; sourceTree = "<group>"; };
|
||||||
1C358FBB27B352B1002C83A6 /* ShareButtonview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareButtonview.swift; sourceTree = "<group>"; };
|
|
||||||
1C358FBD27B4D1F2002C83A6 /* CurrentStreakTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentStreakTemplate.swift; sourceTree = "<group>"; };
|
1C358FBD27B4D1F2002C83A6 /* CurrentStreakTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentStreakTemplate.swift; sourceTree = "<group>"; };
|
||||||
1C358FBF27B4D20C002C83A6 /* MonthTotalTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonthTotalTemplate.swift; sourceTree = "<group>"; };
|
1C358FBF27B4D20C002C83A6 /* MonthTotalTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonthTotalTemplate.swift; sourceTree = "<group>"; };
|
||||||
1C358FC127B4D227002C83A6 /* WeekTotalTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekTotalTemplate.swift; sourceTree = "<group>"; };
|
1C358FC127B4D227002C83A6 /* WeekTotalTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekTotalTemplate.swift; sourceTree = "<group>"; };
|
||||||
@@ -162,6 +162,7 @@
|
|||||||
1CAD603327A5C1C800C520BD /* HeaderStatsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderStatsView.swift; sourceTree = "<group>"; };
|
1CAD603327A5C1C800C520BD /* HeaderStatsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderStatsView.swift; sourceTree = "<group>"; };
|
||||||
1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchableView.swift; sourceTree = "<group>"; };
|
1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchableView.swift; sourceTree = "<group>"; };
|
||||||
1CB101C427B62A2D00D1C033 /* EmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyView.swift; sourceTree = "<group>"; };
|
1CB101C427B62A2D00D1C033 /* EmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyView.swift; sourceTree = "<group>"; };
|
||||||
|
1CB101C627B81CAC00D1C033 /* MoodMetrics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoodMetrics.swift; sourceTree = "<group>"; };
|
||||||
1CC03FA627B5865600B530AF /* Shared 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Shared 2.xcdatamodel"; sourceTree = "<group>"; };
|
1CC03FA627B5865600B530AF /* Shared 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Shared 2.xcdatamodel"; sourceTree = "<group>"; };
|
||||||
1CC469A9278F30A0003E0C6E /* BGTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGTask.swift; sourceTree = "<group>"; };
|
1CC469A9278F30A0003E0C6E /* BGTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGTask.swift; sourceTree = "<group>"; };
|
||||||
1CC469AB27907D48003E0C6E /* DayChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayChartView.swift; sourceTree = "<group>"; };
|
1CC469AB27907D48003E0C6E /* DayChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayChartView.swift; sourceTree = "<group>"; };
|
||||||
@@ -299,9 +300,8 @@
|
|||||||
1CAD602C27A5C1C800C520BD /* SettingsView.swift */,
|
1CAD602C27A5C1C800C520BD /* SettingsView.swift */,
|
||||||
1CAD602B27A5C1C800C520BD /* SmallRollUpHeaderView.swift */,
|
1CAD602B27A5C1C800C520BD /* SmallRollUpHeaderView.swift */,
|
||||||
1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */,
|
1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */,
|
||||||
1C358FB027B0AD87002C83A6 /* SharingView.swift */,
|
1C358FB027B0AD87002C83A6 /* SharingListView.swift */,
|
||||||
1C358FB927B35252002C83A6 /* ActivityViewController.swift */,
|
1C358FB927B35252002C83A6 /* ActivityViewController.swift */,
|
||||||
1C358FBB27B352B1002C83A6 /* ShareButtonview.swift */,
|
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -415,6 +415,7 @@
|
|||||||
1CD90B62278C7EBA001C4FEA /* MoodEntryExtension.swift */,
|
1CD90B62278C7EBA001C4FEA /* MoodEntryExtension.swift */,
|
||||||
1C358FAC27ADD0C3002C83A6 /* Theme.swift */,
|
1C358FAC27ADD0C3002C83A6 /* Theme.swift */,
|
||||||
1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */,
|
1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */,
|
||||||
|
1CB101C627B81CAC00D1C033 /* MoodMetrics.swift */,
|
||||||
);
|
);
|
||||||
path = Models;
|
path = Models;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -628,7 +629,6 @@
|
|||||||
1CAD603727A5C1C800C520BD /* FilterView.swift in Sources */,
|
1CAD603727A5C1C800C520BD /* FilterView.swift in Sources */,
|
||||||
1C683FCA2792281400745862 /* Stats.swift in Sources */,
|
1C683FCA2792281400745862 /* Stats.swift in Sources */,
|
||||||
1CAD603E27A6ECCD00C520BD /* SwitchableView.swift in Sources */,
|
1CAD603E27A6ECCD00C520BD /* SwitchableView.swift in Sources */,
|
||||||
1C358FBC27B352B1002C83A6 /* ShareButtonview.swift in Sources */,
|
|
||||||
1CD90B76278C8119001C4FEA /* LocalNotification.swift in Sources */,
|
1CD90B76278C8119001C4FEA /* LocalNotification.swift in Sources */,
|
||||||
1C358FB627B0AE15002C83A6 /* AllMoodsTotalTemplate.swift in Sources */,
|
1C358FB627B0AE15002C83A6 /* AllMoodsTotalTemplate.swift in Sources */,
|
||||||
1CD90B16278C7DE0001C4FEA /* Feels.xcdatamodeld in Sources */,
|
1CD90B16278C7DE0001C4FEA /* Feels.xcdatamodeld in Sources */,
|
||||||
@@ -648,11 +648,12 @@
|
|||||||
1CC469AC27907D48003E0C6E /* DayChartView.swift in Sources */,
|
1CC469AC27907D48003E0C6E /* DayChartView.swift in Sources */,
|
||||||
1C26190327960CE500FDC148 /* ChartDataBuildable.swift in Sources */,
|
1C26190327960CE500FDC148 /* ChartDataBuildable.swift in Sources */,
|
||||||
1CB101C527B62A2D00D1C033 /* EmptyView.swift in Sources */,
|
1CB101C527B62A2D00D1C033 /* EmptyView.swift in Sources */,
|
||||||
|
1CB101C727B81CAC00D1C033 /* MoodMetrics.swift in Sources */,
|
||||||
1CAD603627A5C1C800C520BD /* GraphView.swift in Sources */,
|
1CAD603627A5C1C800C520BD /* GraphView.swift in Sources */,
|
||||||
1CD90B66278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
1CD90B66278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
||||||
1C358FB327B0ADA4002C83A6 /* SharingTemplate.swift in Sources */,
|
1C358FB327B0ADA4002C83A6 /* SharingTemplate.swift in Sources */,
|
||||||
1C358FB827B0AEE3002C83A6 /* LongestStreakTemplate.swift in Sources */,
|
1C358FB827B0AEE3002C83A6 /* LongestStreakTemplate.swift in Sources */,
|
||||||
1C358FB127B0AD87002C83A6 /* SharingView.swift in Sources */,
|
1C358FB127B0AD87002C83A6 /* SharingListView.swift in Sources */,
|
||||||
1CD90B1C278C7DE0001C4FEA /* Persistence.swift in Sources */,
|
1CD90B1C278C7DE0001C4FEA /* Persistence.swift in Sources */,
|
||||||
1CA0377A279A296E00D26164 /* OnboardingMain.swift in Sources */,
|
1CA0377A279A296E00D26164 /* OnboardingMain.swift in Sources */,
|
||||||
1C358FBA27B35252002C83A6 /* ActivityViewController.swift in Sources */,
|
1C358FBA27B35252002C83A6 /* ActivityViewController.swift in Sources */,
|
||||||
@@ -707,6 +708,7 @@
|
|||||||
1CD90B68278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
1CD90B68278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
||||||
1CD90B71278C80CA001C4FEA /* Feels.xcdatamodeld in Sources */,
|
1CD90B71278C80CA001C4FEA /* Feels.xcdatamodeld in Sources */,
|
||||||
1C10E25127A1AB320047948B /* OnboardingTitle.swift in Sources */,
|
1C10E25127A1AB320047948B /* OnboardingTitle.swift in Sources */,
|
||||||
|
1CB101C827B81CAC00D1C033 /* MoodMetrics.swift in Sources */,
|
||||||
1C683FCB2792281400745862 /* Stats.swift in Sources */,
|
1C683FCB2792281400745862 /* Stats.swift in Sources */,
|
||||||
1C10E25027A1AB220047948B /* OnboardingDay.swift in Sources */,
|
1C10E25027A1AB220047948B /* OnboardingDay.swift in Sources */,
|
||||||
1C10E24F27A1AB1D0047948B /* OnboardingData.swift in Sources */,
|
1C10E24F27A1AB1D0047948B /* OnboardingData.swift in Sources */,
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?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>PreviewsEnabled</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
15
Shared/Models/MoodMetrics.swift
Normal file
15
Shared/Models/MoodMetrics.swift
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// MoodMetrics.swift
|
||||||
|
// Feels
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 2/12/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct MoodMetrics: Identifiable {
|
||||||
|
let id = UUID()
|
||||||
|
let mood: Mood
|
||||||
|
let total: Int
|
||||||
|
let percent: Float
|
||||||
|
}
|
||||||
@@ -9,36 +9,192 @@ import SwiftUI
|
|||||||
|
|
||||||
struct AllMoodsTotalTemplate: View, SharingTemplate {
|
struct AllMoodsTotalTemplate: View, SharingTemplate {
|
||||||
static var description: String {
|
static var description: String {
|
||||||
"AllMoodsSharingTemplate"
|
"All Time Count"
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPreview: Bool
|
var isPreview: Bool
|
||||||
|
|
||||||
var startDate: Date
|
var startDate: Date
|
||||||
var endDate: Date
|
var endDate: Date
|
||||||
|
var totalEntryCount: Int = 0
|
||||||
|
|
||||||
|
@State var showSharingTemplate = false
|
||||||
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
|
private var entries = [MoodMetrics]()
|
||||||
|
|
||||||
|
init(isPreview: Bool, startDate: Date, endDate: Date, fakeData: Bool) {
|
||||||
|
self.isPreview = isPreview
|
||||||
|
self.startDate = startDate
|
||||||
|
self.endDate = endDate
|
||||||
|
|
||||||
|
var moodEntries: [MoodEntry]?
|
||||||
|
|
||||||
|
if fakeData {
|
||||||
|
moodEntries = PersistenceController.shared.randomEntries(count: 10)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
moodEntries = PersistenceController.shared.getData(startDate:startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
includedDays: [1,2,3,4,5,6,7])
|
||||||
|
}
|
||||||
|
|
||||||
|
totalEntryCount = moodEntries?.count ?? 0
|
||||||
|
|
||||||
|
if let moodEntries = moodEntries {
|
||||||
|
for (_, mood) in Mood.allValues.enumerated() {
|
||||||
|
|
||||||
|
let moodEntries = moodEntries.filter({
|
||||||
|
Int($0.moodValue) == mood.rawValue
|
||||||
|
})
|
||||||
|
let total = moodEntries.count
|
||||||
|
let perc = (Float(total) / Float(totalEntryCount)) * 100
|
||||||
|
entries.append(MoodMetrics(mood: mood, total: total, percent: perc))
|
||||||
|
}
|
||||||
|
|
||||||
|
entries = entries.sorted(by: {
|
||||||
|
$0.mood.rawValue > $1.mood.rawValue
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fatalError("no data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var image: UIImage {
|
||||||
|
let image = shareView.snapshot()
|
||||||
|
return image
|
||||||
|
}
|
||||||
|
|
||||||
var preview: some View {
|
var preview: some View {
|
||||||
Rectangle()
|
circularViews
|
||||||
.frame(width: 150, height: 50, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var circularViews: some View {
|
||||||
|
VStack {
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
ForEach(Mood.allValues, id: \.self) { mood in
|
||||||
|
mood.icon
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.foregroundColor(mood.color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 100)
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
ForEach(entries, id: \.mood) { model in
|
||||||
|
ZStack {
|
||||||
|
Circle().fill(model.mood.color)
|
||||||
|
|
||||||
|
Text("\(model.percent, specifier: "%.0f")%")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.scaledToFill()
|
||||||
|
.minimumScaleFactor(0.5)
|
||||||
|
.lineLimit(1)
|
||||||
|
.foregroundColor(Color(UIColor.white))
|
||||||
|
.padding(2)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
ForEach(entries, id: \.mood) { model in
|
||||||
|
ZStack {
|
||||||
|
Circle().fill(model.mood.color)
|
||||||
|
|
||||||
|
Text("\(model.total)")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.scaledToFill()
|
||||||
|
.minimumScaleFactor(0.5)
|
||||||
|
.lineLimit(1)
|
||||||
|
.foregroundColor(Color(UIColor.white))
|
||||||
|
.padding(2)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var shareView: some View {
|
||||||
|
VStack {
|
||||||
|
Text(String(format: String(localized: "share_view_all_moods_total_template_title"), totalEntryCount))
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.padding(.top, 1)
|
||||||
|
|
||||||
|
circularViews
|
||||||
|
.padding([.trailing, .leading, .top])
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainView: some View {
|
var mainView: some View {
|
||||||
Text("AllMoodsSharingTemplate body")
|
VStack {
|
||||||
|
shareView
|
||||||
|
Spacer()
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
Button(action: {
|
||||||
|
showSharingTemplate = true
|
||||||
|
}, label: {
|
||||||
|
Text("Share")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.green
|
||||||
|
)
|
||||||
|
.padding(.trailing, -5)
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Exit")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.red
|
||||||
|
)
|
||||||
|
.padding(.leading, -5)
|
||||||
|
}
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
|
}.sheet(isPresented: $showSharingTemplate) {
|
||||||
|
ActivityViewController(activityItems: [self.image])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if isPreview {
|
if isPreview {
|
||||||
preview
|
preview
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
} else {
|
} else {
|
||||||
mainView
|
mainView
|
||||||
|
.padding([.leading, .trailing])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AllMoodsSharingTemplate_Previews: PreviewProvider {
|
struct AllMoodsSharingTemplate_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AllMoodsTotalTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
AllMoodsTotalTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||||
|
|
||||||
AllMoodsTotalTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
AllMoodsTotalTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,37 +8,146 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct CurrentStreakTemplate: View, SharingTemplate {
|
struct CurrentStreakTemplate: View, SharingTemplate {
|
||||||
|
var image: UIImage {
|
||||||
|
return UIImage(systemName: "square.and.arrow.up")!
|
||||||
|
}
|
||||||
|
|
||||||
static var description: String {
|
static var description: String {
|
||||||
"CurrentStreakTemplate"
|
"Last 10 Days"
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPreview: Bool
|
var isPreview: Bool
|
||||||
|
|
||||||
var startDate: Date
|
var startDate: Date
|
||||||
var endDate: Date
|
var endDate: Date
|
||||||
|
let moodEntries: [MoodEntry]
|
||||||
|
|
||||||
|
@State var showSharingTemplate = false
|
||||||
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
|
|
||||||
|
let columns = [
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center)
|
||||||
|
]
|
||||||
|
|
||||||
|
init(isPreview: Bool, startDate: Date, endDate: Date, fakeData: Bool) {
|
||||||
|
self.isPreview = isPreview
|
||||||
|
self.startDate = startDate
|
||||||
|
self.endDate = endDate
|
||||||
|
|
||||||
|
var _moodEntries: [MoodEntry]?
|
||||||
|
|
||||||
|
if fakeData {
|
||||||
|
_moodEntries = PersistenceController.shared.randomEntries(count: 10)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
_moodEntries = PersistenceController.shared.getData(startDate:startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
includedDays: [1,2,3,4,5,6,7])
|
||||||
|
}
|
||||||
|
|
||||||
|
self.moodEntries = _moodEntries ?? [MoodEntry]()
|
||||||
|
}
|
||||||
|
|
||||||
var preview: some View {
|
var preview: some View {
|
||||||
Rectangle()
|
HStack {
|
||||||
.frame(width: 150, height: 50, alignment: .leading)
|
VStack {
|
||||||
|
LazyVGrid(columns: columns, spacing: 0) {
|
||||||
|
ForEach(moodEntries) { entry in
|
||||||
|
entry.mood.icon
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.foregroundColor(entry.mood.color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(height: 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
var shareView: some View {
|
||||||
|
VStack {
|
||||||
|
Text(String(format: String(localized: "share_view_current_streak_template_title")))
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.padding(.top, 1)
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
VStack {
|
||||||
|
LazyVGrid(columns: columns, spacing: 0) {
|
||||||
|
ForEach(moodEntries) { entry in
|
||||||
|
entry.mood.icon
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.foregroundColor(entry.mood.color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainView: some View {
|
var mainView: some View {
|
||||||
Text("CurrentStreakTemplate body")
|
VStack {
|
||||||
|
shareView
|
||||||
|
Spacer()
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
Button(action: {
|
||||||
|
showSharingTemplate = true
|
||||||
|
}, label: {
|
||||||
|
Text("Share")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.green
|
||||||
|
)
|
||||||
|
.padding(.trailing, -5)
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Exit")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.red
|
||||||
|
)
|
||||||
|
.padding(.leading, -5)
|
||||||
|
}
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
|
}.sheet(isPresented: $showSharingTemplate) {
|
||||||
|
ActivityViewController(activityItems: [self.image])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if isPreview {
|
if isPreview {
|
||||||
preview
|
preview
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
} else {
|
} else {
|
||||||
mainView
|
mainView
|
||||||
|
.padding([.leading, .trailing])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CurrentStreakTemplate_Previews: PreviewProvider {
|
struct CurrentStreakTemplate_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
CurrentStreakTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
CurrentStreakTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||||
|
|
||||||
CurrentStreakTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
CurrentStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,122 +6,229 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Algorithms
|
||||||
|
|
||||||
struct LongestStreakTemplate: View, SharingTemplate {
|
struct LongestStreakTemplate: View, SharingTemplate {
|
||||||
static var description: String {
|
var image: UIImage {
|
||||||
"Share your longest streak!!!!"
|
return UIImage(systemName: "square.and.arrow.up")!
|
||||||
}
|
}
|
||||||
|
|
||||||
@State private var showSharingTemplate = false
|
static var description: String {
|
||||||
|
"Longest Streak"
|
||||||
|
}
|
||||||
|
|
||||||
|
private let itemFormatter: DateFormatter = {
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
formatter.dateStyle = .short
|
||||||
|
return formatter
|
||||||
|
}()
|
||||||
|
|
||||||
var isPreview: Bool
|
var isPreview: Bool
|
||||||
var startDate: Date
|
var startDate: Date
|
||||||
var endDate: Date
|
var endDate: Date
|
||||||
|
var fakeData: Bool
|
||||||
|
|
||||||
var entries: [MoodEntry]
|
@State var moodEntries = [MoodEntry]()
|
||||||
|
@State var selectedMood: Mood = .great
|
||||||
|
|
||||||
init(isPreview: Bool, startDate: Date, endDate: Date) {
|
@State var showSharingTemplate = false
|
||||||
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
|
|
||||||
|
let columns = [
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center)
|
||||||
|
]
|
||||||
|
|
||||||
|
init(isPreview: Bool, startDate: Date, endDate: Date, fakeData: Bool) {
|
||||||
self.isPreview = isPreview
|
self.isPreview = isPreview
|
||||||
self.startDate = startDate
|
self.startDate = startDate
|
||||||
self.endDate = endDate
|
self.endDate = endDate
|
||||||
|
self.fakeData = fakeData
|
||||||
|
|
||||||
/*
|
configureData(fakeData: self.fakeData, mood: self.selectedMood)
|
||||||
get all
|
|
||||||
Split on missing entries
|
|
||||||
Longest subarray
|
|
||||||
*/
|
|
||||||
entries = [MoodEntry]()
|
|
||||||
// entries = PersistenceController.shared.randomEntries(count: 10)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var image: UIImage {
|
private func configureData(fakeData: Bool, mood: Mood) {
|
||||||
let image = shit.snapshot()
|
var _moodEntries: [MoodEntry]?
|
||||||
return image
|
|
||||||
|
if fakeData {
|
||||||
|
_moodEntries = PersistenceController.shared.randomEntries(count: 10)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
_moodEntries = PersistenceController.shared.getData(startDate:startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
includedDays: [1,2,3,4,5,6,7])
|
||||||
|
}
|
||||||
|
let data = _moodEntries ?? [MoodEntry]()
|
||||||
|
|
||||||
|
var splitArrays = createSubArrays(fromMoodEntries: data, splitOn: mood)
|
||||||
|
splitArrays = splitArrays.sorted(by: {
|
||||||
|
$0.count > $1.count
|
||||||
|
} )
|
||||||
|
self.moodEntries = splitArrays.first ?? [MoodEntry]()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createSubArrays(fromMoodEntries: [MoodEntry], splitOn: Mood) -> [[MoodEntry]] {
|
||||||
|
var splitArrays = [[MoodEntry]]()
|
||||||
|
var currentSplit = [MoodEntry]()
|
||||||
|
for entry in fromMoodEntries {
|
||||||
|
if entry.mood == splitOn {
|
||||||
|
currentSplit.append(entry)
|
||||||
|
} else {
|
||||||
|
splitArrays.append(currentSplit)
|
||||||
|
currentSplit.removeAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// append the last grouping
|
||||||
|
splitArrays.append(currentSplit)
|
||||||
|
return splitArrays
|
||||||
}
|
}
|
||||||
|
|
||||||
var preview: some View {
|
var preview: some View {
|
||||||
ZStack {
|
HStack {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
LazyVGrid(columns: columns, spacing: 0) {
|
||||||
Text("Longest Streak")
|
ForEach(moodEntries) { entry in
|
||||||
Spacer()
|
entry.mood.icon
|
||||||
Text(String(entries.count))
|
.resizable()
|
||||||
}
|
.aspectRatio(contentMode: .fit)
|
||||||
Text("From")
|
.foregroundColor(entry.mood.color)
|
||||||
HStack {
|
}
|
||||||
Text(String(entries.first?.forDate?.description ?? ""))
|
|
||||||
Text("-")
|
|
||||||
Text(String(entries.last?.forDate?.description ?? ""))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.background(
|
.frame(height: 88)
|
||||||
Color.red
|
.clipped()
|
||||||
)
|
.onAppear(perform: {
|
||||||
|
self.configureData(fakeData: self.fakeData, mood: self.selectedMood)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var shit: some View {
|
var shareView: some View {
|
||||||
ZStack {
|
VStack {
|
||||||
VStack {
|
Text(String(format: String(localized: "share_view_longest_streak_template_title"), self.selectedMood.strValue))
|
||||||
HStack {
|
.font(.title)
|
||||||
Text("Longest Streak")
|
.foregroundColor(Color(UIColor.label))
|
||||||
Spacer()
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
Text(String(entries.count))
|
.padding(.top, 1)
|
||||||
}
|
|
||||||
Text("From")
|
HStack {
|
||||||
HStack {
|
Text(self.moodEntries.first?.forDate ?? Date(), formatter: itemFormatter)
|
||||||
Text(String(entries.first?.forDate?.description ?? ""))
|
.font(.title)
|
||||||
Text("-")
|
.foregroundColor(Color(UIColor.label))
|
||||||
Text(String(entries.last?.forDate?.description ?? ""))
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.padding(.top, 1)
|
||||||
|
|
||||||
|
Text("-")
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.padding(.top, 1)
|
||||||
|
|
||||||
|
Text(self.moodEntries.last?.forDate ?? Date(), formatter: itemFormatter)
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.padding(.top, 1)
|
||||||
|
}
|
||||||
|
HStack {
|
||||||
|
VStack {
|
||||||
|
LazyVGrid(columns: columns, spacing: 0) {
|
||||||
|
ForEach(moodEntries) { entry in
|
||||||
|
entry.mood.icon
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.foregroundColor(entry.mood.color)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.padding()
|
||||||
}
|
}
|
||||||
.background(
|
.onAppear(perform: {
|
||||||
Color.red
|
self.configureData(fakeData: self.fakeData, mood: self.selectedMood)
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainView: some View {
|
var mainView: some View {
|
||||||
ZStack {
|
VStack {
|
||||||
shit
|
shareView
|
||||||
|
Spacer()
|
||||||
VStack {
|
Menu(content: {
|
||||||
Spacer()
|
ForEach(Mood.allValues) { mood in
|
||||||
|
Button(mood.strValue, action: {
|
||||||
HStack {
|
selectedMood = mood
|
||||||
Spacer()
|
configureData(fakeData: self.fakeData, mood: self.selectedMood)
|
||||||
|
|
||||||
Button(action: {
|
|
||||||
showSharingTemplate = true
|
|
||||||
}, label: {
|
|
||||||
Image(systemName: "square.and.arrow.up")
|
|
||||||
.foregroundColor(.black)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}, label: {
|
||||||
|
Text("Moods")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color(UIColor.white))
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.green
|
||||||
|
)
|
||||||
|
.padding([.leading, .trailing], -5)
|
||||||
|
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
Button(action: {
|
||||||
|
showSharingTemplate = true
|
||||||
|
}, label: {
|
||||||
|
Text("Share")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.green
|
||||||
|
)
|
||||||
|
.padding(.trailing, -5)
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Exit")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.red
|
||||||
|
)
|
||||||
|
.padding(.leading, -5)
|
||||||
}
|
}
|
||||||
}
|
.padding([.leading, .trailing], -20)
|
||||||
.sheet(isPresented: $showSharingTemplate) {
|
}.sheet(isPresented: $showSharingTemplate) {
|
||||||
ActivityViewController(activityItems: [self.image])
|
ActivityViewController(activityItems: [self.image])
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
.background(
|
|
||||||
Color.red
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if isPreview {
|
if isPreview {
|
||||||
preview
|
preview
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
} else {
|
} else {
|
||||||
mainView
|
mainView
|
||||||
|
.padding([.leading, .trailing])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CurrentStreakSharingTemplate_Previews: PreviewProvider {
|
struct CurrentStreakSharingTemplate_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
LongestStreakTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
LongestStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true)
|
||||||
|
|
||||||
LongestStreakTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
LongestStreakTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,36 +9,184 @@ import SwiftUI
|
|||||||
|
|
||||||
struct MonthTotalTemplate: View, SharingTemplate {
|
struct MonthTotalTemplate: View, SharingTemplate {
|
||||||
static var description: String {
|
static var description: String {
|
||||||
"MonthTotalTemplate"
|
"This Month"
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPreview: Bool
|
var isPreview: Bool
|
||||||
|
var startDate: Date
|
||||||
var startDate: Date
|
var endDate: Date
|
||||||
var endDate: Date
|
var totalEntryCount: Int = 0
|
||||||
|
|
||||||
var preview: some View {
|
private var month = Calendar.current.dateComponents([.month], from: Date()).month!
|
||||||
Rectangle()
|
|
||||||
.frame(width: 150, height: 50, alignment: .leading)
|
@State var showSharingTemplate = false
|
||||||
}
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
var mainView: some View {
|
private var moodMetrics = [MoodMetrics]()
|
||||||
Text("MonthTotalTemplate body")
|
private var moodEntries = [MoodEntry]()
|
||||||
}
|
|
||||||
|
let columns = [
|
||||||
var body: some View {
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
if isPreview {
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
preview
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
} else {
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
mainView
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
}
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center),
|
||||||
}
|
GridItem(.flexible(minimum: 5, maximum: .infinity), alignment: .center)
|
||||||
|
]
|
||||||
|
|
||||||
|
init(isPreview: Bool, startDate: Date, endDate: Date, fakeData: Bool) {
|
||||||
|
self.isPreview = isPreview
|
||||||
|
self.startDate = startDate
|
||||||
|
self.endDate = endDate
|
||||||
|
|
||||||
|
var _moodEntries: [MoodEntry]?
|
||||||
|
|
||||||
|
if fakeData {
|
||||||
|
_moodEntries = PersistenceController.shared.randomEntries(count: 10)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
_moodEntries = PersistenceController.shared.getData(startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
includedDays: [1,2,3,4,5,6,7])
|
||||||
|
|
||||||
|
// _moodEntries = PersistenceController.shared.getData(startDate:Calendar.current.date(byAdding: .day, value: -33, to: Date())!,
|
||||||
|
// endDate: Date(),
|
||||||
|
// includedDays: [1,2,3,4,5,6,7])
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
moodEntries = _moodEntries ?? [MoodEntry]()
|
||||||
|
|
||||||
|
totalEntryCount = moodEntries.count
|
||||||
|
|
||||||
|
for (_, mood) in Mood.allValues.enumerated() {
|
||||||
|
let moodEntries = moodEntries.filter({
|
||||||
|
Int($0.moodValue) == mood.rawValue
|
||||||
|
})
|
||||||
|
let total = moodEntries.count
|
||||||
|
let perc = (Float(total) / Float(totalEntryCount)) * 100
|
||||||
|
moodMetrics.append(MoodMetrics(mood: mood, total: total, percent: perc))
|
||||||
|
}
|
||||||
|
|
||||||
|
moodMetrics = moodMetrics.sorted(by: {
|
||||||
|
$0.mood.rawValue > $1.mood.rawValue
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var image: UIImage {
|
||||||
|
let image = shareView.snapshot()
|
||||||
|
return image
|
||||||
|
}
|
||||||
|
|
||||||
|
var preview: some View {
|
||||||
|
circularViews
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var circularViews: some View {
|
||||||
|
HStack {
|
||||||
|
ForEach(moodMetrics, id: \.mood) { model in
|
||||||
|
ZStack {
|
||||||
|
Circle().fill(model.mood.color)
|
||||||
|
|
||||||
|
Text("\(model.percent, specifier: "%.0f")%")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.minimumScaleFactor(0.5)
|
||||||
|
.lineLimit(1)
|
||||||
|
.foregroundColor(Color(UIColor.white))
|
||||||
|
.padding(5)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.frame(height: 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var shareView: some View {
|
||||||
|
VStack {
|
||||||
|
Text(String(format: String(localized: "share_view_month_moods_total_template_title"), Random.monthName(fromMonthInt: month), moodEntries.count))
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.padding(.top, 1)
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
LazyVGrid(columns: columns, spacing: 0) {
|
||||||
|
ForEach(moodEntries) { entry in
|
||||||
|
entry.mood.icon
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.foregroundColor(entry.mood.color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
circularViews
|
||||||
|
.padding([.trailing, .leading, .top])
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var mainView: some View {
|
||||||
|
VStack {
|
||||||
|
shareView
|
||||||
|
Spacer()
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
Button(action: {
|
||||||
|
showSharingTemplate = true
|
||||||
|
}, label: {
|
||||||
|
Text("Share")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.green
|
||||||
|
)
|
||||||
|
.padding(.trailing, -5)
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Exit")
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color.white)
|
||||||
|
.padding(.top, 20)
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
|
.background(
|
||||||
|
Color.red
|
||||||
|
)
|
||||||
|
.padding(.leading, -5)
|
||||||
|
}
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
|
}.sheet(isPresented: $showSharingTemplate) {
|
||||||
|
ActivityViewController(activityItems: [self.image])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
if isPreview {
|
||||||
|
preview
|
||||||
|
.padding([.leading, .trailing], -20)
|
||||||
|
} else {
|
||||||
|
mainView
|
||||||
|
.padding([.leading, .trailing])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MonthTotalTemplate_Previews: PreviewProvider {
|
struct MonthTotalTemplate_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
MonthTotalTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
MonthTotalTemplate(isPreview: true, startDate: Date().startOfMonth(), endDate: Date().endOfMonth(), fakeData: true)
|
||||||
|
|
||||||
MonthTotalTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
MonthTotalTemplate(isPreview: false, startDate: Date().startOfMonth(), endDate: Date().endOfMonth(), fakeData: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,30 +9,34 @@ import SwiftUI
|
|||||||
|
|
||||||
struct WeekTotalTemplate: View, SharingTemplate {
|
struct WeekTotalTemplate: View, SharingTemplate {
|
||||||
static var description: String {
|
static var description: String {
|
||||||
"WeekTotalTemplate"
|
"WeekTotalTemplate"
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPreview: Bool
|
var image: UIImage {
|
||||||
|
return UIImage(systemName: "square.and.arrow.up")!
|
||||||
var startDate: Date
|
}
|
||||||
var endDate: Date
|
|
||||||
|
var isPreview: Bool
|
||||||
var preview: some View {
|
|
||||||
Rectangle()
|
var startDate: Date
|
||||||
.frame(width: 150, height: 50, alignment: .leading)
|
var endDate: Date
|
||||||
}
|
|
||||||
|
var preview: some View {
|
||||||
var mainView: some View {
|
Rectangle()
|
||||||
Text("WeekTotalTemplate body")
|
.frame(width: 150, height: 50, alignment: .leading)
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var mainView: some View {
|
||||||
if isPreview {
|
Text("WeekTotalTemplate body")
|
||||||
preview
|
}
|
||||||
} else {
|
|
||||||
mainView
|
var body: some View {
|
||||||
}
|
if isPreview {
|
||||||
}
|
preview
|
||||||
|
} else {
|
||||||
|
mainView
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct WeekTotalTemplate_Previews: PreviewProvider {
|
struct WeekTotalTemplate_Previews: PreviewProvider {
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class PersistenceController {
|
|||||||
return PersistenceController.shared.container.viewContext
|
return PersistenceController.shared.container.viewContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var childContext: NSManagedObjectContext {
|
||||||
|
return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public var switchContainerListeners = [(() -> Void)]()
|
public var switchContainerListeners = [(() -> Void)]()
|
||||||
|
|
||||||
public func getEntry(byDate date: Date) -> MoodEntry? {
|
public func getEntry(byDate date: Date) -> MoodEntry? {
|
||||||
@@ -185,7 +190,7 @@ class PersistenceController {
|
|||||||
var entries = [MoodEntry]()
|
var entries = [MoodEntry]()
|
||||||
|
|
||||||
for idx in 0..<count {
|
for idx in 0..<count {
|
||||||
let newItem = MoodEntry(context: viewContext)
|
let newItem = MoodEntry(context: childContext)
|
||||||
newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date())
|
newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date())
|
||||||
newItem.moodValue = Int16(Mood.allValues.randomElement()!.rawValue)
|
newItem.moodValue = Int16(Mood.allValues.randomElement()!.rawValue)
|
||||||
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ protocol SharingTemplate {
|
|||||||
var startDate: Date { get }
|
var startDate: Date { get }
|
||||||
var endDate: Date { get }
|
var endDate: Date { get }
|
||||||
var isPreview: Bool { get }
|
var isPreview: Bool { get }
|
||||||
|
var image: UIImage { get }
|
||||||
static var description: String { get }
|
static var description: String { get }
|
||||||
|
|
||||||
@ViewBuilder var mainView: Self.MainView { get }
|
@ViewBuilder var mainView: Self.MainView { get }
|
||||||
|
|||||||
@@ -59,6 +59,30 @@ extension Date: RawRepresentable {
|
|||||||
public init?(rawValue: String) {
|
public init?(rawValue: String) {
|
||||||
self = Date(timeIntervalSinceReferenceDate: Double(rawValue) ?? 0.0)
|
self = Date(timeIntervalSinceReferenceDate: Double(rawValue) ?? 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startOfMonth() -> Date {
|
||||||
|
let interval = Calendar.current.dateInterval(of: .month, for: self)
|
||||||
|
return (interval?.start.toLocalTime())! // Without toLocalTime it give last months last date
|
||||||
|
}
|
||||||
|
|
||||||
|
func endOfMonth() -> Date {
|
||||||
|
let interval = Calendar.current.dateInterval(of: .month, for: self)
|
||||||
|
return interval!.end
|
||||||
|
}
|
||||||
|
|
||||||
|
func toLocalTime() -> Date {
|
||||||
|
let timezone = TimeZone.current
|
||||||
|
let seconds = TimeInterval(timezone.secondsFromGMT(for: self))
|
||||||
|
return Date(timeInterval: seconds, since: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
var weekday: Int {
|
||||||
|
Calendar.current.component(.weekday, from: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstDayOfTheMonth: Date {
|
||||||
|
Calendar.current.dateComponents([.calendar, .year,.month], from: self).date!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ struct ContentView: View {
|
|||||||
Label(String(localized: "content_view_tab_filter"), systemImage: "calendar.circle")
|
Label(String(localized: "content_view_tab_filter"), systemImage: "calendar.circle")
|
||||||
}
|
}
|
||||||
|
|
||||||
SharingView()
|
SharingListView()
|
||||||
.tabItem {
|
.tabItem {
|
||||||
Label(String(localized: "content_view_tab_share"), systemImage: "square.and.arrow.up")
|
Label(String(localized: "content_view_tab_share"), systemImage: "square.and.arrow.up")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
//
|
|
||||||
// ShareButtonview.swift
|
|
||||||
// Feels (iOS)
|
|
||||||
//
|
|
||||||
// Created by Trey Tartt on 2/8/22.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct ShareButtonview: View, Equatable {
|
|
||||||
static func == (lhs: ShareButtonview, rhs: ShareButtonview) -> Bool {
|
|
||||||
lhs.image == rhs.image
|
|
||||||
}
|
|
||||||
|
|
||||||
@State private var showSheet = false
|
|
||||||
@State var image: UIImage? {
|
|
||||||
didSet {
|
|
||||||
showSheet = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
Button(action: {
|
|
||||||
showSheet = true
|
|
||||||
}, label: {
|
|
||||||
Image(systemName: "square.and.arrow.up")
|
|
||||||
.foregroundColor(.black)
|
|
||||||
})
|
|
||||||
|
|
||||||
if showSheet {
|
|
||||||
if let image = image {
|
|
||||||
ActivityViewController(activityItems: [image])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ShareButtonview_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
ShareButtonview()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
151
Shared/views/SharingListView.swift
Normal file
151
Shared/views/SharingListView.swift
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
//
|
||||||
|
// SharingView.swift
|
||||||
|
// Feels (iOS)
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 2/6/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct WrappedSharable: Hashable, Equatable {
|
||||||
|
static func == (lhs: WrappedSharable, rhs: WrappedSharable) -> Bool {
|
||||||
|
lhs.id == rhs.id && lhs.description == rhs.description
|
||||||
|
}
|
||||||
|
|
||||||
|
func hash(into hasher: inout Hasher) {
|
||||||
|
hasher.combine(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
let id = UUID()
|
||||||
|
let preview: AnyView
|
||||||
|
let destination: AnyView
|
||||||
|
let description: String
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SharingListView: View {
|
||||||
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||||
|
|
||||||
|
class StupidAssObservableObject: ObservableObject {
|
||||||
|
@Published var fuckingWrappedShrable: WrappedSharable? = nil
|
||||||
|
@Published var showFuckingSheet = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@StateObject private var selectedShare = StupidAssObservableObject()
|
||||||
|
|
||||||
|
let sharebleItems: [WrappedSharable] = [
|
||||||
|
WrappedSharable(preview: AnyView(
|
||||||
|
AllMoodsTotalTemplate(isPreview: true,
|
||||||
|
startDate: PersistenceController.shared.earliestEntry?.forDate ?? Date(),
|
||||||
|
endDate: Date(),
|
||||||
|
fakeData: false)
|
||||||
|
),destination: AnyView(
|
||||||
|
AllMoodsTotalTemplate(isPreview: false,
|
||||||
|
startDate: PersistenceController.shared.earliestEntry?.forDate ?? Date(),
|
||||||
|
endDate: Date(),
|
||||||
|
fakeData: false)
|
||||||
|
),description: AllMoodsTotalTemplate.description),
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
WrappedSharable(preview: AnyView(
|
||||||
|
CurrentStreakTemplate(isPreview: true,
|
||||||
|
startDate: Calendar.current.date(byAdding: .day, value: -10, to: Date())!,
|
||||||
|
endDate: Date(),
|
||||||
|
fakeData: false)
|
||||||
|
), destination: AnyView(
|
||||||
|
CurrentStreakTemplate(isPreview: false,
|
||||||
|
startDate: Calendar.current.date(byAdding: .day, value: -10, to: Date())!,
|
||||||
|
endDate: Date(),
|
||||||
|
fakeData: false)
|
||||||
|
), description: CurrentStreakTemplate.description),
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
WrappedSharable(preview: AnyView(
|
||||||
|
LongestStreakTemplate(isPreview: true,
|
||||||
|
startDate: PersistenceController.shared.earliestEntry?.forDate ?? Date(),
|
||||||
|
endDate: Date(),
|
||||||
|
fakeData: false)
|
||||||
|
), destination: AnyView(
|
||||||
|
LongestStreakTemplate(isPreview: false,
|
||||||
|
startDate: PersistenceController.shared.earliestEntry?.forDate ?? Date(),
|
||||||
|
endDate: Date(),
|
||||||
|
fakeData: false)
|
||||||
|
), description: LongestStreakTemplate.description),
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
WrappedSharable(preview: AnyView(
|
||||||
|
MonthTotalTemplate(isPreview: true,
|
||||||
|
startDate: Date().startOfMonth(),
|
||||||
|
endDate: Date().endOfMonth(),
|
||||||
|
fakeData: false)
|
||||||
|
), destination: AnyView(
|
||||||
|
MonthTotalTemplate(isPreview: false,
|
||||||
|
startDate: Date().startOfMonth(),
|
||||||
|
endDate: Date().endOfMonth(),
|
||||||
|
fakeData: false)
|
||||||
|
), description: MonthTotalTemplate.description),
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
]
|
||||||
|
|
||||||
|
func didDismiss() {
|
||||||
|
selectedShare.showFuckingSheet = false
|
||||||
|
selectedShare.fuckingWrappedShrable = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
Text(String(format: String(localized: "Share your shit")))
|
||||||
|
.font(.title)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.padding([.top, .leading])
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
ForEach(sharebleItems, id: \.self) { item in
|
||||||
|
Button(action: {
|
||||||
|
selectedShare.fuckingWrappedShrable = item
|
||||||
|
selectedShare.showFuckingSheet = true
|
||||||
|
}, label: {
|
||||||
|
ZStack {
|
||||||
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
|
|
||||||
|
item.preview
|
||||||
|
.frame(height: 88)
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
Spacer()
|
||||||
|
Text(item.description)
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.fontWeight(.bold)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
.frame(height: 44)
|
||||||
|
.background(
|
||||||
|
Color(UIColor.secondarySystemBackground)
|
||||||
|
)
|
||||||
|
.opacity(0.9)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(height: 88)
|
||||||
|
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
|
.scaledToFill()
|
||||||
|
.clipped()
|
||||||
|
.contentShape(Path(CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 88)))
|
||||||
|
.padding([.leading, .trailing])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}.background(
|
||||||
|
theme.currentTheme.bg
|
||||||
|
.edgesIgnoringSafeArea(.all)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.sheet(isPresented: $selectedShare.showFuckingSheet,
|
||||||
|
onDismiss: didDismiss) {
|
||||||
|
selectedShare.fuckingWrappedShrable?.destination
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SharingView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
SharingListView()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
//
|
|
||||||
// SharingView.swift
|
|
||||||
// Feels (iOS)
|
|
||||||
//
|
|
||||||
// Created by Trey Tartt on 2/6/22.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct WrappedSharable: Hashable, Equatable {
|
|
||||||
static func == (lhs: WrappedSharable, rhs: WrappedSharable) -> Bool {
|
|
||||||
lhs.id == rhs.id
|
|
||||||
}
|
|
||||||
|
|
||||||
func hash(into hasher: inout Hasher) {
|
|
||||||
hasher.combine(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
let id = UUID()
|
|
||||||
let preview: AnyView
|
|
||||||
let destination: AnyView
|
|
||||||
let description: String
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SharingView: View {
|
|
||||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
|
||||||
|
|
||||||
@State private var selectedShare: WrappedSharable?
|
|
||||||
@State private var showSharingTemplate = false
|
|
||||||
|
|
||||||
let sharebleItems: [WrappedSharable] = [
|
|
||||||
WrappedSharable(preview: AnyView(
|
|
||||||
AllMoodsTotalTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
|
||||||
),destination: AnyView(
|
|
||||||
AllMoodsTotalTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
|
||||||
),description: AllMoodsTotalTemplate.description),
|
|
||||||
|
|
||||||
WrappedSharable(preview: AnyView(
|
|
||||||
CurrentStreakTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
|
||||||
), destination: AnyView(
|
|
||||||
CurrentStreakTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
|
||||||
), description: CurrentStreakTemplate.description),
|
|
||||||
|
|
||||||
WrappedSharable(preview: AnyView(
|
|
||||||
LongestStreakTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
|
||||||
), destination: AnyView(
|
|
||||||
LongestStreakTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
|
||||||
), description: LongestStreakTemplate.description),
|
|
||||||
|
|
||||||
WrappedSharable(preview: AnyView(
|
|
||||||
MonthTotalTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
|
||||||
), destination: AnyView(
|
|
||||||
MonthTotalTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
|
||||||
), description: MonthTotalTemplate.description),
|
|
||||||
|
|
||||||
WrappedSharable(preview: AnyView(
|
|
||||||
WeekTotalTemplate(isPreview: true, startDate: Date(), endDate: Date())
|
|
||||||
), destination: AnyView(
|
|
||||||
WeekTotalTemplate(isPreview: false, startDate: Date(), endDate: Date())
|
|
||||||
), description: WeekTotalTemplate.description)
|
|
||||||
]
|
|
||||||
|
|
||||||
func didDismiss() {
|
|
||||||
showSharingTemplate = false
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
ScrollView {
|
|
||||||
ForEach(sharebleItems, id: \.self) { item in
|
|
||||||
ZStack {
|
|
||||||
Color(theme.currentTheme.secondaryBGColor)
|
|
||||||
|
|
||||||
item.preview
|
|
||||||
.opacity(0.5)
|
|
||||||
|
|
||||||
VStack {
|
|
||||||
Spacer()
|
|
||||||
Text(item.description)
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity)
|
|
||||||
.background(
|
|
||||||
Color.white
|
|
||||||
)
|
|
||||||
.frame(minHeight: 22, maxHeight: 22)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.frame(minHeight: 88, maxHeight: 88)
|
|
||||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
|
||||||
.onTapGesture ( perform: {
|
|
||||||
selectedShare = item
|
|
||||||
showSharingTemplate = true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
}.sheet(isPresented: $showSharingTemplate,
|
|
||||||
onDismiss: didDismiss) {
|
|
||||||
selectedShare?.destination
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SharingView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
SharingView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -65,3 +65,8 @@
|
|||||||
"mood_value_horrible" = "Horrible";
|
"mood_value_horrible" = "Horrible";
|
||||||
"mood_value_missing" = "Missing";
|
"mood_value_missing" = "Missing";
|
||||||
"mood_value_missing_tap_to_add" = "Missing - Tap to add";
|
"mood_value_missing_tap_to_add" = "Missing - Tap to add";
|
||||||
|
|
||||||
|
"share_view_all_moods_total_template_title" = "Total Entries: %d";
|
||||||
|
"share_view_month_moods_total_template_title" = "Total Entries for %@ - %d";
|
||||||
|
"share_view_current_streak_template_title" = "Last 10 Days";
|
||||||
|
"share_view_longest_streak_template_title" = "Longest consecutive days I was %@";
|
||||||
|
|||||||
Reference in New Issue
Block a user