built out themes a bit more
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// Theme.swift
|
// theme.currentTheme.swift
|
||||||
// Feels (iOS)
|
// Feels (iOS)
|
||||||
//
|
//
|
||||||
// Created by Trey Tartt on 2/4/22.
|
// Created by Trey Tartt on 2/4/22.
|
||||||
@@ -7,65 +7,93 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
enum Theme: Int, CaseIterable {
|
struct ThemeConstants {
|
||||||
static let iconSize: CGFloat = 50
|
static let iconSize: CGFloat = 50
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Theme: Int, CaseIterable {
|
||||||
case system
|
case system
|
||||||
case ifeelTheme
|
case iFeel
|
||||||
|
|
||||||
var title: String {
|
var title: String {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
||||||
case .system:
|
case .system:
|
||||||
return "System"
|
return SystemTheme.title
|
||||||
case .ifeelTheme:
|
case .iFeel:
|
||||||
return "iFeel Theme"
|
return IFeelTheme.title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var secondaryBGColor: UIColor {
|
var currentTheme: Themeable {
|
||||||
switch self{
|
|
||||||
case .system:
|
|
||||||
return UIColor.secondarySystemBackground
|
|
||||||
case .ifeelTheme:
|
|
||||||
return UIColor.systemBackground
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var bg: some View {
|
|
||||||
switch self {
|
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:
|
case .system:
|
||||||
return AnyView(
|
return SystemTheme()
|
||||||
ZStack {
|
case .iFeel:
|
||||||
Rectangle()
|
return IFeelTheme()
|
||||||
.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))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol Themeable {
|
||||||
|
static var title: String { get }
|
||||||
|
var secondaryBGColor: UIColor { get }
|
||||||
|
var bg: AnyView { get }
|
||||||
|
var preview: AnyView { get }
|
||||||
|
}
|
||||||
|
|
||||||
|
struct IFeelTheme: Themeable {
|
||||||
|
static var title: String {
|
||||||
|
return "iFeel Theme"
|
||||||
|
}
|
||||||
|
|
||||||
|
var secondaryBGColor: UIColor {
|
||||||
|
return UIColor.systemBackground
|
||||||
|
}
|
||||||
|
|
||||||
|
var bg: AnyView {
|
||||||
|
return AnyView(
|
||||||
|
BGView().equatable()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
var preview: AnyView {
|
||||||
|
return AnyView(
|
||||||
|
ZStack {
|
||||||
|
BGView().equatable()
|
||||||
|
.frame(width: ThemeConstants.iconSize, height: ThemeConstants.iconSize)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SystemTheme: Themeable {
|
||||||
|
static var title: String {
|
||||||
|
return "System"
|
||||||
|
}
|
||||||
|
|
||||||
|
var secondaryBGColor: UIColor {
|
||||||
|
return UIColor.secondarySystemBackground
|
||||||
|
}
|
||||||
|
|
||||||
|
var bg: AnyView {
|
||||||
|
return AnyView(
|
||||||
|
ZStack {
|
||||||
|
Rectangle()
|
||||||
|
.fill(Color(UIColor.systemBackground))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
var preview: AnyView {
|
||||||
|
return AnyView(
|
||||||
|
ZStack {
|
||||||
|
Rectangle()
|
||||||
|
.fill(Color(UIColor.secondarySystemBackground))
|
||||||
|
.frame(width: ThemeConstants.iconSize, height: ThemeConstants.iconSize)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ struct AddMoodHeaderView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
Text(self.getTitle())
|
Text(self.getTitle())
|
||||||
@@ -47,7 +47,7 @@ struct AddMoodHeaderView: View {
|
|||||||
.padding([.leading, .trailing, .bottom])
|
.padding([.leading, .trailing, .bottom])
|
||||||
}
|
}
|
||||||
.background(
|
.background(
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
)
|
)
|
||||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
.frame(minHeight: 88, maxHeight: 150)
|
.frame(minHeight: 88, maxHeight: 150)
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ struct ContentView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
.background(
|
.background(
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
)
|
)
|
||||||
.coordinateSpace(name: "scroll")
|
.coordinateSpace(name: "scroll")
|
||||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
.onPreferenceChange(ViewOffsetKey.self) { value in
|
||||||
@@ -223,7 +223,7 @@ struct ContentView: View {
|
|||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
.padding()
|
.padding()
|
||||||
.background(
|
.background(
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ struct ContentView: View {
|
|||||||
|
|
||||||
private var emptyView: some View {
|
private var emptyView: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
Text(String(localized: "content_view_empty_title"))
|
Text(String(localized: "content_view_empty_title"))
|
||||||
@@ -347,7 +347,7 @@ struct ContentView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
SmallRollUpHeaderView(fakeData: false, backDays: 30)
|
SmallRollUpHeaderView(fakeData: false, backDays: 30)
|
||||||
.background(
|
.background(
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
)
|
)
|
||||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
.padding()
|
.padding()
|
||||||
@@ -365,7 +365,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.padding(.bottom, 5)
|
.padding(.bottom, 5)
|
||||||
.background(
|
.background(
|
||||||
theme.bg
|
theme.currentTheme.bg
|
||||||
.edgesIgnoringSafeArea(.all)
|
.edgesIgnoringSafeArea(.all)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ struct FilterView: View {
|
|||||||
}
|
}
|
||||||
.padding(.bottom, 5)
|
.padding(.bottom, 5)
|
||||||
.background(
|
.background(
|
||||||
theme.bg
|
theme.currentTheme.bg
|
||||||
.edgesIgnoringSafeArea(.all)
|
.edgesIgnoringSafeArea(.all)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,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(theme.secondaryBGColor))
|
.background(Color(theme.currentTheme.secondaryBGColor))
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
}).frame(maxWidth: .infinity)
|
}).frame(maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ struct FilterView: View {
|
|||||||
|
|
||||||
private var statsView: some View {
|
private var statsView: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
@@ -120,7 +120,7 @@ struct FilterView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
VStack {
|
VStack {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
DatePicker(
|
DatePicker(
|
||||||
String(localized: "filter_view_begin_date"),
|
String(localized: "filter_view_begin_date"),
|
||||||
selection: $viewModel.entryStartDate,
|
selection: $viewModel.entryStartDate,
|
||||||
@@ -135,7 +135,7 @@ struct FilterView: View {
|
|||||||
.padding([.leading, .trailing])
|
.padding([.leading, .trailing])
|
||||||
|
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
DatePicker(
|
DatePicker(
|
||||||
String(localized: "filter_view_end_date"),
|
String(localized: "filter_view_end_date"),
|
||||||
selection: $viewModel.entryEndDate,
|
selection: $viewModel.entryEndDate,
|
||||||
@@ -150,7 +150,7 @@ struct FilterView: View {
|
|||||||
.padding([.leading, .trailing])
|
.padding([.leading, .trailing])
|
||||||
|
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
ForEach(weekdays.indices, id: \.self) { dayIdx in
|
ForEach(weekdays.indices, id: \.self) { dayIdx in
|
||||||
@@ -204,7 +204,7 @@ struct FilterView: View {
|
|||||||
.font(.title)
|
.font(.title)
|
||||||
yearGridView(yearData: yearData, columns: columns)
|
yearGridView(yearData: yearData, columns: columns)
|
||||||
.background(
|
.background(
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
)
|
)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ struct SettingsView: View {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
.background(
|
.background(
|
||||||
theme.bg
|
theme.currentTheme.bg
|
||||||
.edgesIgnoringSafeArea(.all)
|
.edgesIgnoringSafeArea(.all)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var specialThanksCell: some View {
|
private var specialThanksCell: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
withAnimation{
|
withAnimation{
|
||||||
@@ -102,7 +102,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var addTestDataCell: some View {
|
private var addTestDataCell: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
Button(action: {
|
Button(action: {
|
||||||
PersistenceController.shared.populateTestData()
|
PersistenceController.shared.populateTestData()
|
||||||
editedDataClosure()
|
editedDataClosure()
|
||||||
@@ -117,7 +117,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var clearDB: some View {
|
private var clearDB: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
Button(action: {
|
Button(action: {
|
||||||
PersistenceController.shared.clearDB()
|
PersistenceController.shared.clearDB()
|
||||||
editedDataClosure()
|
editedDataClosure()
|
||||||
@@ -132,7 +132,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var whyBackgroundMode: some View {
|
private var whyBackgroundMode: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
withAnimation{
|
withAnimation{
|
||||||
@@ -159,7 +159,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var changeIcon: some View {
|
private var changeIcon: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Text(String(localized: "settings_view_change_icon"))
|
Text(String(localized: "settings_view_change_icon"))
|
||||||
HStack {
|
HStack {
|
||||||
@@ -196,7 +196,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var showOnboardingButton: some View {
|
private var showOnboardingButton: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
Button(action: {
|
Button(action: {
|
||||||
showOnboarding.toggle()
|
showOnboarding.toggle()
|
||||||
}, label: {
|
}, label: {
|
||||||
@@ -210,7 +210,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var cloudKitEnable: some View {
|
private var cloudKitEnable: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Toggle(String(localized: "settings_use_cloudkit_title"),
|
Toggle(String(localized: "settings_use_cloudkit_title"),
|
||||||
isOn: $useCloudKit)
|
isOn: $useCloudKit)
|
||||||
@@ -228,7 +228,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var cloudKitStatus: some View {
|
private var cloudKitStatus: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Image(systemName: syncMonitor.syncStateSummary.symbolName)
|
Image(systemName: syncMonitor.syncStateSummary.symbolName)
|
||||||
.foregroundColor(syncMonitor.syncStateSummary.symbolColor)
|
.foregroundColor(syncMonitor.syncStateSummary.symbolColor)
|
||||||
@@ -242,7 +242,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var canDelete: some View {
|
private var canDelete: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Toggle(String(localized: "settings_use_delete_enable"),
|
Toggle(String(localized: "settings_use_delete_enable"),
|
||||||
isOn: $deleteEnabled)
|
isOn: $deleteEnabled)
|
||||||
@@ -255,7 +255,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
private var themePicker: some View {
|
private var themePicker: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
VStack {
|
VStack {
|
||||||
Text(String(localized: "settings_background_title"))
|
Text(String(localized: "settings_background_title"))
|
||||||
HStack {
|
HStack {
|
||||||
@@ -265,7 +265,7 @@ struct SettingsView: View {
|
|||||||
theme = aTheme
|
theme = aTheme
|
||||||
}, label: {
|
}, label: {
|
||||||
VStack {
|
VStack {
|
||||||
aTheme.preview
|
aTheme.currentTheme.preview
|
||||||
.overlay(
|
.overlay(
|
||||||
Circle()
|
Circle()
|
||||||
.stroke(Color(UIColor.systemGray), style: StrokeStyle(lineWidth: 2))
|
.stroke(Color(UIColor.systemGray), style: StrokeStyle(lineWidth: 2))
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ struct SwitchableView: View {
|
|||||||
.padding(.top, -12)
|
.padding(.top, -12)
|
||||||
}
|
}
|
||||||
.background(
|
.background(
|
||||||
Color(theme.secondaryBGColor)
|
Color(theme.currentTheme.secondaryBGColor)
|
||||||
)
|
)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
|
|||||||
Reference in New Issue
Block a user