filtering days in customize will filter views
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
1C2162F727C16D11004353D1 /* MoodTintable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2162F627C16D11004353D1 /* MoodTintable.swift */; };
|
||||
1C2162F827C16E3C004353D1 /* MoodTintable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2162F627C16D11004353D1 /* MoodTintable.swift */; };
|
||||
1C2618FA2795E41D00FDC148 /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 1C2618F92795E41D00FDC148 /* Charts */; };
|
||||
1C2618FE27960A4F00FDC148 /* FilterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */; };
|
||||
1C2618FE27960A4F00FDC148 /* YearViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2618FD27960A4F00FDC148 /* YearViewModel.swift */; };
|
||||
1C26190327960CE500FDC148 /* ChartDataBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190227960CE500FDC148 /* ChartDataBuildable.swift */; };
|
||||
1C26190727960DC900FDC148 /* ChartViewItemBuildable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C26190627960DC900FDC148 /* ChartViewItemBuildable.swift */; };
|
||||
1C2C5B2B27DEBE260092A308 /* EventLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C414C2F27DB1C2400BC1720 /* EventLogger.swift */; };
|
||||
@@ -88,7 +88,7 @@
|
||||
1C95ABCA27E6F73A00509BD3 /* Shapes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABC827E6F73A00509BD3 /* Shapes.swift */; };
|
||||
1C95ABCC27E6FA7200509BD3 /* DiamondView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */; };
|
||||
1C95ABCD27E6FA7200509BD3 /* DiamondView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */; };
|
||||
1CA037702799FFA600D26164 /* HomeViewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA0376F2799FFA600D26164 /* HomeViewViewModel.swift */; };
|
||||
1CA037702799FFA600D26164 /* DayViewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA0376F2799FFA600D26164 /* DayViewViewModel.swift */; };
|
||||
1CA03773279A293D00D26164 /* OnboardingTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03772279A293D00D26164 /* OnboardingTime.swift */; };
|
||||
1CA03775279A294800D26164 /* OnboardingDay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03774279A294800D26164 /* OnboardingDay.swift */; };
|
||||
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03776279A295600D26164 /* OnboardingTitle.swift */; };
|
||||
@@ -98,11 +98,11 @@
|
||||
1CAD603427A5C1C800C520BD /* SmallRollUpHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD602B27A5C1C800C520BD /* SmallRollUpHeaderView.swift */; };
|
||||
1CAD603527A5C1C800C520BD /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD602C27A5C1C800C520BD /* SettingsView.swift */; };
|
||||
1CAD603627A5C1C800C520BD /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD602D27A5C1C800C520BD /* GraphView.swift */; };
|
||||
1CAD603727A5C1C800C520BD /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD602E27A5C1C800C520BD /* FilterView.swift */; };
|
||||
1CAD603727A5C1C800C520BD /* YearView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD602E27A5C1C800C520BD /* YearView.swift */; };
|
||||
1CAD603827A5C1C800C520BD /* AddMoodHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD602F27A5C1C800C520BD /* AddMoodHeaderView.swift */; };
|
||||
1CAD603927A5C1C800C520BD /* HeaderPercView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603027A5C1C800C520BD /* HeaderPercView.swift */; };
|
||||
1CAD603A27A5C1C800C520BD /* BGView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603127A5C1C800C520BD /* BGView.swift */; };
|
||||
1CAD603B27A5C1C800C520BD /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603227A5C1C800C520BD /* HomeView.swift */; };
|
||||
1CAD603B27A5C1C800C520BD /* DayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603227A5C1C800C520BD /* DayView.swift */; };
|
||||
1CAD603C27A5C1C800C520BD /* HeaderStatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603327A5C1C800C520BD /* HeaderStatsView.swift */; };
|
||||
1CAD603E27A6ECCD00C520BD /* SwitchableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */; };
|
||||
1CB101C527B62A2D00D1C033 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CB101C427B62A2D00D1C033 /* EmptyView.swift */; };
|
||||
@@ -196,7 +196,7 @@
|
||||
1C2162F127C156E6004353D1 /* CustomizeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizeView.swift; sourceTree = "<group>"; };
|
||||
1C2162F327C1602D004353D1 /* MoodImagable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoodImagable.swift; sourceTree = "<group>"; };
|
||||
1C2162F627C16D11004353D1 /* MoodTintable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoodTintable.swift; sourceTree = "<group>"; };
|
||||
1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterViewModel.swift; sourceTree = "<group>"; };
|
||||
1C2618FD27960A4F00FDC148 /* YearViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YearViewModel.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>"; };
|
||||
1C358FAC27ADD0C3002C83A6 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
|
||||
@@ -231,7 +231,7 @@
|
||||
1C76E86D27C882A400ADEE1F /* SharingImageModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingImageModels.swift; sourceTree = "<group>"; };
|
||||
1C95ABC827E6F73A00509BD3 /* Shapes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shapes.swift; sourceTree = "<group>"; };
|
||||
1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiamondView.swift; sourceTree = "<group>"; };
|
||||
1CA0376F2799FFA600D26164 /* HomeViewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewViewModel.swift; sourceTree = "<group>"; };
|
||||
1CA0376F2799FFA600D26164 /* DayViewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayViewViewModel.swift; sourceTree = "<group>"; };
|
||||
1CA03772279A293D00D26164 /* OnboardingTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTime.swift; sourceTree = "<group>"; };
|
||||
1CA03774279A294800D26164 /* OnboardingDay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingDay.swift; sourceTree = "<group>"; };
|
||||
1CA03776279A295600D26164 /* OnboardingTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTitle.swift; sourceTree = "<group>"; };
|
||||
@@ -240,11 +240,11 @@
|
||||
1CAD602B27A5C1C800C520BD /* SmallRollUpHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SmallRollUpHeaderView.swift; sourceTree = "<group>"; };
|
||||
1CAD602C27A5C1C800C520BD /* SettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
|
||||
1CAD602D27A5C1C800C520BD /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = "<group>"; };
|
||||
1CAD602E27A5C1C800C520BD /* FilterView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilterView.swift; sourceTree = "<group>"; };
|
||||
1CAD602E27A5C1C800C520BD /* YearView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YearView.swift; sourceTree = "<group>"; };
|
||||
1CAD602F27A5C1C800C520BD /* AddMoodHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddMoodHeaderView.swift; sourceTree = "<group>"; };
|
||||
1CAD603027A5C1C800C520BD /* HeaderPercView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderPercView.swift; sourceTree = "<group>"; };
|
||||
1CAD603127A5C1C800C520BD /* BGView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BGView.swift; sourceTree = "<group>"; };
|
||||
1CAD603227A5C1C800C520BD /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
|
||||
1CAD603227A5C1C800C520BD /* DayView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DayView.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>"; };
|
||||
1CB101C427B62A2D00D1C033 /* EmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyView.swift; sourceTree = "<group>"; };
|
||||
@@ -333,13 +333,13 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
1C04488F27C2CA9C00D22444 /* HomeView */ = {
|
||||
1C04488F27C2CA9C00D22444 /* DayView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1CAD603227A5C1C800C520BD /* HomeView.swift */,
|
||||
1CA0376F2799FFA600D26164 /* HomeViewViewModel.swift */,
|
||||
1CAD603227A5C1C800C520BD /* DayView.swift */,
|
||||
1CA0376F2799FFA600D26164 /* DayViewViewModel.swift */,
|
||||
);
|
||||
path = HomeView;
|
||||
path = DayView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1C04489027C2CAAC00D22444 /* CustomIcon */ = {
|
||||
@@ -377,13 +377,13 @@
|
||||
path = SettingsView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1C04489427C2CAD100D22444 /* FilterView */ = {
|
||||
1C04489427C2CAD100D22444 /* YearView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */,
|
||||
1CAD602E27A5C1C800C520BD /* FilterView.swift */,
|
||||
1CAD602E27A5C1C800C520BD /* YearView.swift */,
|
||||
1C2618FD27960A4F00FDC148 /* YearViewModel.swift */,
|
||||
);
|
||||
path = FilterView;
|
||||
path = YearView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1C04489527C2CB1A00D22444 /* Sharing */ = {
|
||||
@@ -470,11 +470,11 @@
|
||||
1C04489127C2CAB100D22444 /* CustomWidget */,
|
||||
1CC469AB27907D48003E0C6E /* DayChartView.swift */,
|
||||
1CB101C427B62A2D00D1C033 /* EmptyView.swift */,
|
||||
1C04489427C2CAD100D22444 /* FilterView */,
|
||||
1C04489427C2CAD100D22444 /* YearView */,
|
||||
1CAD602D27A5C1C800C520BD /* GraphView.swift */,
|
||||
1CAD603027A5C1C800C520BD /* HeaderPercView.swift */,
|
||||
1CAD603327A5C1C800C520BD /* HeaderStatsView.swift */,
|
||||
1C04488F27C2CA9C00D22444 /* HomeView */,
|
||||
1C04488F27C2CA9C00D22444 /* DayView */,
|
||||
1C361F0B27C0356B00E832FC /* MainTabView.swift */,
|
||||
1C4DAA7327CC263F00C25D2B /* MonthView */,
|
||||
1C04489327C2CABF00D22444 /* SettingsView */,
|
||||
@@ -595,6 +595,8 @@
|
||||
1CD90B60278C7EBA001C4FEA /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1C718C6F27F611C900A8F9FE /* DaysFilterClass.swift */,
|
||||
1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */,
|
||||
1CD90B61278C7EBA001C4FEA /* Mood.swift */,
|
||||
1CD90B62278C7EBA001C4FEA /* MoodEntryExtension.swift */,
|
||||
1C2162F327C1602D004353D1 /* MoodImagable.swift */,
|
||||
@@ -602,13 +604,11 @@
|
||||
1C2162F627C16D11004353D1 /* MoodTintable.swift */,
|
||||
1C361F1327C03C8600E832FC /* OnboardingDataDataManager.swift */,
|
||||
1C04488627C1C81D00D22444 /* PersonalityPackable.swift */,
|
||||
1C95ABC827E6F73A00509BD3 /* Shapes.swift */,
|
||||
1C76E86D27C882A400ADEE1F /* SharingImageModels.swift */,
|
||||
1C718C7227F611E300A8F9FE /* StupidAssCustomWidgetObservableObject.swift */,
|
||||
1C358FAC27ADD0C3002C83A6 /* Theme.swift */,
|
||||
1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */,
|
||||
1C95ABC827E6F73A00509BD3 /* Shapes.swift */,
|
||||
1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */,
|
||||
1C718C6F27F611C900A8F9FE /* DaysFilterClass.swift */,
|
||||
1C718C7227F611E300A8F9FE /* StupidAssCustomWidgetObservableObject.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@@ -819,7 +819,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1CA037702799FFA600D26164 /* HomeViewViewModel.swift in Sources */,
|
||||
1CA037702799FFA600D26164 /* DayViewViewModel.swift in Sources */,
|
||||
1CA03773279A293D00D26164 /* OnboardingTime.swift in Sources */,
|
||||
1CAD603927A5C1C800C520BD /* HeaderPercView.swift in Sources */,
|
||||
1CAD603C27A5C1C800C520BD /* HeaderStatsView.swift in Sources */,
|
||||
@@ -827,7 +827,7 @@
|
||||
1CA0377C279B605000D26164 /* OnboardingWrapup.swift in Sources */,
|
||||
1C4FF3C327BEE07200BE8F34 /* PersistenceDELETE.swift in Sources */,
|
||||
1CA03775279A294800D26164 /* OnboardingDay.swift in Sources */,
|
||||
1CAD603727A5C1C800C520BD /* FilterView.swift in Sources */,
|
||||
1CAD603727A5C1C800C520BD /* YearView.swift in Sources */,
|
||||
1C04488D27C2ADDB00D22444 /* IconViewModel.swift in Sources */,
|
||||
1C2162F227C156E6004353D1 /* CustomizeView.swift in Sources */,
|
||||
1C683FCA2792281400745862 /* Stats.swift in Sources */,
|
||||
@@ -841,13 +841,13 @@
|
||||
1C4FF3BE27BEDF9100BE8F34 /* PersistenceHelper.swift in Sources */,
|
||||
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */,
|
||||
1C95ABC927E6F73A00509BD3 /* Shapes.swift in Sources */,
|
||||
1CAD603B27A5C1C800C520BD /* HomeView.swift in Sources */,
|
||||
1CAD603B27A5C1C800C520BD /* DayView.swift in Sources */,
|
||||
1C5F4976279C84090092F1B4 /* OnboardingData.swift in Sources */,
|
||||
1CAD603427A5C1C800C520BD /* SmallRollUpHeaderView.swift in Sources */,
|
||||
1CAD603A27A5C1C800C520BD /* BGView.swift in Sources */,
|
||||
1C26190727960DC900FDC148 /* ChartViewItemBuildable.swift in Sources */,
|
||||
1CD90B5D278C7EAD001C4FEA /* Random.swift in Sources */,
|
||||
1C2618FE27960A4F00FDC148 /* FilterViewModel.swift in Sources */,
|
||||
1C2618FE27960A4F00FDC148 /* YearViewModel.swift in Sources */,
|
||||
1C744F2C278CE15600953A57 /* AppDelegate.swift in Sources */,
|
||||
1CD90B63278C7EBA001C4FEA /* Mood.swift in Sources */,
|
||||
1C358FBE27B4D1F2002C83A6 /* CurrentStreakTemplate.swift in Sources */,
|
||||
|
||||
@@ -14,6 +14,8 @@ struct FeelsApp: App {
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
|
||||
@StateObject var daysFilter = DaysFilterClass()
|
||||
|
||||
let persistenceController = PersistenceController.shared
|
||||
|
||||
init() {
|
||||
@@ -28,6 +30,7 @@ struct FeelsApp: App {
|
||||
WindowGroup {
|
||||
MainTabView()
|
||||
.environment(\.managedObjectContext, persistenceController.viewContext)
|
||||
.environmentObject(daysFilter)
|
||||
}.onChange(of: scenePhase) { phase in
|
||||
if phase == .background {
|
||||
// BGTask.scheduleBackgroundProcessing()
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
// Created by Trey Tartt on 3/31/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
class DaysFilterClass: ObservableObject {
|
||||
@Published public private(set) var currentFilters = [Int]()
|
||||
@Published public var currentFilters = [Int]()
|
||||
|
||||
init() {
|
||||
currentFilters = UserDefaultsStore.getDaysFilter()
|
||||
let storedDays = UserDefaultsStore.getDaysFilter()
|
||||
currentFilters = storedDays
|
||||
}
|
||||
|
||||
func addFilter(newFilter: Int) {
|
||||
|
||||
@@ -48,10 +48,10 @@ extension PersistenceController {
|
||||
return data
|
||||
}
|
||||
|
||||
public func splitIntoYearMonth() -> [Int: [Int: [MoodEntry]]] {
|
||||
public func splitIntoYearMonth(includedDays: [Int]) -> [Int: [Int: [MoodEntry]]] {
|
||||
let data = PersistenceController.shared.getData(startDate: Date(timeIntervalSince1970: 0),
|
||||
endDate: Date(),
|
||||
includedDays: [1,2,3,4,5,6,7]).sorted(by: {
|
||||
includedDays: includedDays).sorted(by: {
|
||||
$0.forDate! < $1.forDate!
|
||||
})
|
||||
var returnData = [Int: [Int: [MoodEntry]]]()
|
||||
|
||||
@@ -33,7 +33,7 @@ struct CustomizeView: View {
|
||||
|
||||
@StateObject private var selectedWidget = StupidAssCustomWidgetObservableObject()
|
||||
|
||||
@StateObject private var daysFilter = DaysFilterClass()
|
||||
@EnvironmentObject var daysFilter: DaysFilterClass
|
||||
|
||||
let weekdays = [("Sun", 1),
|
||||
("mon", 2),
|
||||
|
||||
@@ -27,4 +27,12 @@ struct DayChartView: ChartViewItemBuildable, View, Hashable {
|
||||
alignment: .center)
|
||||
.opacity(color == Mood.missing.color ? 0.5 : 1.0)
|
||||
}
|
||||
|
||||
var filteredDaysView: some View {
|
||||
shape.view(withText: Text(""), bgColor: Mood.missing.color, textColor: .clear)
|
||||
.frame(minWidth: 5, idealWidth: 50, maxWidth: 50,
|
||||
minHeight: 5, idealHeight: 20, maxHeight: 50,
|
||||
alignment: .center)
|
||||
.opacity(color == Mood.missing.color ? 0.5 : 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,16 @@ import SwiftUI
|
||||
import CoreData
|
||||
import Charts
|
||||
|
||||
struct HomeViewConstants {
|
||||
struct DayViewConstants {
|
||||
static let maxHeaderHeight = 200.0
|
||||
static let minHeaderHeight = 120.0
|
||||
}
|
||||
|
||||
struct DayView: View {
|
||||
@EnvironmentObject var daysFilter: DaysFilterClass
|
||||
|
||||
@Environment(\.managedObjectContext) private var viewContext
|
||||
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@@ -47,12 +49,12 @@ struct DayView: View {
|
||||
@StateObject private var onboardingData = OnboardingDataDataManager.shared
|
||||
|
||||
// MARK: header properties
|
||||
@State private var headerHeight: CGFloat = HomeViewConstants.maxHeaderHeight
|
||||
@State private var headerHeight: CGFloat = DayViewConstants.maxHeaderHeight
|
||||
@State private var headerViewType: MainSwitchableViewType = .total
|
||||
@State private var headerOpacity: Double = 1.0
|
||||
//
|
||||
|
||||
@ObservedObject var viewModel = HomeViewViewModel(addMonthStartWeekdayPadding: false)
|
||||
@ObservedObject var viewModel: DayViewViewModel = DayViewViewModel(addMonthStartWeekdayPadding: false)
|
||||
|
||||
var body: some View {
|
||||
mainView
|
||||
@@ -62,7 +64,7 @@ struct DayView: View {
|
||||
.sheet(isPresented: $showingSheet) {
|
||||
SettingsView()
|
||||
}
|
||||
.alert(HomeViewViewModel.updateTitleHeader(forEntry: selectedEntry),
|
||||
.alert(DayViewViewModel.updateTitleHeader(forEntry: selectedEntry),
|
||||
isPresented: $showUpdateEntryAlert) {
|
||||
ForEach(Mood.allValues) { mood in
|
||||
Button(mood.strValue, action: {
|
||||
@@ -92,7 +94,7 @@ struct DayView: View {
|
||||
|
||||
// MARK: functions that do view type work
|
||||
func calcuateViewAlpha() {
|
||||
let perc = (((Double(headerHeight) - HomeViewConstants.minHeaderHeight) * 100) / (HomeViewConstants.maxHeaderHeight - HomeViewConstants.minHeaderHeight)) / 100
|
||||
let perc = (((Double(headerHeight) - DayViewConstants.minHeaderHeight) * 100) / (DayViewConstants.maxHeaderHeight - DayViewConstants.minHeaderHeight)) / 100
|
||||
headerOpacity = perc
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@ struct DayView: View {
|
||||
VStack {
|
||||
SmallRollUpHeaderView(entries: getBackEntries(),
|
||||
viewType: $currentSelectedHeaderViewViewType)
|
||||
.frame(height: HomeViewConstants.minHeaderHeight)
|
||||
.frame(height: DayViewConstants.minHeaderHeight)
|
||||
.padding([.trailing, .leading])
|
||||
.background(
|
||||
theme.currentTheme.secondaryBGColor
|
||||
@@ -263,8 +265,8 @@ struct DayView: View {
|
||||
.coordinateSpace(name: "scroll")
|
||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
||||
if viewModel.numberOfItems > 10 {
|
||||
calculateHeight(minHeight: HomeViewConstants.minHeaderHeight,
|
||||
maxHeight: HomeViewConstants.maxHeaderHeight,
|
||||
calculateHeight(minHeight: DayViewConstants.minHeaderHeight,
|
||||
maxHeight: DayViewConstants.maxHeaderHeight,
|
||||
yOffset: value)
|
||||
}
|
||||
}
|
||||
@@ -298,12 +300,14 @@ extension DayView {
|
||||
ForEach(entries.sorted(by: {
|
||||
return $0.forDate! > $1.forDate!
|
||||
}), id: \.self) { entry in
|
||||
EntryListView(entry: entry)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: {
|
||||
selectedEntry = entry
|
||||
showUpdateEntryAlert = true
|
||||
})
|
||||
if daysFilter.currentFilters.contains(Int(entry.weekDay)) {
|
||||
EntryListView(entry: entry)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: {
|
||||
selectedEntry = entry
|
||||
showUpdateEntryAlert = true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,12 +330,12 @@ private let itemFormatter: DateFormatter = {
|
||||
|
||||
struct DayView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
DayView().environment(\.managedObjectContext, PersistenceController.shared.viewContext)
|
||||
DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false)).environment(\.managedObjectContext, PersistenceController.shared.viewContext)
|
||||
.onAppear(perform: {
|
||||
PersistenceController.shared.populateMemory()
|
||||
})
|
||||
|
||||
DayView()
|
||||
DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false))
|
||||
.preferredColorScheme(.dark)
|
||||
.environment(\.managedObjectContext, PersistenceController.shared.viewContext)
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
import SwiftUI
|
||||
import CoreData
|
||||
|
||||
class HomeViewViewModel: ObservableObject {
|
||||
class DayViewViewModel: ObservableObject {
|
||||
@Published var grouped = [Int: [Int: [MoodEntry]]]()
|
||||
@Published var numberOfItems = 0
|
||||
|
||||
@@ -52,7 +52,7 @@ class HomeViewViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
private func getGroupedData(addMonthStartWeekdayPadding: Bool) {
|
||||
var newStuff = PersistenceController.shared.splitIntoYearMonth()
|
||||
var newStuff = PersistenceController.shared.splitIntoYearMonth(includedDays: [1,2,3,4,5,6,7])
|
||||
if addMonthStartWeekdayPadding {
|
||||
newStuff = MoodEntryFunctions.padMoodEntriesForCalendar(entries: newStuff)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ struct EmptyHomeView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
||||
|
||||
let viewModel: HomeViewViewModel
|
||||
let viewModel: DayViewViewModel
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
@@ -32,6 +32,6 @@ struct EmptyHomeView: View {
|
||||
|
||||
struct EmptyHomeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
EmptyHomeView(viewModel: HomeViewViewModel(addMonthStartWeekdayPadding: false))
|
||||
EmptyHomeView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MainTabView: View {
|
||||
@EnvironmentObject var daysFilter: DaysFilterClass
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@@ -23,7 +25,7 @@ struct MainTabView: View {
|
||||
Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
|
||||
}
|
||||
|
||||
MonthView()
|
||||
MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true))
|
||||
.tabItem {
|
||||
Label(String(localized: "content_view_tab_month"), systemImage: "calendar")
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ struct MonthDetailView: View {
|
||||
let monthInt: Int
|
||||
let yearInt: Int
|
||||
@State var entries: [MoodEntry]
|
||||
var parentViewModel: HomeViewViewModel
|
||||
var parentViewModel: DayViewViewModel
|
||||
|
||||
let columns = [
|
||||
GridItem(.flexible(minimum: 5, maximum: 500)),
|
||||
@@ -86,7 +86,7 @@ struct MonthDetailView: View {
|
||||
ShareSheet(photo: uiImage)
|
||||
}
|
||||
}
|
||||
.alert(HomeViewViewModel.updateTitleHeader(forEntry: selectedEntry), isPresented: $showUpdateEntryAlert) {
|
||||
.alert(DayViewViewModel.updateTitleHeader(forEntry: selectedEntry), isPresented: $showUpdateEntryAlert) {
|
||||
ForEach(Mood.allValues) { mood in
|
||||
Button(mood.strValue, action: {
|
||||
if let selectedEntry = selectedEntry {
|
||||
@@ -225,6 +225,6 @@ struct MonthDetailView_Previews: PreviewProvider {
|
||||
MonthDetailView(monthInt: 5, yearInt: 2022, entries:
|
||||
PersistenceController.shared.randomEntries(count: 30).sorted(by: {
|
||||
$0.forDate! < $1.forDate!
|
||||
}), parentViewModel: HomeViewViewModel(addMonthStartWeekdayPadding: true))
|
||||
}), parentViewModel: DayViewViewModel(addMonthStartWeekdayPadding: true))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MonthView: View {
|
||||
@EnvironmentObject var daysFilter: DaysFilterClass
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@@ -22,7 +24,6 @@ struct MonthView: View {
|
||||
// store a value that gets changed when user updates custom colors to update the view since the moodTint doesn't change
|
||||
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
|
||||
|
||||
@ObservedObject var viewModel = HomeViewViewModel(addMonthStartWeekdayPadding: true)
|
||||
|
||||
@StateObject private var selectedDetail = StupidAssDetailViewObservableObject()
|
||||
@State private var showingSheet = false
|
||||
@@ -43,6 +44,8 @@ struct MonthView: View {
|
||||
GridItem(.flexible(minimum: 5, maximum: 400))
|
||||
]
|
||||
|
||||
@ObservedObject var viewModel: DayViewViewModel
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if viewModel.hasNoData {
|
||||
@@ -201,10 +204,17 @@ extension MonthView {
|
||||
Divider()
|
||||
LazyVGrid(columns: columns, spacing: 15) {
|
||||
ForEach(entries, id: \.self) { entry in
|
||||
shape.view(withText: Text(""),
|
||||
bgColor: entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood),
|
||||
textColor: .clear)
|
||||
.frame(minHeight: 25, idealHeight: 25, maxHeight: 50, alignment: .center)
|
||||
if daysFilter.currentFilters.contains(Int(entry.weekDay)) {
|
||||
shape.view(withText: Text(""),
|
||||
bgColor: entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood),
|
||||
textColor: .clear)
|
||||
.frame(minHeight: 25, idealHeight: 25, maxHeight: 50, alignment: .center)
|
||||
} else {
|
||||
shape.view(withText: Text(""),
|
||||
bgColor: .clear,
|
||||
textColor: .clear)
|
||||
.frame(minHeight: 25, idealHeight: 25, maxHeight: 50, alignment: .center)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,6 +233,6 @@ extension MonthView {
|
||||
|
||||
struct HomeViewTwo_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MonthView()
|
||||
MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import SwiftUI
|
||||
import CoreData
|
||||
|
||||
struct YearView: View {
|
||||
@EnvironmentObject var daysFilter: DaysFilterClass
|
||||
|
||||
let months = [(0, "J"), (1, "F"), (2,"M"), (3,"A"), (4,"M"), (5, "J"), (6,"J"), (7,"A"), (8,"S"), (9,"O"), (10, "N"), (11,"D")]
|
||||
|
||||
@State private var toggle = true
|
||||
@@ -22,7 +24,7 @@ struct YearView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
||||
|
||||
@StateObject private var viewModel = FilterViewModel()
|
||||
@StateObject private var viewModel = YearViewModel()
|
||||
//[
|
||||
// 2001: [0: [], 1: [], 2: []],
|
||||
// 2002: [0: [], 1: [], 2: []]
|
||||
@@ -159,12 +161,18 @@ struct YearView: View {
|
||||
}
|
||||
|
||||
private struct monthGridView: View {
|
||||
@EnvironmentObject var daysFilter: DaysFilterClass
|
||||
|
||||
let monthData: [DayChartView]
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ForEach(monthData, id: \.self) { view in
|
||||
view
|
||||
if daysFilter.currentFilters.contains(view.weekDay) {
|
||||
view
|
||||
} else {
|
||||
view.filteredDaysView
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class FilterViewModel: ObservableObject {
|
||||
class YearViewModel: ObservableObject {
|
||||
@Published public var entryStartDate: Date = Date()
|
||||
@Published public var entryEndDate: Date = Date()
|
||||
@Published var selectedDays = [Int]()
|
||||
Reference in New Issue
Block a user