separate all customize views into their own files

make corner radius a constant
create the views in the main app file and pass through so they dont get re-drawn when changing UI things
This commit is contained in:
Trey t
2022-04-02 10:53:04 -05:00
parent 3d1b7abc64
commit 682f62fa4a
25 changed files with 764 additions and 551 deletions

View File

@@ -22,6 +22,15 @@
1C10E24E27A1AB110047948B /* UserDefaultsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */; };
1C10E25027A1AB220047948B /* OnboardingDay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03774279A294800D26164 /* OnboardingDay.swift */; };
1C10E25127A1AB320047948B /* OnboardingTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03776279A295600D26164 /* OnboardingTitle.swift */; };
1C1AFF3027F894970067F9DC /* ThemePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF2F27F894970067F9DC /* ThemePickerView.swift */; };
1C1AFF3227F894A40067F9DC /* IconPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF3127F894A40067F9DC /* IconPickerView.swift */; };
1C1AFF3427F894BA0067F9DC /* TintPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF3327F894BA0067F9DC /* TintPickerView.swift */; };
1C1AFF3827F8951F0067F9DC /* CustomWigetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF3727F8951F0067F9DC /* CustomWigetView.swift */; };
1C1AFF3A27F895490067F9DC /* ImagePackPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF3927F895490067F9DC /* ImagePackPickerView.swift */; };
1C1AFF3C27F895800067F9DC /* TextColorPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF3B27F895800067F9DC /* TextColorPickerView.swift */; };
1C1AFF3E27F895A40067F9DC /* PersonalityPackPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF3D27F895A40067F9DC /* PersonalityPackPickerView.swift */; };
1C1AFF4127F895C00067F9DC /* ShapePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF4027F895C00067F9DC /* ShapePickerView.swift */; };
1C1AFF4327F895D90067F9DC /* DayFilterPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C1AFF4227F895D90067F9DC /* DayFilterPickerView.swift */; };
1C2162EB27C14EFA004353D1 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2162EA27C14EFA004353D1 /* Date+Extensions.swift */; };
1C2162EC27C14FC5004353D1 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2162EA27C14EFA004353D1 /* Date+Extensions.swift */; };
1C2162EE27C15191004353D1 /* MoodEntryFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2162ED27C15191004353D1 /* MoodEntryFunctions.swift */; };
@@ -191,6 +200,15 @@
1C04489827C3F24000D22444 /* Color+Codable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Codable.swift"; sourceTree = "<group>"; };
1C0DAB46279DB0FB003B1F21 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
1C0DAB48279DB116003B1F21 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
1C1AFF2F27F894970067F9DC /* ThemePickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemePickerView.swift; sourceTree = "<group>"; };
1C1AFF3127F894A40067F9DC /* IconPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconPickerView.swift; sourceTree = "<group>"; };
1C1AFF3327F894BA0067F9DC /* TintPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TintPickerView.swift; sourceTree = "<group>"; };
1C1AFF3727F8951F0067F9DC /* CustomWigetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomWigetView.swift; sourceTree = "<group>"; };
1C1AFF3927F895490067F9DC /* ImagePackPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePackPickerView.swift; sourceTree = "<group>"; };
1C1AFF3B27F895800067F9DC /* TextColorPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextColorPickerView.swift; sourceTree = "<group>"; };
1C1AFF3D27F895A40067F9DC /* PersonalityPackPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersonalityPackPickerView.swift; sourceTree = "<group>"; };
1C1AFF4027F895C00067F9DC /* ShapePickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShapePickerView.swift; sourceTree = "<group>"; };
1C1AFF4227F895D90067F9DC /* DayFilterPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DayFilterPickerView.swift; sourceTree = "<group>"; };
1C2162EA27C14EFA004353D1 /* Date+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = "<group>"; };
1C2162ED27C15191004353D1 /* MoodEntryFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoodEntryFunctions.swift; sourceTree = "<group>"; };
1C2162F127C156E6004353D1 /* CustomizeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizeView.swift; sourceTree = "<group>"; };
@@ -365,6 +383,7 @@
isa = PBXGroup;
children = (
1C2162F127C156E6004353D1 /* CustomizeView.swift */,
1C1AFF4427F898E40067F9DC /* SubViews */,
);
path = CustomizeView;
sourceTree = "<group>";
@@ -394,6 +413,22 @@
path = Sharing;
sourceTree = "<group>";
};
1C1AFF4427F898E40067F9DC /* SubViews */ = {
isa = PBXGroup;
children = (
1C1AFF3727F8951F0067F9DC /* CustomWigetView.swift */,
1C1AFF4227F895D90067F9DC /* DayFilterPickerView.swift */,
1C1AFF3127F894A40067F9DC /* IconPickerView.swift */,
1C1AFF3927F895490067F9DC /* ImagePackPickerView.swift */,
1C1AFF3D27F895A40067F9DC /* PersonalityPackPickerView.swift */,
1C1AFF4027F895C00067F9DC /* ShapePickerView.swift */,
1C1AFF3B27F895800067F9DC /* TextColorPickerView.swift */,
1C1AFF2F27F894970067F9DC /* ThemePickerView.swift */,
1C1AFF3327F894BA0067F9DC /* TintPickerView.swift */,
);
path = SubViews;
sourceTree = "<group>";
};
1C26190127960CDA00FDC148 /* Protocols */ = {
isa = PBXGroup;
children = (
@@ -827,9 +862,11 @@
1CA0377C279B605000D26164 /* OnboardingWrapup.swift in Sources */,
1C4FF3C327BEE07200BE8F34 /* PersistenceDELETE.swift in Sources */,
1CA03775279A294800D26164 /* OnboardingDay.swift in Sources */,
1C1AFF3C27F895800067F9DC /* TextColorPickerView.swift in Sources */,
1CAD603727A5C1C800C520BD /* YearView.swift in Sources */,
1C04488D27C2ADDB00D22444 /* IconViewModel.swift in Sources */,
1C2162F227C156E6004353D1 /* CustomizeView.swift in Sources */,
1C1AFF3E27F895A40067F9DC /* PersonalityPackPickerView.swift in Sources */,
1C683FCA2792281400745862 /* Stats.swift in Sources */,
1C76E86E27C882A400ADEE1F /* SharingImageModels.swift in Sources */,
1C718C7327F611E300A8F9FE /* StupidAssCustomWidgetObservableObject.swift in Sources */,
@@ -837,6 +874,8 @@
1CD90B76278C8119001C4FEA /* LocalNotification.swift in Sources */,
1C358FB627B0AE15002C83A6 /* AllMoodsTotalTemplate.swift in Sources */,
1CD90B16278C7DE0001C4FEA /* Feels.xcdatamodeld in Sources */,
1C1AFF3027F894970067F9DC /* ThemePickerView.swift in Sources */,
1C1AFF4327F895D90067F9DC /* DayFilterPickerView.swift in Sources */,
1C04488727C1C81D00D22444 /* PersonalityPackable.swift in Sources */,
1C4FF3BE27BEDF9100BE8F34 /* PersistenceHelper.swift in Sources */,
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */,
@@ -853,6 +892,7 @@
1C358FBE27B4D1F2002C83A6 /* CurrentStreakTemplate.swift in Sources */,
1C4FF3C727BEE09E00BE8F34 /* PersistenceADD.swift in Sources */,
1C414C0F27D51FB500BC1720 /* EntryListView.swift in Sources */,
1C1AFF3827F8951F0067F9DC /* CustomWigetView.swift in Sources */,
1C4FF3BB27BEDDF000BE8F34 /* ShowBasedOnVoteLogics.swift in Sources */,
1CAD603527A5C1C800C520BD /* SettingsView.swift in Sources */,
1CD90B53278C7E7A001C4FEA /* FeelsWidget.intentdefinition in Sources */,
@@ -869,6 +909,7 @@
1C7352B927DD02760024B5D2 /* ImagePickerGridView.swift in Sources */,
1C358FB327B0ADA4002C83A6 /* SharingTemplate.swift in Sources */,
1C358FB827B0AEE3002C83A6 /* LongestStreakTemplate.swift in Sources */,
1C1AFF4127F895C00067F9DC /* ShapePickerView.swift in Sources */,
1C358FB127B0AD87002C83A6 /* SharingListView.swift in Sources */,
1CD90B1C278C7DE0001C4FEA /* Persistence.swift in Sources */,
1CEC966F27B9C29300CC8688 /* CustomWidgetView.swift in Sources */,
@@ -879,6 +920,7 @@
1CD90B18278C7DE0001C4FEA /* FeelsApp.swift in Sources */,
1C358FC027B4D20C002C83A6 /* MonthTotalTemplate.swift in Sources */,
1CA03777279A295600D26164 /* OnboardingTitle.swift in Sources */,
1C1AFF3A27F895490067F9DC /* ImagePackPickerView.swift in Sources */,
1C4FF3C027BEE06900BE8F34 /* PersistenceGET.swift in Sources */,
1C04488A27C2ABD500D22444 /* IconView.swift in Sources */,
1C361F0C27C0356B00E832FC /* MainTabView.swift in Sources */,
@@ -891,7 +933,9 @@
1C95ABCC27E6FA7200509BD3 /* DiamondView.swift in Sources */,
1C2162EB27C14EFA004353D1 /* Date+Extensions.swift in Sources */,
1C02589C27B9677A00EB91AC /* CreateWidgetView.swift in Sources */,
1C1AFF3227F894A40067F9DC /* IconPickerView.swift in Sources */,
1C04489927C3F24000D22444 /* Color+Codable.swift in Sources */,
1C1AFF3427F894BA0067F9DC /* TintPickerView.swift in Sources */,
1C358FC227B4D227002C83A6 /* WeekTotalTemplate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@@ -14,8 +14,6 @@ struct FeelsApp: App {
@Environment(\.scenePhase) private var scenePhase
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject var daysFilter = DaysFilterClass()
let persistenceController = PersistenceController.shared
init() {
@@ -28,12 +26,16 @@ struct FeelsApp: App {
var body: some Scene {
WindowGroup {
MainTabView()
.environment(\.managedObjectContext, persistenceController.viewContext)
.environmentObject(daysFilter)
// build these here so when tints and other things get updated the views / their data dont
// have to get redrawn
MainTabView(dayView: DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false)),
monthView: MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true)),
yearView: YearView(viewModel: YearViewModel()),
customizeView: CustomizeView())
.environment(\.managedObjectContext, persistenceController.viewContext)
}.onChange(of: scenePhase) { phase in
if phase == .background {
// BGTask.scheduleBackgroundProcessing()
//BGTask.scheduleBackgroundProcessing()
WidgetCenter.shared.reloadAllTimelines()
}

View File

@@ -8,6 +8,8 @@
import SwiftUI
class DaysFilterClass: ObservableObject {
static let shared = DaysFilterClass()
@Published public var currentFilters = [Int]()
init() {

View File

@@ -11,6 +11,8 @@ import SwiftUI
struct Constants {
static let groupShareId = "group.com.88oakapps.ifeel"
static let groupShareIdDebug = "group.com.88oakapps.ifeelDebug"
static let viewsCornerRaidus: CGFloat = 10
}
struct GroupUserDefaults {

View File

@@ -54,7 +54,7 @@ struct AddMoodHeaderView: View {
.background(
theme.currentTheme.secondaryBGColor
)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.frame(minHeight: 88, maxHeight: 150)
.frame(minWidth: 0, maxWidth: .infinity)
}

View File

@@ -8,365 +8,43 @@
import SwiftUI
struct CustomizeView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@AppStorage(UserDefaultsStore.Keys.moodImages.rawValue, store: GroupUserDefaults.groupDefaults) private var imagePack: MoodImages = .FontAwesome
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
@AppStorage(UserDefaultsStore.Keys.shape.rawValue, store: GroupUserDefaults.groupDefaults) private var shape: BGShape = .circle
@AppStorage(UserDefaultsStore.Keys.personalityPack.rawValue, store: GroupUserDefaults.groupDefaults) private var personalityPack: PersonalityPack = .Default
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
@AppStorage(UserDefaultsStore.Keys.showNSFW.rawValue, store: GroupUserDefaults.groupDefaults) private var showNSFW: Bool = false
@State private var sampleListEntry = PersistenceController.shared.randomEntries(count: 1).first!
@State private var showOver18Alert = false
@StateObject private var customMoodTint = UserDefaultsStore.getCustomMoodTint()
@State var shapeRefreshToggleThing: Bool = false
@StateObject private var selectedWidget = StupidAssCustomWidgetObservableObject()
@EnvironmentObject var daysFilter: DaysFilterClass
let weekdays = [("Sun", 1),
("mon", 2),
("tue", 3),
("wed", 4),
("thur", 5),
("fri", 6),
("sat", 7)]
let iconSets: [(String,String)] = [
("AppIconGoodImage", "AppIconGood"),
("AppIconAverageImage", "AppIconAverage"),
("AppIconBadImage", "AppIconBad"),
("AppIconBlueGreenImage", "AppIconBlueGreen"),
("AppIconNeonGreenImage", "AppIconNeonGreen"),
("AppIconPinkImage", "AppIconPink"),
("AppIconPurpleImage", "AppIconPurple")
]
@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
var body: some View {
ScrollView {
VStack {
Group {
createCustomWidget
changeIcon
themePicker
CustomWigetView()
IconPickerView()
ThemePickerView()
Divider()
sampleEntryView
pickMoodImagePack
ImagePackPickerView()
}
Group {
pickMoodTintPack
pickTextColor
TintPickerView()
TextColorPickerView()
}
Divider()
dayFilterView
DayFilterPickerView()
Divider()
shapePicker
ShapePickerView()
Divider()
pickPeronsalityPack
PersonalityPackPickerView()
}
}
.onAppear(perform: {
EventLogger.log(event: "show_customize_view")
})
.padding()
.sheet(isPresented: $selectedWidget.showFuckingSheet) {
if let fuckingWrapped = selectedWidget.fuckingWrapped {
CreateWidgetView(customWidget: fuckingWrapped)
}
}
.background(
theme.currentTheme.bg
.edgesIgnoringSafeArea(.all)
)
}
private var changeIcon: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ScrollView(.horizontal) {
HStack {
Button(action: {
UIApplication.shared.setAlternateIconName(nil)
EventLogger.log(event: "change_icon_title", withData: ["title": "default"])
}, label: {
Image("AppIconImage", bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
ForEach(iconSets, id: \.self.0){ iconSet in
Button(action: {
UIApplication.shared.setAlternateIconName(iconSet.1) { (error) in
// FIXME: Handle error
}
EventLogger.log(event: "change_icon_title", withData: ["title": iconSet.1])
}, label: {
Image(iconSet.0, bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
}
}
.padding()
}
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
.padding()
.cornerRadius(10)
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var themePicker: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
HStack {
Spacer()
ForEach(Theme.allCases, id:\.rawValue) { aTheme in
Button(action: {
theme = aTheme
EventLogger.log(event: "change_theme_id", withData: ["id": aTheme.rawValue])
}, label: {
VStack {
aTheme.currentTheme.preview
.overlay(
Circle()
.stroke(Color(UIColor.systemGray), style: StrokeStyle(lineWidth: 2))
)
Text(aTheme.title)
.foregroundColor(textColor)
.font(.body)
}
})
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(theme == aTheme ? theme.currentTheme.bgColor : .clear)
.padding(-5)
)
Spacer()
}
}
.padding(.top)
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var createCustomWidget: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ScrollView(.horizontal) {
HStack {
ForEach(UserDefaultsStore.getCustomWidgets(), id: \.uuid) { widget in
CustomWidgetView(customWidgetModel: widget)
.frame(width: 50, height: 50)
.cornerRadius(10)
.onTapGesture {
EventLogger.log(event: "show_widget")
selectedWidget.fuckingWrapped = widget.copy() as? CustomWidgetModel
selectedWidget.showFuckingSheet = true
}
}
RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.secondaryBGColor)
.frame(width: 50, height: 50)
.overlay(
Image(systemName: "plus")
)
.onTapGesture {
EventLogger.log(event: "tap_create_new_widget")
selectedWidget.fuckingWrapped = CustomWidgetModel.randomWidget
selectedWidget.showFuckingSheet = true
}
}
.padding()
}
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
.padding()
.cornerRadius(10)
Text("[How to add widget](https://support.apple.com/guide/iphone/add-widgets-iphb8f1bf206/ios)")
.accentColor(textColor)
.padding(.bottom)
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var pickMoodImagePack: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ForEach(MoodImages.allCases, id: \.rawValue) { images in
ZStack {
VStack {
HStack {
ForEach(Mood.allValues, id: \.self) { mood in
images.icon(forMood: mood)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 35, height: 35)
.foregroundColor(
moodTint.color(forMood: mood)
)
}
.frame(minWidth: 0, maxWidth: .infinity)
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(imagePack == images ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
imagePack = images
EventLogger.log(event: "change_image_pack_id", withData: ["id": images.rawValue])
}
if images.rawValue != (MoodImages.allCases.sorted(by: { $0.rawValue > $1.rawValue }).first?.rawValue) ?? 0 {
Divider()
}
}
}
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var pickMoodTintPack: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ForEach(MoodTints.defaultOptions, id: \.rawValue) { tint in
HStack {
ForEach(Mood.allValues, id: \.self) { mood in
Circle()
.frame(width: 35, height: 35)
.foregroundColor(
tint.color(forMood: mood)
)
}
.frame(minWidth: 0, maxWidth: .infinity)
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(moodTint == tint ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
moodTint = tint
EventLogger.log(event: "change_mood_tint_id", withData: ["id": tint.rawValue])
}
Divider()
}
ZStack {
Color.clear
Rectangle()
.frame(height: 35)
.frame(minWidth: 0, maxWidth: .infinity)
.foregroundColor(.clear)
.contentShape(Rectangle())
.onTapGesture {
moodTint = .Custom
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
}
HStack {
ColorPicker("", selection: $customMoodTint.colorOne)
.onChange(of: customMoodTint.colorOne, perform: { _ in
saveCustomMoodTint()
})
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
ColorPicker("", selection: $customMoodTint.colorTwo)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorTwo, perform: { _ in
saveCustomMoodTint()
})
ColorPicker("", selection: $customMoodTint.colorThree)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorThree, perform: { _ in
saveCustomMoodTint()
})
ColorPicker("", selection: $customMoodTint.colorFour)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorFour, perform: { _ in
saveCustomMoodTint()
})
ColorPicker("", selection: $customMoodTint.colorFive)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorFive, perform: { _ in
saveCustomMoodTint()
})
}
.background(
Color.clear
)
}
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(moodTint == .Custom ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var pickTextColor: some View {
ZStack {
theme.currentTheme.secondaryBGColor
ColorPicker(String(localized: "customize_view_view_text_color"), selection: $textColor)
.padding()
.foregroundColor(textColor)
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var sampleEntryView: some View {
ZStack {
theme.currentTheme.secondaryBGColor
@@ -395,156 +73,10 @@ struct CustomizeView: View {
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private func saveCustomMoodTint() {
UserDefaultsStore.saveCustomMoodTint(customTint: customMoodTint)
moodTint = .Custom
EventLogger.log(event: "change_mood_tint_id", withData: ["id": MoodTints.Custom.rawValue])
customMoodTintUpdateNumber += 1
}
private var pickPeronsalityPack: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ForEach(PersonalityPack.allCases, id: \.self) { aPack in
VStack(spacing: 10) {
Text(String(aPack.title()))
.font(.body)
.foregroundColor(textColor)
Text(aPack.randomPushNotificationStrings().title)
.font(.body)
.foregroundColor(Color(UIColor.systemGray))
Text(aPack.randomPushNotificationStrings().body)
.font(.body)
.foregroundColor(Color(UIColor.systemGray))
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(personalityPack == aPack ? theme.currentTheme.bgColor : .clear)
.padding(5)
)
.onTapGesture {
if aPack.rawValue == PersonalityPack.Rude.rawValue && !showNSFW {
showOver18Alert = true
EventLogger.log(event: "show_over_18_alert")
} else {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
personalityPack = aPack
EventLogger.log(event: "change_personality_pack", withData: ["pack_title": aPack.title()])
LocalNotification.rescheduleNotifiations()
}
}
.blur(radius: aPack.rawValue == PersonalityPack.Rude.rawValue && !showNSFW ? 5 : 0)
.alert(isPresented: $showOver18Alert) {
let primaryButton = Alert.Button.default(Text(String(localized: "customize_view_over18alert_ok"))) {
showNSFW = true
}
let secondaryButton = Alert.Button.cancel(Text(String(localized: "customize_view_over18alert_no"))) {
showNSFW = false
}
return Alert(title: Text(String(localized: "customize_view_over18alert_title")),
message: Text(String(localized: "customize_view_over18alert_body")),
primaryButton: primaryButton,
secondaryButton: secondaryButton)
}
if aPack.rawValue != (PersonalityPack.allCases.sorted(by: { $0.rawValue > $1.rawValue }).first?.rawValue) ?? 0 {
Divider()
}
}
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var shapePicker: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
HStack {
Spacer()
Text(shapeRefreshToggleThing.description.localizedLowercase)
.hidden()
Image(systemName: "arrow.triangle.2.circlepath.circle")
.resizable()
.frame(width: 20, height: 20, alignment: .trailing)
.foregroundColor(Color(UIColor.systemGray))
.onTapGesture {
shapeRefreshToggleThing.toggle()
}
}
Spacer()
}
.padding()
VStack(alignment:.leading) {
Text(String(localized: "customize_view_view_pick_shape"))
.padding([.leading])
.foregroundColor(textColor)
Divider()
HStack {
ForEach(BGShape.allCases, id: \.rawValue) { ashape in
ashape.view(withText: Text("20"),
bgColor: moodTint.color(forMood: Mood.allValues.randomElement()!), textColor: textColor)
.frame(height: 50)
.frame(minWidth: 0, maxWidth: .infinity)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
shape = ashape
EventLogger.log(event: "change_mood_shape_id", withData: ["id": shape.rawValue])
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(shape == ashape ? theme.currentTheme.bgColor : .clear)
.padding(-5)
)
}
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var dayFilterView: some View {
ZStack {
theme.currentTheme.secondaryBGColor
HStack {
ForEach(weekdays.indices, id: \.self) { dayIdx in
let day = String(weekdays[dayIdx].0)
let value = weekdays[dayIdx].1
Button(day.capitalized, action: {
if daysFilter.currentFilters.contains(value) {
daysFilter.removeFilter(filter: value)
} else {
daysFilter.addFilter(newFilter: value)
}
})
.frame(maxWidth: .infinity)
.foregroundColor(daysFilter.currentFilters.contains(value) ? .green : .red)
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct CustomizeView_Previews: PreviewProvider {

View File

@@ -0,0 +1,67 @@
//
// CustomWigetView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct CustomWigetView: 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
@StateObject private var selectedWidget = StupidAssCustomWidgetObservableObject()
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ScrollView(.horizontal) {
HStack {
ForEach(UserDefaultsStore.getCustomWidgets(), id: \.uuid) { widget in
CustomWidgetView(customWidgetModel: widget)
.frame(width: 50, height: 50)
.cornerRadius(10)
.onTapGesture {
EventLogger.log(event: "show_widget")
selectedWidget.fuckingWrapped = widget.copy() as? CustomWidgetModel
selectedWidget.showFuckingSheet = true
}
}
RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.secondaryBGColor)
.frame(width: 50, height: 50)
.overlay(
Image(systemName: "plus")
)
.onTapGesture {
EventLogger.log(event: "tap_create_new_widget")
selectedWidget.fuckingWrapped = CustomWidgetModel.randomWidget
selectedWidget.showFuckingSheet = true
}
}
.padding()
}
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
.padding()
.cornerRadius(10)
Text("[How to add widget](https://support.apple.com/guide/iphone/add-widgets-iphb8f1bf206/ios)")
.accentColor(textColor)
.padding(.bottom)
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.sheet(isPresented: $selectedWidget.showFuckingSheet) {
if let fuckingWrapped = selectedWidget.fuckingWrapped {
CreateWidgetView(customWidget: fuckingWrapped)
}
}
}
}
struct CustomWigetView_Previews: PreviewProvider {
static var previews: some View {
CustomWigetView()
}
}

View File

@@ -0,0 +1,52 @@
//
// DayFilterPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct DayFilterPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@StateObject private var filteredDays = DaysFilterClass.shared
let weekdays = [("Sun", 1),
("mon", 2),
("tue", 3),
("wed", 4),
("thur", 5),
("fri", 6),
("sat", 7)]
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
HStack {
ForEach(weekdays.indices, id: \.self) { dayIdx in
let day = String(weekdays[dayIdx].0)
let value = weekdays[dayIdx].1
Button(day.capitalized, action: {
if filteredDays.currentFilters.contains(value) {
filteredDays.removeFilter(filter: value)
} else {
filteredDays.addFilter(newFilter: value)
}
})
.frame(maxWidth: .infinity)
.foregroundColor(filteredDays.currentFilters.contains(value) ? .green : .red)
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct DayFilterPickerView_Previews: PreviewProvider {
static var previews: some View {
DayFilterPickerView()
}
}

View File

@@ -0,0 +1,70 @@
//
// IconPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct IconPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let iconSets: [(String,String)] = [
("AppIconGoodImage", "AppIconGood"),
("AppIconAverageImage", "AppIconAverage"),
("AppIconBadImage", "AppIconBad"),
("AppIconBlueGreenImage", "AppIconBlueGreen"),
("AppIconNeonGreenImage", "AppIconNeonGreen"),
("AppIconPinkImage", "AppIconPink"),
("AppIconPurpleImage", "AppIconPurple")
]
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ScrollView(.horizontal) {
HStack {
Button(action: {
UIApplication.shared.setAlternateIconName(nil)
EventLogger.log(event: "change_icon_title", withData: ["title": "default"])
}, label: {
Image("AppIconImage", bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
ForEach(iconSets, id: \.self.0){ iconSet in
Button(action: {
UIApplication.shared.setAlternateIconName(iconSet.1) { (error) in
// FIXME: Handle error
}
EventLogger.log(event: "change_icon_title", withData: ["title": iconSet.1])
}, label: {
Image(iconSet.0, bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
}
}
.padding()
}
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
.padding()
.cornerRadius(10)
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct IconPickerView_Previews: PreviewProvider {
static var previews: some View {
IconPickerView()
}
}

View File

@@ -0,0 +1,64 @@
//
// ImagePackPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct ImagePackPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
@AppStorage(UserDefaultsStore.Keys.moodImages.rawValue, store: GroupUserDefaults.groupDefaults) private var imagePack: MoodImages = .FontAwesome
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ForEach(MoodImages.allCases, id: \.rawValue) { images in
ZStack {
VStack {
HStack {
ForEach(Mood.allValues, id: \.self) { mood in
images.icon(forMood: mood)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 35, height: 35)
.foregroundColor(
moodTint.color(forMood: mood)
)
}
.frame(minWidth: 0, maxWidth: .infinity)
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(imagePack == images ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
imagePack = images
EventLogger.log(event: "change_image_pack_id", withData: ["id": images.rawValue])
}
if images.rawValue != (MoodImages.allCases.sorted(by: { $0.rawValue > $1.rawValue }).first?.rawValue) ?? 0 {
Divider()
}
}
}
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct ImagePackPickerView_Previews: PreviewProvider {
static var previews: some View {
ImagePackPickerView()
}
}

View File

@@ -0,0 +1,83 @@
//
// PersonalityPackPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct PersonalityPackPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@AppStorage(UserDefaultsStore.Keys.personalityPack.rawValue, store: GroupUserDefaults.groupDefaults) private var personalityPack: PersonalityPack = .Default
@State private var showOver18Alert = false
@AppStorage(UserDefaultsStore.Keys.showNSFW.rawValue, store: GroupUserDefaults.groupDefaults) private var showNSFW: Bool = false
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ForEach(PersonalityPack.allCases, id: \.self) { aPack in
VStack(spacing: 10) {
Text(String(aPack.title()))
.font(.body)
.foregroundColor(textColor)
Text(aPack.randomPushNotificationStrings().title)
.font(.body)
.foregroundColor(Color(UIColor.systemGray))
Text(aPack.randomPushNotificationStrings().body)
.font(.body)
.foregroundColor(Color(UIColor.systemGray))
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(personalityPack == aPack ? theme.currentTheme.bgColor : .clear)
.padding(5)
)
.onTapGesture {
if aPack.rawValue == PersonalityPack.Rude.rawValue && !showNSFW {
showOver18Alert = true
EventLogger.log(event: "show_over_18_alert")
} else {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
personalityPack = aPack
EventLogger.log(event: "change_personality_pack", withData: ["pack_title": aPack.title()])
LocalNotification.rescheduleNotifiations()
}
}
.blur(radius: aPack.rawValue == PersonalityPack.Rude.rawValue && !showNSFW ? 5 : 0)
.alert(isPresented: $showOver18Alert) {
let primaryButton = Alert.Button.default(Text(String(localized: "customize_view_over18alert_ok"))) {
showNSFW = true
}
let secondaryButton = Alert.Button.cancel(Text(String(localized: "customize_view_over18alert_no"))) {
showNSFW = false
}
return Alert(title: Text(String(localized: "customize_view_over18alert_title")),
message: Text(String(localized: "customize_view_over18alert_body")),
primaryButton: primaryButton,
secondaryButton: secondaryButton)
}
if aPack.rawValue != (PersonalityPack.allCases.sorted(by: { $0.rawValue > $1.rawValue }).first?.rawValue) ?? 0 {
Divider()
}
}
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct PersonalityPackPickerView_Previews: PreviewProvider {
static var previews: some View {
PersonalityPackPickerView()
}
}

View File

@@ -0,0 +1,77 @@
//
// ShapePickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct ShapePickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@State var shapeRefreshToggleThing: Bool = false
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
@AppStorage(UserDefaultsStore.Keys.shape.rawValue, store: GroupUserDefaults.groupDefaults) private var shape: BGShape = .circle
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
HStack {
Spacer()
Text(shapeRefreshToggleThing.description.localizedLowercase)
.hidden()
Image(systemName: "arrow.triangle.2.circlepath.circle")
.resizable()
.frame(width: 20, height: 20, alignment: .trailing)
.foregroundColor(Color(UIColor.systemGray))
.onTapGesture {
shapeRefreshToggleThing.toggle()
}
}
Spacer()
}
.padding()
VStack(alignment:.leading) {
Text(String(localized: "customize_view_view_pick_shape"))
.padding([.leading])
.foregroundColor(textColor)
Divider()
HStack {
ForEach(BGShape.allCases, id: \.rawValue) { ashape in
ashape.view(withText: Text("20"),
bgColor: moodTint.color(forMood: Mood.allValues.randomElement()!), textColor: textColor)
.frame(height: 50)
.frame(minWidth: 0, maxWidth: .infinity)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
shape = ashape
EventLogger.log(event: "change_mood_shape_id", withData: ["id": shape.rawValue])
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(shape == ashape ? theme.currentTheme.bgColor : .clear)
.padding(-5)
)
}
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct ShapePickerView_Previews: PreviewProvider {
static var previews: some View {
ShapePickerView()
}
}

View File

@@ -0,0 +1,30 @@
//
// TextColorPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct TextColorPickerView: 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
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
ColorPicker(String(localized: "customize_view_view_text_color"), selection: $textColor)
.padding()
.foregroundColor(textColor)
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct TextColorPickerView_Previews: PreviewProvider {
static var previews: some View {
TextColorPickerView()
}
}

View File

@@ -0,0 +1,59 @@
//
// ThemePicker.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct ThemePickerView: 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
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
HStack {
Spacer()
ForEach(Theme.allCases, id:\.rawValue) { aTheme in
Button(action: {
theme = aTheme
EventLogger.log(event: "change_theme_id", withData: ["id": aTheme.rawValue])
}, label: {
VStack {
aTheme.currentTheme.preview
.overlay(
Circle()
.stroke(Color(UIColor.systemGray), style: StrokeStyle(lineWidth: 2))
)
Text(aTheme.title)
.foregroundColor(textColor)
.font(.body)
}
})
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(theme == aTheme ? theme.currentTheme.bgColor : .clear)
.padding(-5)
)
Spacer()
}
}
.padding(.top)
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct ThemePickerView_Previews: PreviewProvider {
static var previews: some View {
ThemePickerView()
}
}

View File

@@ -0,0 +1,125 @@
//
// TintPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct TintPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
@StateObject private var customMoodTint = UserDefaultsStore.getCustomMoodTint()
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ForEach(MoodTints.defaultOptions, id: \.rawValue) { tint in
HStack {
ForEach(Mood.allValues, id: \.self) { mood in
Circle()
.frame(width: 35, height: 35)
.foregroundColor(
tint.color(forMood: mood)
)
}
.frame(minWidth: 0, maxWidth: .infinity)
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(moodTint == tint ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
moodTint = tint
EventLogger.log(event: "change_mood_tint_id", withData: ["id": tint.rawValue])
}
Divider()
}
ZStack {
Color.clear
Rectangle()
.frame(height: 35)
.frame(minWidth: 0, maxWidth: .infinity)
.foregroundColor(.clear)
.contentShape(Rectangle())
.onTapGesture {
moodTint = .Custom
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
}
HStack {
ColorPicker("", selection: $customMoodTint.colorOne)
.onChange(of: customMoodTint.colorOne, perform: { _ in
saveCustomMoodTint()
})
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
ColorPicker("", selection: $customMoodTint.colorTwo)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorTwo, perform: { _ in
saveCustomMoodTint()
})
ColorPicker("", selection: $customMoodTint.colorThree)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorThree, perform: { _ in
saveCustomMoodTint()
})
ColorPicker("", selection: $customMoodTint.colorFour)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorFour, perform: { _ in
saveCustomMoodTint()
})
ColorPicker("", selection: $customMoodTint.colorFive)
.labelsHidden()
.frame(minWidth: 0, maxWidth: .infinity)
.onChange(of: customMoodTint.colorFive, perform: { _ in
saveCustomMoodTint()
})
}
.background(
Color.clear
)
}
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(moodTint == .Custom ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private func saveCustomMoodTint() {
UserDefaultsStore.saveCustomMoodTint(customTint: customMoodTint)
moodTint = .Custom
EventLogger.log(event: "change_mood_tint_id", withData: ["id": MoodTints.Custom.rawValue])
customMoodTintUpdateNumber += 1
}
}
struct TintPickerView_Previews: PreviewProvider {
static var previews: some View {
TintPickerView()
}
}

View File

@@ -15,8 +15,6 @@ struct DayViewConstants {
}
struct DayView: View {
@EnvironmentObject var daysFilter: DaysFilterClass
@Environment(\.managedObjectContext) private var viewContext
@AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true
@@ -47,6 +45,7 @@ struct DayView: View {
@State private var showTodayInput = true
@State private var showUpdateEntryAlert = false
@StateObject private var onboardingData = OnboardingDataDataManager.shared
@StateObject private var filteredDays = DaysFilterClass.shared
// MARK: header properties
@State private var headerHeight: CGFloat = DayViewConstants.maxHeaderHeight
@@ -54,10 +53,10 @@ struct DayView: View {
@State private var headerOpacity: Double = 1.0
//
@ObservedObject var viewModel: DayViewViewModel = DayViewViewModel(addMonthStartWeekdayPadding: false)
@ObservedObject var viewModel: DayViewViewModel
var body: some View {
mainView
mainView
.onAppear(perform: {
EventLogger.log(event: "show_home_view")
})
@@ -149,7 +148,7 @@ struct DayView: View {
.background(
theme.currentTheme.secondaryBGColor
)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
Spacer()
}
@@ -270,7 +269,7 @@ struct DayView: View {
yOffset: value)
}
}
.cornerRadius(10, corners: [.topLeft, .topRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight])
}
func getBackEntries() -> [MoodEntry] {
@@ -300,7 +299,7 @@ extension DayView {
ForEach(entries.sorted(by: {
return $0.forDate! > $1.forDate!
}), id: \.self) { entry in
if daysFilter.currentFilters.contains(Int(entry.weekDay)) {
if filteredDays.currentFilters.contains(Int(entry.weekDay)) {
EntryListView(entry: entry)
.contentShape(Rectangle())
.onTapGesture(perform: {

View File

@@ -26,7 +26,7 @@ struct EmptyHomeView: View {
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}

View File

@@ -27,7 +27,7 @@ struct GraphView: View {
BarChartDataEntry(x: 5, y: Double(Int.random(in: 0...10)))
])
}
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.padding()
ZStack {
@@ -40,7 +40,7 @@ struct GraphView: View {
BarChartDataEntry(x: 5, y: Double(Int.random(in: 0...10)))
])
}
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.padding()
}
@@ -54,7 +54,7 @@ struct GraphView: View {
BarChartDataEntry(x: 5, y: Double(Int.random(in: 0...10)))
])
}
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.padding()
ZStack {
@@ -67,7 +67,7 @@ struct GraphView: View {
BarChartDataEntry(x: 5, y: Double(Int.random(in: 0...10)))
])
}
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.padding()
}
}

View File

@@ -8,61 +8,61 @@
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
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
let onboardingData = OnboardingDataDataManager.shared.savedOnboardingData
let dayView: DayView
let monthView: MonthView
let yearView: YearView
let customizeView: CustomizeView
var body: some View {
TabView {
DayView()
Self._printChanges()
return TabView {
dayView
.tabItem {
Label(String(localized: "content_view_tab_main"), systemImage: "list.dash")
}
MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true))
monthView
.tabItem {
Label(String(localized: "content_view_tab_month"), systemImage: "calendar")
}
YearView()
yearView
.tabItem {
Label(String(localized: "content_view_tab_filter"), systemImage: "line.3.horizontal.decrease.circle")
}
CustomizeView()
customizeView
.tabItem {
Label(String(localized: "content_view_tab_customize"), systemImage: "pencil")
}
}
.accentColor(moodTint.color(forMood: .average))
.sheet(isPresented: $needsOnboarding, onDismiss: {
}, content: {
.sheet(isPresented: $needsOnboarding, onDismiss: { }, content: {
OnboardingMain(onboardingData: onboardingData,
updateBoardingDataClosure: { onboardingData in
needsOnboarding = false
OnboardingDataDataManager.shared.updateOnboardingData(onboardingData: onboardingData)
})
})
.onAppear(perform: {
switch theme {
case .system:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
case .iFeel:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
case .dark:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .dark
case .light:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .light
}
.onAppear(perform: {
switch theme {
case .system:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
case .iFeel:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
case .dark:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .dark
case .light:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .light
}
})
.onChange(of: theme, perform: { value in
.onChange(of: theme, perform: { value in
switch theme {
case .system:
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
@@ -79,6 +79,9 @@ struct MainTabView: View {
struct MainTabView_Previews: PreviewProvider {
static var previews: some View {
MainTabView()
MainTabView(dayView: DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false)),
monthView: MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true)),
yearView: YearView(viewModel: YearViewModel()),
customizeView: CustomizeView())
}
}

View File

@@ -8,8 +8,6 @@
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
@@ -28,7 +26,8 @@ struct MonthView: View {
@StateObject private var selectedDetail = StupidAssDetailViewObservableObject()
@State private var showingSheet = false
@StateObject private var onboardingData = OnboardingDataDataManager.shared
@StateObject private var filteredDays = DaysFilterClass.shared
class StupidAssDetailViewObservableObject: ObservableObject {
@Published var fuckingWrapped: MonthDetailView? = nil
@Published var showFuckingSheet = false
@@ -204,7 +203,7 @@ extension MonthView {
Divider()
LazyVGrid(columns: columns, spacing: 15) {
ForEach(entries, id: \.self) { entry in
if daysFilter.currentFilters.contains(Int(entry.weekDay)) {
if filteredDays.currentFilters.contains(Int(entry.weekDay)) {
shape.view(withText: Text(""),
bgColor: entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood),
textColor: .clear)

View File

@@ -175,7 +175,7 @@ struct SettingsView: View {
}
}
.frame(minWidth: 0, maxWidth: .infinity)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var addTestDataCell: some View {
@@ -190,7 +190,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var clearDB: some View {
@@ -205,7 +205,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var whyBackgroundMode: some View {
@@ -229,7 +229,7 @@ struct SettingsView: View {
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var showOnboardingButton: some View {
@@ -245,7 +245,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var cloudKitEnable: some View {
@@ -266,7 +266,7 @@ struct SettingsView: View {
.padding(.bottom)
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var cloudKitStatus: some View {
@@ -281,7 +281,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var canDelete: some View {
@@ -298,7 +298,7 @@ struct SettingsView: View {
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var exportData: some View {
@@ -314,7 +314,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var importData: some View {
@@ -330,7 +330,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var randomIcons: some View {
@@ -461,7 +461,7 @@ struct SettingsView: View {
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}

View File

@@ -123,7 +123,7 @@ struct SharingListView: View {
}
}
.frame(height: 88)
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.scaledToFill()
.clipped()
.contentShape(Path(CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 88)))

View File

@@ -98,7 +98,7 @@ struct SwitchableView: View {
theme.currentTheme.secondaryBGColor
)
.contentShape(Rectangle())
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
.padding(.bottom, 30)
.onTapGesture {
viewType = viewType.next()

View File

@@ -9,8 +9,6 @@ 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
@@ -24,7 +22,8 @@ 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 = YearViewModel()
@StateObject public var viewModel: YearViewModel
@StateObject private var filteredDays = DaysFilterClass.shared
//[
// 2001: [0: [], 1: [], 2: []],
// 2002: [0: [], 1: [], 2: []]
@@ -79,7 +78,7 @@ struct YearView: View {
let yearEntries = PersistenceController.shared.getData(startDate: firstOfYear,
endDate: lastOfYear,
includedDays: daysFilter.currentFilters)
includedDays: filteredDays.currentFilters)
Text(String(yearKey))
.font(.title)
.foregroundColor(textColor)
@@ -144,14 +143,14 @@ struct YearView: View {
}
private struct monthGridView: View {
@EnvironmentObject var daysFilter: DaysFilterClass
@StateObject private var filteredDays = DaysFilterClass.shared
let monthData: [DayChartView]
var body: some View {
VStack {
ForEach(monthData, id: \.self) { view in
if daysFilter.currentFilters.contains(view.weekDay) {
if filteredDays.currentFilters.contains(view.weekDay) {
view
} else {
view.filteredDaysView
@@ -165,9 +164,9 @@ struct YearView: View {
struct YearView_Previews: PreviewProvider {
static var previews: some View {
Group {
YearView()
YearView(viewModel: YearViewModel())
YearView()
YearView(viewModel: YearViewModel())
.preferredColorScheme(.dark)
}
}

View File

@@ -22,6 +22,10 @@ class YearViewModel: ObservableObject {
}
init() {
updateData()
}
private func updateData() {
let filteredEntries = PersistenceController.shared.getData(startDate: Date(timeIntervalSince1970: 0),
endDate: Date(),
includedDays: selectedDays)