closed #38
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
1C412082278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
|
1C412082278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
|
||||||
1C412083278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
|
1C412083278F2B8800D9153A /* FilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C412081278F2B8800D9153A /* FilterView.swift */; };
|
||||||
1C5F4976279C84090092F1B4 /* OnboardingData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C5F4975279C84090092F1B4 /* OnboardingData.swift */; };
|
1C5F4976279C84090092F1B4 /* OnboardingData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C5F4975279C84090092F1B4 /* OnboardingData.swift */; };
|
||||||
|
1C5F4978279C945E0092F1B4 /* UserDefaultsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */; };
|
||||||
1C683FCA2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
1C683FCA2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
||||||
1C683FCB2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
1C683FCB2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
||||||
1C683FCC2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
1C683FCC2792281400745862 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C683FC92792281400745862 /* Stats.swift */; };
|
||||||
@@ -116,6 +117,7 @@
|
|||||||
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>"; };
|
||||||
1C412081278F2B8800D9153A /* FilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterView.swift; sourceTree = "<group>"; };
|
1C412081278F2B8800D9153A /* FilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterView.swift; sourceTree = "<group>"; };
|
||||||
1C5F4975279C84090092F1B4 /* OnboardingData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingData.swift; sourceTree = "<group>"; };
|
1C5F4975279C84090092F1B4 /* OnboardingData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingData.swift; sourceTree = "<group>"; };
|
||||||
|
1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsStore.swift; sourceTree = "<group>"; };
|
||||||
1C683FC92792281400745862 /* Stats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stats.swift; sourceTree = "<group>"; };
|
1C683FC92792281400745862 /* Stats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stats.swift; sourceTree = "<group>"; };
|
||||||
1C6B37792799B78A001EF820 /* BGView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGView.swift; sourceTree = "<group>"; };
|
1C6B37792799B78A001EF820 /* BGView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGView.swift; sourceTree = "<group>"; };
|
||||||
1C744F2B278CE15600953A57 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
1C744F2B278CE15600953A57 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
@@ -220,6 +222,7 @@
|
|||||||
1CA03771279A291F00D26164 /* Onboarding */ = {
|
1CA03771279A291F00D26164 /* Onboarding */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
1C5F4975279C84090092F1B4 /* OnboardingData.swift */,
|
||||||
1CA03778279A295F00D26164 /* views */,
|
1CA03778279A295F00D26164 /* views */,
|
||||||
);
|
);
|
||||||
path = Onboarding;
|
path = Onboarding;
|
||||||
@@ -351,12 +354,12 @@
|
|||||||
1CD90B60278C7EBA001C4FEA /* Models */ = {
|
1CD90B60278C7EBA001C4FEA /* Models */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */,
|
||||||
1CA0376F2799FFA600D26164 /* ContentModeViewModel.swift */,
|
1CA0376F2799FFA600D26164 /* ContentModeViewModel.swift */,
|
||||||
1CC469AB27907D48003E0C6E /* DayChartView.swift */,
|
1CC469AB27907D48003E0C6E /* DayChartView.swift */,
|
||||||
1CD90B61278C7EBA001C4FEA /* Mood.swift */,
|
1CD90B61278C7EBA001C4FEA /* Mood.swift */,
|
||||||
1CD90B62278C7EBA001C4FEA /* MoodEntryExtension.swift */,
|
1CD90B62278C7EBA001C4FEA /* MoodEntryExtension.swift */,
|
||||||
1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */,
|
1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */,
|
||||||
1C5F4975279C84090092F1B4 /* OnboardingData.swift */,
|
|
||||||
);
|
);
|
||||||
path = Models;
|
path = Models;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -582,6 +585,7 @@
|
|||||||
1CD90B66278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
1CD90B66278C7EBA001C4FEA /* MoodEntryExtension.swift in Sources */,
|
||||||
1CD90B1C278C7DE0001C4FEA /* Persistence.swift in Sources */,
|
1CD90B1C278C7DE0001C4FEA /* Persistence.swift in Sources */,
|
||||||
1CA0377A279A296E00D26164 /* OnboardingMain.swift in Sources */,
|
1CA0377A279A296E00D26164 /* OnboardingMain.swift in Sources */,
|
||||||
|
1C5F4978279C945E0092F1B4 /* UserDefaultsStore.swift in Sources */,
|
||||||
1C412082278F2B8800D9153A /* FilterView.swift in Sources */,
|
1C412082278F2B8800D9153A /* FilterView.swift in Sources */,
|
||||||
1CD90B18278C7DE0001C4FEA /* FeelsApp.swift in Sources */,
|
1CD90B18278C7DE0001C4FEA /* FeelsApp.swift in Sources */,
|
||||||
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */,
|
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */,
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ import Foundation
|
|||||||
import UserNotifications
|
import UserNotifications
|
||||||
import UIKit
|
import UIKit
|
||||||
import WidgetKit
|
import WidgetKit
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
// AppDelegate.swift
|
// AppDelegate.swift
|
||||||
class AppDelegate: NSObject, UIApplicationDelegate {
|
class AppDelegate: NSObject, UIApplicationDelegate {
|
||||||
|
@AppStorage("savedOnboardingData") private var savedOnboardingData = OnboardingData()
|
||||||
|
|
||||||
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
||||||
// PersistenceController.shared.clearDB()
|
// PersistenceController.shared.clearDB()
|
||||||
application.registerForRemoteNotifications()
|
application.registerForRemoteNotifications()
|
||||||
@@ -29,17 +32,27 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
|
|||||||
|
|
||||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||||
if let action = LocalNotification.ActionType(rawValue: response.actionIdentifier) {
|
if let action = LocalNotification.ActionType(rawValue: response.actionIdentifier) {
|
||||||
|
var date: Date
|
||||||
|
|
||||||
|
switch savedOnboardingData.inputDay {
|
||||||
|
case .Today:
|
||||||
|
date = Date()
|
||||||
|
case .Previous:
|
||||||
|
date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case .horrible:
|
case .horrible:
|
||||||
PersistenceController.shared.add(mood: .horrible, forDate: Date())
|
PersistenceController.shared.add(mood: .horrible, forDate: date)
|
||||||
case .bad:
|
case .bad:
|
||||||
PersistenceController.shared.add(mood: .bad, forDate: Date())
|
PersistenceController.shared.add(mood: .bad, forDate: date)
|
||||||
case .average:
|
case .average:
|
||||||
PersistenceController.shared.add(mood: .average, forDate: Date())
|
PersistenceController.shared.add(mood: .average, forDate: date)
|
||||||
case .good:
|
case .good:
|
||||||
PersistenceController.shared.add(mood: .good, forDate: Date())
|
PersistenceController.shared.add(mood: .good, forDate: date)
|
||||||
case .great:
|
case .great:
|
||||||
PersistenceController.shared.add(mood: .great, forDate: Date())
|
PersistenceController.shared.add(mood: .great, forDate: date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WidgetCenter.shared.reloadAllTimelines()
|
WidgetCenter.shared.reloadAllTimelines()
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import CoreData
|
|||||||
|
|
||||||
class ContentModeViewModel: ObservableObject {
|
class ContentModeViewModel: ObservableObject {
|
||||||
@Published var grouped = [Int: [Int: [MoodEntry]]]()
|
@Published var grouped = [Int: [Int: [MoodEntry]]]()
|
||||||
|
@Published public private(set) var savedOnboardingData = UserDefaultsStore.getOnboarding()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
updateData()
|
updateData()
|
||||||
}
|
}
|
||||||
@@ -19,18 +20,30 @@ class ContentModeViewModel: ObservableObject {
|
|||||||
grouped = PersistenceController.shared.splitIntoYearMonth()
|
grouped = PersistenceController.shared.splitIntoYearMonth()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func shouldShowTodayInput() -> Bool {
|
public func shouldShowVotingHeader() -> Bool {
|
||||||
|
isMissingCurrentVote() && savedOnboardingData.ableToVoteBasedOnCurentTime() ? true : false
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateOnboardingData(onboardingData: OnboardingData) {
|
||||||
|
self.savedOnboardingData = UserDefaultsStore.saveOnboarding(onboardingData: onboardingData)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func isMissingCurrentVote() -> Bool {
|
||||||
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
||||||
|
|
||||||
var calendar = Calendar.current
|
var calendar = Calendar.current
|
||||||
calendar.timeZone = NSTimeZone.local
|
calendar.timeZone = NSTimeZone.local
|
||||||
|
|
||||||
// Get today's beginning & end
|
var dateFrom: Date
|
||||||
let dateFrom = calendar.startOfDay(for: Date()) // eg. 2016-10-10 00:00:00
|
switch savedOnboardingData.inputDay {
|
||||||
|
case .Today:
|
||||||
|
dateFrom = calendar.startOfDay(for: Date())
|
||||||
|
case .Previous:
|
||||||
|
dateFrom = calendar.startOfDay(for: Date())
|
||||||
|
dateFrom = calendar.date(byAdding: .day, value: -1, to: dateFrom)!
|
||||||
|
}
|
||||||
let dateTo = calendar.date(byAdding: .day, value: 1, to: dateFrom)!
|
let dateTo = calendar.date(byAdding: .day, value: 1, to: dateFrom)!
|
||||||
// Note: Times are printed in UTC. Depending on where you live it won't print 00:00:00 but it will work with UTC times which can be converted to local time
|
|
||||||
|
|
||||||
// Set predicate as date being today's date
|
|
||||||
let fromPredicate = NSPredicate(format: "%@ <= %K", dateFrom as NSDate, #keyPath(MoodEntry.forDate))
|
let fromPredicate = NSPredicate(format: "%@ <= %K", dateFrom as NSDate, #keyPath(MoodEntry.forDate))
|
||||||
let toPredicate = NSPredicate(format: "%K < %@", #keyPath(MoodEntry.forDate), dateTo as NSDate)
|
let toPredicate = NSPredicate(format: "%K < %@", #keyPath(MoodEntry.forDate), dateTo as NSDate)
|
||||||
let datePredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [fromPredicate, toPredicate])
|
let datePredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [fromPredicate, toPredicate])
|
||||||
@@ -45,7 +58,7 @@ class ContentModeViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func add(mood: Mood, forDate date: Date) {
|
public func add(mood: Mood, forDate date: Date) {
|
||||||
PersistenceController.shared.add(mood: mood, forDate: Date())
|
PersistenceController.shared.add(mood: mood, forDate: date)
|
||||||
getGroupedData()
|
getGroupedData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
Shared/Models/UserDefaultsStore.swift
Normal file
29
Shared/Models/UserDefaultsStore.swift
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// UserDefaultsStore.swift
|
||||||
|
// Feels (iOS)
|
||||||
|
//
|
||||||
|
// Created by Trey Tartt on 1/22/22.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class UserDefaultsStore {
|
||||||
|
static func getOnboarding() -> OnboardingData {
|
||||||
|
if let data = UserDefaults.standard.object(forKey: "savedOnboardingData") as? Data,
|
||||||
|
let model = try? JSONDecoder().decode(OnboardingData.self, from: data) {
|
||||||
|
return model
|
||||||
|
} else {
|
||||||
|
return OnboardingData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func saveOnboarding(onboardingData: OnboardingData) -> OnboardingData {
|
||||||
|
do {
|
||||||
|
let data = try JSONEncoder().encode(onboardingData)
|
||||||
|
UserDefaults.standard.set(data, forKey: "savedOnboardingData")
|
||||||
|
return UserDefaultsStore.getOnboarding()
|
||||||
|
} catch {
|
||||||
|
fatalError("error saving")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ struct OnboardingMain: View {
|
|||||||
@Environment(\.presentationMode) var presentationMode
|
@Environment(\.presentationMode) var presentationMode
|
||||||
@State var onboardingData: OnboardingData
|
@State var onboardingData: OnboardingData
|
||||||
|
|
||||||
let completionClosure: ((OnboardingData) -> Void)
|
let updateBoardingDataClosure: ((OnboardingData) -> Void)
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
TabView {
|
TabView {
|
||||||
@@ -22,7 +22,7 @@ struct OnboardingMain: View {
|
|||||||
OnboardingTitle(onboardingData: onboardingData)
|
OnboardingTitle(onboardingData: onboardingData)
|
||||||
|
|
||||||
OnboardingWrapup(onboardingData: onboardingData, completionClosure: { _ in
|
OnboardingWrapup(onboardingData: onboardingData, completionClosure: { _ in
|
||||||
completionClosure(onboardingData)
|
updateBoardingDataClosure(onboardingData)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
@@ -42,7 +42,7 @@ struct OnboardingMain: View {
|
|||||||
struct OnboardingMain_Previews: PreviewProvider {
|
struct OnboardingMain_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
OnboardingMain(onboardingData: OnboardingData(),
|
OnboardingMain(onboardingData: OnboardingData(),
|
||||||
completionClosure: { _ in
|
updateBoardingDataClosure: { _ in
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import SwiftUI
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
struct AddMoodHeaderView: View {
|
struct AddMoodHeaderView: View {
|
||||||
@Environment(\.managedObjectContext) private var viewContext
|
private let savedOnboardingData = UserDefaultsStore.getOnboarding()
|
||||||
let addItemClosure: ((Mood, Date) -> Void)
|
|
||||||
|
let addItemHeaderClosure: ((Mood, Date) -> Void)
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
@@ -49,26 +50,32 @@ struct AddMoodHeaderView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func addItem(withMood mood: Mood) {
|
private func addItem(withMood mood: Mood) {
|
||||||
addItemClosure(mood, Date())
|
switch savedOnboardingData.inputDay {
|
||||||
|
case .Today:
|
||||||
|
addItemHeaderClosure(mood, Date())
|
||||||
|
case .Previous:
|
||||||
|
let date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||||
|
addItemHeaderClosure(mood, date)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AddMoodHeaderView_Previews: PreviewProvider {
|
struct AddMoodHeaderView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
AddMoodHeaderView(addItemClosure: { (_,_) in
|
AddMoodHeaderView(addItemHeaderClosure: { (_,_) in
|
||||||
|
|
||||||
}).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
}).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
||||||
|
|
||||||
AddMoodHeaderView(addItemClosure: { (_,_) in
|
AddMoodHeaderView(addItemHeaderClosure: { (_,_) in
|
||||||
|
|
||||||
}).preferredColorScheme(.dark).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
}).preferredColorScheme(.dark).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
||||||
|
|
||||||
AddMoodHeaderView(addItemClosure: { (_,_) in
|
AddMoodHeaderView(addItemHeaderClosure: { (_,_) in
|
||||||
|
|
||||||
}).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
}).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
||||||
|
|
||||||
AddMoodHeaderView(addItemClosure: { (_,_) in
|
AddMoodHeaderView(addItemHeaderClosure: { (_,_) in
|
||||||
|
|
||||||
}).preferredColorScheme(.dark).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
}).preferredColorScheme(.dark).environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ struct ContentView: View {
|
|||||||
|
|
||||||
@ObservedObject var viewModel = ContentModeViewModel()
|
@ObservedObject var viewModel = ContentModeViewModel()
|
||||||
|
|
||||||
@AppStorage("savedOnboardingData") private var savedOnboardingData = OnboardingData()
|
|
||||||
|
|
||||||
init(){
|
init(){
|
||||||
UITabBar.appearance().backgroundColor = UIColor.systemBackground
|
UITabBar.appearance().backgroundColor = UIColor.systemBackground
|
||||||
}
|
}
|
||||||
@@ -43,10 +41,10 @@ struct ContentView: View {
|
|||||||
}.sheet(isPresented: $needsOnboarding, onDismiss: {
|
}.sheet(isPresented: $needsOnboarding, onDismiss: {
|
||||||
|
|
||||||
}, content: {
|
}, content: {
|
||||||
OnboardingMain(onboardingData: savedOnboardingData,
|
OnboardingMain(onboardingData: viewModel.savedOnboardingData,
|
||||||
completionClosure: { onboardingData in
|
updateBoardingDataClosure: { onboardingData in
|
||||||
needsOnboarding = false
|
needsOnboarding = false
|
||||||
savedOnboardingData = onboardingData
|
viewModel.updateOnboardingData(onboardingData: onboardingData)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -65,6 +63,8 @@ struct ContentView: View {
|
|||||||
withAnimation{
|
withAnimation{
|
||||||
viewModel.updateData()
|
viewModel.updateData()
|
||||||
}
|
}
|
||||||
|
}, updateBoardingDataClosure: { onboardingData in
|
||||||
|
viewModel.updateOnboardingData(onboardingData: onboardingData)
|
||||||
})
|
})
|
||||||
}.padding(.trailing)
|
}.padding(.trailing)
|
||||||
}
|
}
|
||||||
@@ -170,8 +170,8 @@ struct ContentView: View {
|
|||||||
BGView()
|
BGView()
|
||||||
VStack{
|
VStack{
|
||||||
settingsButtonView
|
settingsButtonView
|
||||||
if viewModel.shouldShowTodayInput() && savedOnboardingData.ableToVoteBasedOnCurentTime() {
|
if viewModel.shouldShowVotingHeader() {
|
||||||
AddMoodHeaderView(addItemClosure: { (mood, date) in
|
AddMoodHeaderView(addItemHeaderClosure: { (mood, date) in
|
||||||
withAnimation {
|
withAnimation {
|
||||||
viewModel.add(mood: mood, forDate: date)
|
viewModel.add(mood: mood, forDate: date)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ struct SettingsView: View {
|
|||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
let editedDataClosure: (() -> Void)
|
let editedDataClosure: (() -> Void)
|
||||||
|
let updateBoardingDataClosure: ((OnboardingData) -> Void)
|
||||||
|
|
||||||
@State private var showOnboarding = false
|
@State private var showOnboarding = false
|
||||||
|
|
||||||
@AppStorage("savedOnboardingData") private var savedOnboardingData = OnboardingData()
|
|
||||||
@AppStorage("showReminder") private var showReminder: Bool = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(UIColor.secondarySystemBackground)
|
Color(UIColor.secondarySystemBackground)
|
||||||
@@ -33,10 +32,10 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}.sheet(isPresented: $showOnboarding) {
|
}.sheet(isPresented: $showOnboarding) {
|
||||||
OnboardingMain(onboardingData: savedOnboardingData,
|
OnboardingMain(onboardingData: UserDefaultsStore.getOnboarding(),
|
||||||
completionClosure: { onboardingData in
|
updateBoardingDataClosure: { onboardingData in
|
||||||
|
updateBoardingDataClosure(onboardingData)
|
||||||
showOnboarding = false
|
showOnboarding = false
|
||||||
savedOnboardingData = onboardingData
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,10 +176,14 @@ struct SettingsView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
SettingsView(editedDataClosure: {
|
SettingsView(editedDataClosure: {
|
||||||
|
|
||||||
|
}, updateBoardingDataClosure: { _ in
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
SettingsView(editedDataClosure: {
|
SettingsView(editedDataClosure: {
|
||||||
|
|
||||||
|
}, updateBoardingDataClosure: { _ in
|
||||||
|
|
||||||
})
|
})
|
||||||
.preferredColorScheme(.dark)
|
.preferredColorScheme(.dark)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user