fix issue with two votes on the same date
fix issue with header not showing correct vote date split logic for Persistence into different files create class that deals with voting time, existing votes, and what should be shown based on that
This commit is contained in:
@@ -25,7 +25,7 @@ struct AddMoodHeaderView: View {
|
||||
Color(theme.currentTheme.secondaryBGColor)
|
||||
|
||||
VStack {
|
||||
Text(self.getTitle())
|
||||
Text(ShowBasedOnVoteLogics.getVotingTitle())
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.label))
|
||||
.padding()
|
||||
@@ -56,48 +56,8 @@ struct AddMoodHeaderView: View {
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
}
|
||||
|
||||
private func getTitle() -> String {
|
||||
//if this is being shown we're missing an entry
|
||||
// voting time is noon
|
||||
// vote for current day
|
||||
// today at 11 am -> How as yesterday
|
||||
// today at 1 pm -> How is today
|
||||
// vote for previous day
|
||||
// today at 11 am -> How as 2 days ago
|
||||
// today at 1 pm -> How was yesterday
|
||||
|
||||
let latestVoteUnLocked = UserDefaultsStore.getOnboarding().ableToVoteBasedOnCurentTime()
|
||||
let inputDay = UserDefaultsStore.getOnboarding().inputDay
|
||||
|
||||
switch (latestVoteUnLocked, inputDay) {
|
||||
case (true, .Previous):
|
||||
return "how was yesterday"
|
||||
case (true, .Today):
|
||||
return "how is today"
|
||||
case (false, .Previous):
|
||||
return "how was two days ago"
|
||||
case (false, .Today):
|
||||
return "how as yesterday"
|
||||
}
|
||||
}
|
||||
|
||||
private func addItem(withMood mood: Mood) {
|
||||
let latestVoteUnLocked = UserDefaultsStore.getOnboarding().ableToVoteBasedOnCurentTime()
|
||||
let inputDay = UserDefaultsStore.getOnboarding().inputDay
|
||||
|
||||
var date: Date?
|
||||
|
||||
switch (latestVoteUnLocked, inputDay) {
|
||||
case (true, .Previous):
|
||||
date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||
case (true, .Today):
|
||||
date = Date()
|
||||
case (false, .Previous):
|
||||
date = Calendar.current.date(byAdding: .day, value: -2, to: Date())!
|
||||
case (false, .Today):
|
||||
date = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||
}
|
||||
if let date = date {
|
||||
if let date = ShowBasedOnVoteLogics.dateForHeaderVote() {
|
||||
addItemHeaderClosure(mood, date)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user