no votes screen
This commit is contained in:
@@ -12,6 +12,10 @@ class ContentModeViewModel: ObservableObject {
|
|||||||
@Published var grouped = [Int: [Int: [MoodEntry]]]()
|
@Published var grouped = [Int: [Int: [MoodEntry]]]()
|
||||||
@Published public private(set) var savedOnboardingData = UserDefaultsStore.getOnboarding()
|
@Published public private(set) var savedOnboardingData = UserDefaultsStore.getOnboarding()
|
||||||
|
|
||||||
|
var hasNoData: Bool {
|
||||||
|
grouped.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
PersistenceController.shared.switchContainerListeners.append {
|
PersistenceController.shared.switchContainerListeners.append {
|
||||||
self.getGroupedData()
|
self.getGroupedData()
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ struct AddMoodHeaderView: View {
|
|||||||
|
|
||||||
let addItemHeaderClosure: ((Mood, Date) -> Void)
|
let addItemHeaderClosure: ((Mood, Date) -> Void)
|
||||||
|
|
||||||
|
var overrideDay: DayOptions?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(UIColor.systemBackground)
|
Color(UIColor.systemBackground)
|
||||||
@@ -50,22 +52,40 @@ struct AddMoodHeaderView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func getTitle() -> String {
|
private func getTitle() -> String {
|
||||||
switch savedOnboardingData.inputDay {
|
if let overrideDay = overrideDay {
|
||||||
|
switch overrideDay {
|
||||||
case .Today:
|
case .Today:
|
||||||
return String(localized: "add_mood_header_view_title_today")
|
return String(localized: "add_mood_header_view_title_today")
|
||||||
case .Previous:
|
case .Previous:
|
||||||
return String(localized: "add_mood_header_view_title_yesterday")
|
return String(localized: "add_mood_header_view_title_yesterday")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch savedOnboardingData.inputDay {
|
||||||
|
case .Today:
|
||||||
|
return String(localized: "add_mood_header_view_title_today")
|
||||||
|
case .Previous:
|
||||||
|
return String(localized: "add_mood_header_view_title_yesterday")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addItem(withMood mood: Mood) {
|
private func addItem(withMood mood: Mood) {
|
||||||
switch savedOnboardingData.inputDay {
|
if let overrideDay = overrideDay {
|
||||||
case .Today:
|
switch overrideDay {
|
||||||
addItemHeaderClosure(mood, Date())
|
case .Today:
|
||||||
case .Previous:
|
addItemHeaderClosure(mood, Date())
|
||||||
let date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
case .Previous:
|
||||||
addItemHeaderClosure(mood, date)
|
let date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||||
|
addItemHeaderClosure(mood, date)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch savedOnboardingData.inputDay {
|
||||||
|
case .Today:
|
||||||
|
addItemHeaderClosure(mood, Date())
|
||||||
|
case .Previous:
|
||||||
|
let date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||||
|
addItemHeaderClosure(mood, date)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,6 +205,32 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var emptyView: some View {
|
||||||
|
ZStack {
|
||||||
|
Color(UIColor.systemBackground)
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
Text(String(localized: "content_view_empty_title"))
|
||||||
|
.font(.title)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.padding()
|
||||||
|
|
||||||
|
Text(String(localized: "content_view_empty_title"))
|
||||||
|
.font(.body)
|
||||||
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
.padding()
|
||||||
|
AddMoodHeaderView(addItemHeaderClosure: { (mood, date) in
|
||||||
|
withAnimation {
|
||||||
|
viewModel.add(mood: mood, forDate: date)
|
||||||
|
}
|
||||||
|
}, overrideDay: viewModel.shouldShowVotingHeader() ? .Today : .Previous)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||||
|
.padding()
|
||||||
|
}
|
||||||
|
|
||||||
private var mainView: some View {
|
private var mainView: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
|
|
||||||
@@ -213,10 +239,14 @@ struct ContentView: View {
|
|||||||
VStack{
|
VStack{
|
||||||
settingsButtonView
|
settingsButtonView
|
||||||
.padding(.top, 50)
|
.padding(.top, 50)
|
||||||
|
if viewModel.hasNoData {
|
||||||
headerView
|
Spacer()
|
||||||
|
emptyView
|
||||||
listView
|
Spacer()
|
||||||
|
} else {
|
||||||
|
headerView
|
||||||
|
listView
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(.bottom)
|
.padding(.bottom)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
"content_view_fill_in_missing_entry" = "Fill in missing entry";
|
"content_view_fill_in_missing_entry" = "Fill in missing entry";
|
||||||
"content_view_fill_in_missing_entry_cancel" = "Cancel";
|
"content_view_fill_in_missing_entry_cancel" = "Cancel";
|
||||||
"content_view_header_title" = "Past %d days";
|
"content_view_header_title" = "Past %d days";
|
||||||
|
"content_view_empty_title" = "You aint done shit";
|
||||||
|
"content_view_empty_body" = "Fucking vote or something?!?!? How the fuck was yesterday?";
|
||||||
|
|
||||||
"filter_view_total" = "Total";
|
"filter_view_total" = "Total";
|
||||||
"filter_view_show_filters" = "Show Filters";
|
"filter_view_show_filters" = "Show Filters";
|
||||||
|
|||||||
Reference in New Issue
Block a user