closed #60
This commit is contained in:
Trey t
2022-02-04 16:49:56 -06:00
parent b3785fac2c
commit a1f70edec2
10 changed files with 150 additions and 29 deletions

View File

@@ -16,6 +16,7 @@
1C2618FE27960A4F00FDC148 /* FilterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */; }; 1C2618FE27960A4F00FDC148 /* FilterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */; };
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 */; };
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 */; }; 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 */; };
@@ -120,6 +121,7 @@
1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterViewModel.swift; sourceTree = "<group>"; }; 1C2618FD27960A4F00FDC148 /* FilterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterViewModel.swift; sourceTree = "<group>"; };
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>"; };
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>"; }; 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>"; };
@@ -262,6 +264,7 @@
1CAD602C27A5C1C800C520BD /* SettingsView.swift */, 1CAD602C27A5C1C800C520BD /* SettingsView.swift */,
1CAD602B27A5C1C800C520BD /* SmallRollUpHeaderView.swift */, 1CAD602B27A5C1C800C520BD /* SmallRollUpHeaderView.swift */,
1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */, 1CAD603D27A6ECCD00C520BD /* SwitchableView.swift */,
1C358FAC27ADD0C3002C83A6 /* Theme.swift */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -609,6 +612,7 @@
1C5F4978279C945E0092F1B4 /* UserDefaultsStore.swift in Sources */, 1C5F4978279C945E0092F1B4 /* UserDefaultsStore.swift in Sources */,
1CD90B18278C7DE0001C4FEA /* FeelsApp.swift in Sources */, 1CD90B18278C7DE0001C4FEA /* FeelsApp.swift in Sources */,
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */, 1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */,
1C358FAD27ADD0C3002C83A6 /* Theme.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@@ -46,7 +46,7 @@ enum Mood: Int {
case .great: case .great:
return .green return .green
case .missing: case .missing:
return Color(uiColor: UIColor.tertiarySystemBackground) return Color(uiColor: UIColor.systemGray2)
} }
} }

View File

@@ -14,6 +14,7 @@ class UserDefaultsStore {
case useCloudKit case useCloudKit
case deleteEnable case deleteEnable
case mainViewTopHeaderIndex case mainViewTopHeaderIndex
case theme
} }
static func getOnboarding() -> OnboardingData { static func getOnboarding() -> OnboardingData {

View File

@@ -12,6 +12,7 @@ import CoreData
struct AddMoodHeaderView: View { struct AddMoodHeaderView: View {
private let savedOnboardingData = UserDefaultsStore.getOnboarding() private let savedOnboardingData = UserDefaultsStore.getOnboarding()
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let addItemHeaderClosure: ((Mood, Date) -> Void) let addItemHeaderClosure: ((Mood, Date) -> Void)
@@ -19,7 +20,7 @@ struct AddMoodHeaderView: View {
var body: some View { var body: some View {
ZStack { ZStack {
Color(UIColor.systemBackground) Color(theme.secondaryBGColor)
VStack { VStack {
Text(self.getTitle()) Text(self.getTitle())
@@ -45,6 +46,9 @@ struct AddMoodHeaderView: View {
} }
.padding([.leading, .trailing, .bottom]) .padding([.leading, .trailing, .bottom])
} }
.background(
Color(theme.secondaryBGColor)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.frame(minHeight: 88, maxHeight: 150) .frame(minHeight: 88, maxHeight: 150)
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)

View File

@@ -19,6 +19,7 @@ struct ContentView: View {
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true @AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
@AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true @AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true
@AppStorage(UserDefaultsStore.Keys.mainViewTopHeaderIndex.rawValue, store: GroupUserDefaults.groupDefaults) private var mainViewTopHeaderIndex = 0 @AppStorage(UserDefaultsStore.Keys.mainViewTopHeaderIndex.rawValue, store: GroupUserDefaults.groupDefaults) private var mainViewTopHeaderIndex = 0
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@State private var showingSheet = false @State private var showingSheet = false
@State private var showTodayInput = true @State private var showTodayInput = true
@@ -33,7 +34,8 @@ struct ContentView: View {
@ObservedObject var viewModel = ContentModeViewModel() @ObservedObject var viewModel = ContentModeViewModel()
init(){ init(){
UITabBar.appearance().backgroundColor = UIColor.systemBackground UITabBar.appearance().backgroundColor = theme.secondaryBGColor
print(theme)
} }
var body: some View { var body: some View {
@@ -180,7 +182,7 @@ struct ContentView: View {
) )
} }
.background( .background(
Color(UIColor.systemBackground) Color(theme.secondaryBGColor)
) )
.coordinateSpace(name: "scroll") .coordinateSpace(name: "scroll")
.onPreferenceChange(ViewOffsetKey.self) { value in .onPreferenceChange(ViewOffsetKey.self) { value in
@@ -200,7 +202,7 @@ struct ContentView: View {
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.padding() .padding()
.background( .background(
Color(UIColor.systemBackground) Color(theme.secondaryBGColor)
) )
} }
@@ -285,7 +287,7 @@ struct ContentView: View {
private var emptyView: some View { private var emptyView: some View {
ZStack { ZStack {
Color(UIColor.systemBackground) Color(theme.secondaryBGColor)
VStack { VStack {
Text(String(localized: "content_view_empty_title")) Text(String(localized: "content_view_empty_title"))
@@ -327,7 +329,7 @@ struct ContentView: View {
VStack { VStack {
SmallRollUpHeaderView(fakeData: false, backDays: 30) SmallRollUpHeaderView(fakeData: false, backDays: 30)
.background( .background(
Color(UIColor.systemBackground) Color(theme.secondaryBGColor)
) )
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.padding() .padding()
@@ -342,7 +344,8 @@ struct ContentView: View {
.padding([.leading, .trailing, .bottom]) .padding([.leading, .trailing, .bottom])
} }
}.background( }.background(
BGView().equatable() theme.bg
.edgesIgnoringSafeArea(.all)
) )
} }
} }

View File

@@ -13,7 +13,6 @@ struct FilterView: View {
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")] 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 @State private var toggle = true
@State private var showFilter = false @State private var showFilter = false
@FetchRequest( @FetchRequest(
@@ -21,6 +20,8 @@ struct FilterView: View {
animation: .spring()) animation: .spring())
private var items: FetchedResults<MoodEntry> private var items: FetchedResults<MoodEntry>
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@StateObject private var viewModel = FilterViewModel() @StateObject private var viewModel = FilterViewModel()
//[ //[
// 2001: [0: [], 1: [], 2: []], // 2001: [0: [], 1: [], 2: []],
@@ -63,6 +64,10 @@ struct FilterView: View {
self.viewModel.filterEntries(startDate: Date(timeIntervalSince1970: 0), endDate: Date()) self.viewModel.filterEntries(startDate: Date(timeIntervalSince1970: 0), endDate: Date())
}) })
} }
.background(
theme.bg
.edgesIgnoringSafeArea(.all)
)
} }
private var filterButon: some View { private var filterButon: some View {
@@ -75,7 +80,7 @@ struct FilterView: View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.frame(height: 44) .frame(height: 44)
.foregroundColor(Color(UIColor.label)) .foregroundColor(Color(UIColor.label))
.background(Color(UIColor.secondarySystemBackground)) .background(Color(theme.secondaryBGColor))
.cornerRadius(25) .cornerRadius(25)
}).frame(maxWidth: .infinity) }).frame(maxWidth: .infinity)
} }
@@ -97,7 +102,7 @@ struct FilterView: View {
private var statsView: some View { private var statsView: some View {
ZStack { ZStack {
Color(UIColor.secondarySystemBackground) Color(theme.secondaryBGColor)
HStack { HStack {
Spacer() Spacer()
@@ -115,7 +120,7 @@ struct FilterView: View {
VStack { VStack {
VStack { VStack {
ZStack { ZStack {
Color(UIColor.secondarySystemBackground) Color(theme.secondaryBGColor)
DatePicker( DatePicker(
String(localized: "filter_view_begin_date"), String(localized: "filter_view_begin_date"),
selection: $viewModel.entryStartDate, selection: $viewModel.entryStartDate,
@@ -130,7 +135,7 @@ struct FilterView: View {
.padding([.leading, .trailing]) .padding([.leading, .trailing])
ZStack { ZStack {
Color(UIColor.secondarySystemBackground) Color(theme.secondaryBGColor)
DatePicker( DatePicker(
String(localized: "filter_view_end_date"), String(localized: "filter_view_end_date"),
selection: $viewModel.entryEndDate, selection: $viewModel.entryEndDate,
@@ -145,7 +150,7 @@ struct FilterView: View {
.padding([.leading, .trailing]) .padding([.leading, .trailing])
ZStack { ZStack {
Color(UIColor.secondarySystemBackground) Color(theme.secondaryBGColor)
HStack { HStack {
Spacer() Spacer()
ForEach(weekdays.indices, id: \.self) { dayIdx in ForEach(weekdays.indices, id: \.self) { dayIdx in
@@ -198,6 +203,10 @@ struct FilterView: View {
Text(String(yearKey)) Text(String(yearKey))
.font(.title) .font(.title)
yearGridView(yearData: yearData, columns: columns) yearGridView(yearData: yearData, columns: columns)
.background(
Color(theme.secondaryBGColor)
)
.cornerRadius(25)
} }
} }
.simultaneousGesture(DragGesture().onChanged({ _ in .simultaneousGesture(DragGesture().onChanged({ _ in
@@ -215,20 +224,16 @@ struct FilterView: View {
let columns: [GridItem] let columns: [GridItem]
var body: some View { var body: some View {
ZStack { VStack {
Color(UIColor.secondarySystemBackground) LazyVGrid(columns: columns, spacing: 0) {
ForEach(Array(yearData.keys.sorted(by: <)), id: \.self) { monthKey in
VStack { let monthData = yearData[monthKey]!
LazyVGrid(columns: columns, spacing: 0) { VStack {
ForEach(Array(yearData.keys.sorted(by: <)), id: \.self) { monthKey in monthGridView(monthData: monthData)
let monthData = yearData[monthKey]!
VStack {
monthGridView(monthData: monthData)
}
} }
} }
.padding([.leading, .trailing, .top, .bottom])
} }
.padding([.leading, .trailing, .top, .bottom])
} }
.cornerRadius(25) .cornerRadius(25)
} }

View File

@@ -22,19 +22,22 @@ struct SettingsView: View {
@AppStorage(UserDefaultsStore.Keys.useCloudKit.rawValue, store: GroupUserDefaults.groupDefaults) private var useCloudKit = false @AppStorage(UserDefaultsStore.Keys.useCloudKit.rawValue, store: GroupUserDefaults.groupDefaults) private var useCloudKit = false
@AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true @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
var body: some View { var body: some View {
ZStack { ZStack {
Color(UIColor.secondarySystemBackground) Color(theme.secondaryBGColor)
VStack { VStack {
closeButtonView
.padding()
Group { Group {
closeButtonView
.padding()
cloudKitEnable cloudKitEnable
addTestDataCell addTestDataCell
clearDB clearDB
changeIcon changeIcon
themePicker
showOnboardingButton showOnboardingButton
whyBackgroundMode whyBackgroundMode
specialThanksCell specialThanksCell
@@ -247,6 +250,34 @@ struct SettingsView: View {
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
} }
private var themePicker: some View {
ZStack {
Color(UIColor.systemBackground)
VStack {
Text(String(localized: "settings_background_title"))
HStack {
Spacer()
ForEach(Theme.allCases, id:\.rawValue) { aTheme in
Button(action: {
theme = aTheme
print(theme)
}, label: {
VStack {
aTheme.preview
Text(aTheme.title)
}
})
Spacer()
}
}
.padding(.top)
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
}
} }
struct SettingsView_Previews: PreviewProvider { struct SettingsView_Previews: PreviewProvider {

View File

@@ -10,6 +10,7 @@ import SwiftUI
struct SwitchableView: View { struct SwitchableView: View {
@State var currentViewIdx = 0 @State var currentViewIdx = 0
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let daysBack: Int let daysBack: Int
@@ -47,7 +48,7 @@ struct SwitchableView: View {
.padding(.top, -12) .padding(.top, -12)
} }
.background( .background(
Color(UIColor.systemBackground) Color(theme.secondaryBGColor)
) )
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.contentShape(Rectangle()) .contentShape(Rectangle())

71
Shared/views/Theme.swift Normal file
View File

@@ -0,0 +1,71 @@
//
// Theme.swift
// Feels (iOS)
//
// Created by Trey Tartt on 2/4/22.
//
import SwiftUI
enum Theme: Int, CaseIterable {
static let iconSize: CGFloat = 50
case system
case ifeelTheme
var title: String {
switch self {
case .system:
return "System"
case .ifeelTheme:
return "iFeel Theme"
}
}
var secondaryBGColor: UIColor {
switch self{
case .system:
return UIColor.secondarySystemBackground
case .ifeelTheme:
return UIColor.systemBackground
}
}
var bg: some View {
switch self {
case .system:
return AnyView(
ZStack {
Rectangle()
.fill(Color(UIColor.systemBackground))
}
)
case .ifeelTheme:
return AnyView(
BGView().equatable()
)
}
}
var preview: some View {
switch self {
case .system:
return AnyView(
ZStack {
Rectangle()
.fill(Color(UIColor.secondarySystemBackground))
.frame(width: Theme.iconSize, height: Theme.iconSize)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
}
)
case .ifeelTheme:
return AnyView(
ZStack {
BGView().equatable()
.frame(width: Theme.iconSize, height: Theme.iconSize)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
}
)
}
}
}

View File

@@ -56,6 +56,7 @@
"settings_use_cloudkit_title" = "Use CloudKit"; "settings_use_cloudkit_title" = "Use CloudKit";
"settings_use_cloudkit_body" = "CloudKit fucking sucks"; "settings_use_cloudkit_body" = "CloudKit fucking sucks";
"settings_use_delete_enable" = "Allow deletion of entry"; "settings_use_delete_enable" = "Allow deletion of entry";
"settings_background_title" = "What background would you like to use";
"mood_value_great" = "Great"; "mood_value_great" = "Great";
"mood_value_good" = "Good"; "mood_value_good" = "Good";