build out enable delete option but cant use b/c list view is not a list
re-arrange the content view
This commit is contained in:
@@ -12,6 +12,7 @@ class UserDefaultsStore {
|
|||||||
case savedOnboardingData
|
case savedOnboardingData
|
||||||
case needsOnboarding
|
case needsOnboarding
|
||||||
case useCloudKit
|
case useCloudKit
|
||||||
|
case deleteEnable
|
||||||
}
|
}
|
||||||
|
|
||||||
static func getOnboarding() -> OnboardingData {
|
static func getOnboarding() -> OnboardingData {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Charts
|
|||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@Environment(\.managedObjectContext) private var viewContext
|
@Environment(\.managedObjectContext) private var viewContext
|
||||||
@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
|
||||||
|
|
||||||
@State private var showingSheet = false
|
@State private var showingSheet = false
|
||||||
@State private var showTodayInput = true
|
@State private var showTodayInput = true
|
||||||
@@ -155,6 +156,23 @@ struct ContentView: View {
|
|||||||
ForEach(months.sorted(by: {
|
ForEach(months.sorted(by: {
|
||||||
$0.key > $1.key
|
$0.key > $1.key
|
||||||
}), id: \.key) { month, entries in
|
}), id: \.key) { month, entries in
|
||||||
|
monthListView(month: month, year: year, entries: entries)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GeometryReader { proxy in
|
||||||
|
let offset = proxy.frame(in: .named("scroll")).minY
|
||||||
|
Color.clear.preference(key: ViewOffsetKey.self, value: offset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.coordinateSpace(name: "scroll")
|
||||||
|
.onPreferenceChange(ViewOffsetKey.self) { value in
|
||||||
|
calculateHeight(minHeight: 88, maxHeight: 180, yOffset: value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func monthListView(month: Int, year: Int, entries: [MoodEntry]) -> some View {
|
||||||
Section(header:
|
Section(header:
|
||||||
HStack{
|
HStack{
|
||||||
Text(monthName(fromMonthInt: month))
|
Text(monthName(fromMonthInt: month))
|
||||||
@@ -173,24 +191,14 @@ struct ContentView: View {
|
|||||||
selectedEntry = entry
|
selectedEntry = entry
|
||||||
showUpdateEntryAlert = true
|
showUpdateEntryAlert = true
|
||||||
})
|
})
|
||||||
}.onDelete(perform: { offsets in
|
|
||||||
withAnimation {
|
|
||||||
viewModel.delete(offsets: offsets, inMonth: month, inYear: year)
|
|
||||||
}
|
}
|
||||||
})
|
// if deleteEnabled {
|
||||||
}
|
// .onDelete(perform: { offsets in
|
||||||
}
|
// withAnimation {
|
||||||
}
|
// viewModel.delete(offsets: offsets, inMonth: month, inYear: year)
|
||||||
}
|
// }
|
||||||
GeometryReader { proxy in
|
// })
|
||||||
let offset = proxy.frame(in: .named("scroll")).minY
|
// }
|
||||||
Color.clear.preference(key: ViewOffsetKey.self, value: offset)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.coordinateSpace(name: "scroll")
|
|
||||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
|
||||||
calculateHeight(minHeight: 88, maxHeight: 180, yOffset: value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,13 +282,8 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var mainView: some View {
|
private var mainView: some View {
|
||||||
ZStack {
|
VStack {
|
||||||
BGView().equatable()
|
|
||||||
|
|
||||||
VStack{
|
|
||||||
settingsButtonView
|
settingsButtonView
|
||||||
.padding(.top, 50)
|
|
||||||
|
|
||||||
if viewModel.hasNoData {
|
if viewModel.hasNoData {
|
||||||
Spacer()
|
Spacer()
|
||||||
emptyView
|
emptyView
|
||||||
@@ -299,15 +302,14 @@ struct ContentView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.opacity(1 - headerOpacity)
|
.opacity(1 - headerOpacity)
|
||||||
|
}
|
||||||
|
.frame(height: headerHeight + 20)
|
||||||
listView
|
listView
|
||||||
.padding([.leading, .trailing])
|
.padding([.leading, .trailing])
|
||||||
.padding(.top, headerHeight+10)
|
|
||||||
.padding(.bottom, 60)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}.background(
|
||||||
|
BGView().equatable()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ struct SettingsView: View {
|
|||||||
@ObservedObject var syncMonitor = SyncMonitor.shared
|
@ObservedObject var syncMonitor = SyncMonitor.shared
|
||||||
|
|
||||||
@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
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(UIColor.secondarySystemBackground)
|
Color(UIColor.secondarySystemBackground)
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
|
Group {
|
||||||
closeButtonView
|
closeButtonView
|
||||||
.padding()
|
.padding()
|
||||||
cloudKitEnable
|
cloudKitEnable
|
||||||
@@ -40,7 +42,7 @@ struct SettingsView: View {
|
|||||||
if useCloudKit {
|
if useCloudKit {
|
||||||
cloudKitStatus
|
cloudKitStatus
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
@@ -230,6 +232,19 @@ 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 canDelete: some View {
|
||||||
|
ZStack {
|
||||||
|
Color(UIColor.systemBackground)
|
||||||
|
VStack {
|
||||||
|
Toggle(String(localized: "settings_use_delete_enable"),
|
||||||
|
isOn: $deleteEnabled)
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SettingsView_Previews: PreviewProvider {
|
struct SettingsView_Previews: PreviewProvider {
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
"settings_view_show_onboarding" = "Show onboarding";
|
"settings_view_show_onboarding" = "Show onboarding";
|
||||||
"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";
|
||||||
|
|
||||||
"mood_value_great" = "Great";
|
"mood_value_great" = "Great";
|
||||||
"mood_value_good" = "Good";
|
"mood_value_good" = "Good";
|
||||||
|
|||||||
Reference in New Issue
Block a user