remove filters from filter view
This commit is contained in:
@@ -13,7 +13,6 @@ struct FilterView: View {
|
|||||||
let months = [(0, "J"), (1, "F"), (2,"M"), (3,"A"), (4,"M"), (5, "J"), (6,"J"), (7,"A"), (8,"S"), (9,"O"), (10, "N"), (11,"D")]
|
let months = [(0, "J"), (1, "F"), (2,"M"), (3,"A"), (4,"M"), (5, "J"), (6,"J"), (7,"A"), (8,"S"), (9,"O"), (10, "N"), (11,"D")]
|
||||||
|
|
||||||
@State private var toggle = true
|
@State private var toggle = true
|
||||||
@State private var showFilter = false
|
|
||||||
|
|
||||||
@FetchRequest(
|
@FetchRequest(
|
||||||
sortDescriptors: [NSSortDescriptor(keyPath: \MoodEntry.forDate, ascending: false)],
|
sortDescriptors: [NSSortDescriptor(keyPath: \MoodEntry.forDate, ascending: false)],
|
||||||
@@ -45,10 +44,8 @@ struct FilterView: View {
|
|||||||
]
|
]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
ScrollView {
|
||||||
VStack {
|
VStack {
|
||||||
filterButon
|
|
||||||
.padding([.leading, .trailing, .top])
|
|
||||||
|
|
||||||
statsView
|
statsView
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 90, maxHeight: 90)
|
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 90, maxHeight: 90)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
@@ -58,15 +55,12 @@ struct FilterView: View {
|
|||||||
.font(.title2)
|
.font(.title2)
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
|
|
||||||
if showFilter {
|
|
||||||
filterView
|
|
||||||
}
|
|
||||||
|
|
||||||
gridView
|
gridView
|
||||||
.onAppear(perform: {
|
.onAppear(perform: {
|
||||||
self.viewModel.filterEntries(startDate: Date(timeIntervalSince1970: 0), endDate: Date())
|
self.viewModel.filterEntries(startDate: Date(timeIntervalSince1970: 0), endDate: Date())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.padding(.bottom, 5)
|
.padding(.bottom, 5)
|
||||||
.background(
|
.background(
|
||||||
theme.currentTheme.bg
|
theme.currentTheme.bg
|
||||||
@@ -74,21 +68,6 @@ struct FilterView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var filterButon: some View {
|
|
||||||
Button(action: {
|
|
||||||
withAnimation{
|
|
||||||
showFilter.toggle()
|
|
||||||
}
|
|
||||||
}, label: {
|
|
||||||
Text(showFilter ? String(localized: "filter_view_hide_filters") : String(localized: "filter_view_show_filters"))
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.frame(height: 44)
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
.background(theme.currentTheme.secondaryBGColor)
|
|
||||||
.cornerRadius(10)
|
|
||||||
}).frame(maxWidth: .infinity)
|
|
||||||
}
|
|
||||||
|
|
||||||
struct StatsSubView: View {
|
struct StatsSubView: View {
|
||||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||||
@@ -127,75 +106,6 @@ struct FilterView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var filterView: some View {
|
|
||||||
VStack {
|
|
||||||
VStack {
|
|
||||||
ZStack {
|
|
||||||
theme.currentTheme.secondaryBGColor
|
|
||||||
DatePicker(
|
|
||||||
String(localized: "filter_view_begin_date"),
|
|
||||||
selection: $viewModel.entryStartDate,
|
|
||||||
displayedComponents: [.date]
|
|
||||||
).onChange(of: viewModel.entryStartDate, perform: { value in
|
|
||||||
viewModel.filterEntries(startDate: viewModel.entryStartDate, endDate: viewModel.entryEndDate)
|
|
||||||
})
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 44, maxHeight: 44)
|
|
||||||
.cornerRadius(10)
|
|
||||||
.padding([.leading, .trailing])
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
.accentColor(textColor)
|
|
||||||
|
|
||||||
ZStack {
|
|
||||||
theme.currentTheme.secondaryBGColor
|
|
||||||
DatePicker(
|
|
||||||
String(localized: "filter_view_end_date"),
|
|
||||||
selection: $viewModel.entryEndDate,
|
|
||||||
displayedComponents: [.date]
|
|
||||||
).onChange(of: viewModel.entryStartDate, perform: { value in
|
|
||||||
viewModel.filterEntries(startDate: viewModel.entryStartDate, endDate: viewModel.entryEndDate)
|
|
||||||
})
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 44, maxHeight: 44)
|
|
||||||
.cornerRadius(10)
|
|
||||||
.padding([.leading, .trailing])
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
.accentColor(textColor)
|
|
||||||
|
|
||||||
ZStack {
|
|
||||||
theme.currentTheme.secondaryBGColor
|
|
||||||
HStack {
|
|
||||||
Spacer()
|
|
||||||
ForEach(weekdays.indices, id: \.self) { dayIdx in
|
|
||||||
let day = String(weekdays[dayIdx].0)
|
|
||||||
let value = weekdays[dayIdx].1
|
|
||||||
|
|
||||||
Button(day.capitalized, action: {
|
|
||||||
if let index = viewModel.selectedDays.firstIndex(of: value) {
|
|
||||||
viewModel.selectedDays.remove(at: index)
|
|
||||||
} else {
|
|
||||||
viewModel.selectedDays.append(value)
|
|
||||||
}
|
|
||||||
viewModel.filterEntries(startDate: viewModel.entryStartDate,
|
|
||||||
endDate: viewModel.entryEndDate)
|
|
||||||
})
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.foregroundColor(viewModel.selectedDays.contains(value) || viewModel.selectedDays.isEmpty ? .green : .red)
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 44, maxHeight: 44)
|
|
||||||
.cornerRadius(10)
|
|
||||||
.padding([ .leading, .trailing])
|
|
||||||
}
|
|
||||||
filterButon
|
|
||||||
.padding([.leading, .trailing, .top])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var monthsHeader: some View {
|
private var monthsHeader: some View {
|
||||||
LazyVGrid(columns: columns, spacing: 0) {
|
LazyVGrid(columns: columns, spacing: 0) {
|
||||||
ForEach(months, id: \.self.0) { item in
|
ForEach(months, id: \.self.0) { item in
|
||||||
@@ -213,7 +123,6 @@ struct FilterView: View {
|
|||||||
.padding([.leading, .trailing])
|
.padding([.leading, .trailing])
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
ScrollView {
|
|
||||||
ForEach(Array(self.viewModel.data.keys.sorted(by: >)), id: \.self) { yearKey in
|
ForEach(Array(self.viewModel.data.keys.sorted(by: >)), id: \.self) { yearKey in
|
||||||
let yearData = self.viewModel.data[yearKey]!
|
let yearData = self.viewModel.data[yearKey]!
|
||||||
Text(String(yearKey))
|
Text(String(yearKey))
|
||||||
@@ -225,12 +134,6 @@ struct FilterView: View {
|
|||||||
)
|
)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.simultaneousGesture(DragGesture().onChanged({ _ in
|
|
||||||
withAnimation{
|
|
||||||
showFilter = false
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
.padding([.top, .leading, .trailing])
|
.padding([.top, .leading, .trailing])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user