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

View File

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

View File

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

View File

@@ -12,6 +12,7 @@ import CoreData
struct AddMoodHeaderView: View {
private let savedOnboardingData = UserDefaultsStore.getOnboarding()
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let addItemHeaderClosure: ((Mood, Date) -> Void)
@@ -19,7 +20,7 @@ struct AddMoodHeaderView: View {
var body: some View {
ZStack {
Color(UIColor.systemBackground)
Color(theme.secondaryBGColor)
VStack {
Text(self.getTitle())
@@ -45,6 +46,9 @@ struct AddMoodHeaderView: View {
}
.padding([.leading, .trailing, .bottom])
}
.background(
Color(theme.secondaryBGColor)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.frame(minHeight: 88, maxHeight: 150)
.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.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true
@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 showTodayInput = true
@@ -33,7 +34,8 @@ struct ContentView: View {
@ObservedObject var viewModel = ContentModeViewModel()
init(){
UITabBar.appearance().backgroundColor = UIColor.systemBackground
UITabBar.appearance().backgroundColor = theme.secondaryBGColor
print(theme)
}
var body: some View {
@@ -180,7 +182,7 @@ struct ContentView: View {
)
}
.background(
Color(UIColor.systemBackground)
Color(theme.secondaryBGColor)
)
.coordinateSpace(name: "scroll")
.onPreferenceChange(ViewOffsetKey.self) { value in
@@ -200,7 +202,7 @@ struct ContentView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(
Color(UIColor.systemBackground)
Color(theme.secondaryBGColor)
)
}
@@ -285,7 +287,7 @@ struct ContentView: View {
private var emptyView: some View {
ZStack {
Color(UIColor.systemBackground)
Color(theme.secondaryBGColor)
VStack {
Text(String(localized: "content_view_empty_title"))
@@ -327,7 +329,7 @@ struct ContentView: View {
VStack {
SmallRollUpHeaderView(fakeData: false, backDays: 30)
.background(
Color(UIColor.systemBackground)
Color(theme.secondaryBGColor)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.padding()
@@ -342,7 +344,8 @@ struct ContentView: View {
.padding([.leading, .trailing, .bottom])
}
}.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")]
@State private var toggle = true
@State private var showFilter = false
@FetchRequest(
@@ -21,6 +20,8 @@ struct FilterView: View {
animation: .spring())
private var items: FetchedResults<MoodEntry>
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@StateObject private var viewModel = FilterViewModel()
//[
// 2001: [0: [], 1: [], 2: []],
@@ -63,6 +64,10 @@ struct FilterView: View {
self.viewModel.filterEntries(startDate: Date(timeIntervalSince1970: 0), endDate: Date())
})
}
.background(
theme.bg
.edgesIgnoringSafeArea(.all)
)
}
private var filterButon: some View {
@@ -75,7 +80,7 @@ struct FilterView: View {
.frame(maxWidth: .infinity)
.frame(height: 44)
.foregroundColor(Color(UIColor.label))
.background(Color(UIColor.secondarySystemBackground))
.background(Color(theme.secondaryBGColor))
.cornerRadius(25)
}).frame(maxWidth: .infinity)
}
@@ -97,7 +102,7 @@ struct FilterView: View {
private var statsView: some View {
ZStack {
Color(UIColor.secondarySystemBackground)
Color(theme.secondaryBGColor)
HStack {
Spacer()
@@ -115,7 +120,7 @@ struct FilterView: View {
VStack {
VStack {
ZStack {
Color(UIColor.secondarySystemBackground)
Color(theme.secondaryBGColor)
DatePicker(
String(localized: "filter_view_begin_date"),
selection: $viewModel.entryStartDate,
@@ -130,7 +135,7 @@ struct FilterView: View {
.padding([.leading, .trailing])
ZStack {
Color(UIColor.secondarySystemBackground)
Color(theme.secondaryBGColor)
DatePicker(
String(localized: "filter_view_end_date"),
selection: $viewModel.entryEndDate,
@@ -145,7 +150,7 @@ struct FilterView: View {
.padding([.leading, .trailing])
ZStack {
Color(UIColor.secondarySystemBackground)
Color(theme.secondaryBGColor)
HStack {
Spacer()
ForEach(weekdays.indices, id: \.self) { dayIdx in
@@ -198,6 +203,10 @@ struct FilterView: View {
Text(String(yearKey))
.font(.title)
yearGridView(yearData: yearData, columns: columns)
.background(
Color(theme.secondaryBGColor)
)
.cornerRadius(25)
}
}
.simultaneousGesture(DragGesture().onChanged({ _ in
@@ -215,20 +224,16 @@ struct FilterView: View {
let columns: [GridItem]
var body: some View {
ZStack {
Color(UIColor.secondarySystemBackground)
VStack {
LazyVGrid(columns: columns, spacing: 0) {
ForEach(Array(yearData.keys.sorted(by: <)), id: \.self) { monthKey in
let monthData = yearData[monthKey]!
VStack {
monthGridView(monthData: monthData)
}
VStack {
LazyVGrid(columns: columns, spacing: 0) {
ForEach(Array(yearData.keys.sorted(by: <)), id: \.self) { monthKey in
let monthData = yearData[monthKey]!
VStack {
monthGridView(monthData: monthData)
}
}
.padding([.leading, .trailing, .top, .bottom])
}
.padding([.leading, .trailing, .top, .bottom])
}
.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.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 {
ZStack {
Color(UIColor.secondarySystemBackground)
Color(theme.secondaryBGColor)
VStack {
closeButtonView
.padding()
Group {
closeButtonView
.padding()
cloudKitEnable
addTestDataCell
clearDB
changeIcon
themePicker
showOnboardingButton
whyBackgroundMode
specialThanksCell
@@ -247,6 +250,34 @@ struct SettingsView: View {
.fixedSize(horizontal: false, vertical: true)
.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 {

View File

@@ -10,6 +10,7 @@ import SwiftUI
struct SwitchableView: View {
@State var currentViewIdx = 0
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let daysBack: Int
@@ -47,7 +48,7 @@ struct SwitchableView: View {
.padding(.top, -12)
}
.background(
Color(UIColor.systemBackground)
Color(theme.secondaryBGColor)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.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_body" = "CloudKit fucking sucks";
"settings_use_delete_enable" = "Allow deletion of entry";
"settings_background_title" = "What background would you like to use";
"mood_value_great" = "Great";
"mood_value_good" = "Good";