everything changed
This commit is contained in:
@@ -18,17 +18,13 @@ import SwiftUI
|
||||
// today at 11 am -> How as 2 days ago
|
||||
// today at 1 pm -> How was yesterday
|
||||
class ShowBasedOnVoteLogics {
|
||||
private static var currentVoting: (passTimeToVote: Bool, dayOptions: DayOptions) {
|
||||
let passedTimeToVote = UserDefaultsStore.getOnboarding().ableToVoteBasedOnCurentTime()
|
||||
let inputDay = UserDefaultsStore.getOnboarding().inputDay
|
||||
static func isMissingCurrentVote(onboardingData: OnboardingData) -> Bool {
|
||||
let passedTimeToVote = onboardingData.ableToVoteBasedOnCurentTime()
|
||||
let inputDay = onboardingData.inputDay
|
||||
|
||||
return (passedTimeToVote, inputDay)
|
||||
}
|
||||
|
||||
static func isMissingCurrentVote() -> Bool {
|
||||
var startDate: Date?
|
||||
|
||||
switch (currentVoting.passTimeToVote, currentVoting.dayOptions) {
|
||||
|
||||
switch (passedTimeToVote, inputDay) {
|
||||
case (true, .Previous):
|
||||
// if we're passed time to vote and the voting type is previous - last vote should be -1
|
||||
startDate = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||
@@ -57,8 +53,11 @@ class ShowBasedOnVoteLogics {
|
||||
return entries < 1
|
||||
}
|
||||
|
||||
static func getVotingTitle() -> String {
|
||||
switch (currentVoting.passTimeToVote, currentVoting.dayOptions) {
|
||||
static func getVotingTitle(onboardingData: OnboardingData) -> String {
|
||||
let passedTimeToVote = onboardingData.ableToVoteBasedOnCurentTime()
|
||||
let inputDay = onboardingData.inputDay
|
||||
|
||||
switch (passedTimeToVote, inputDay) {
|
||||
case (true, .Previous):
|
||||
// if we're passed time to vote and the voting type is previous - last vote should be -1
|
||||
return "how was yesterday"
|
||||
@@ -67,7 +66,7 @@ class ShowBasedOnVoteLogics {
|
||||
return "how is today"
|
||||
case (false, .Previous):
|
||||
// if we're passed time to vote and the voting type is previous - last vote should be -2
|
||||
let lastDayVoteShouldExist = ShowBasedOnVoteLogics.getLastDateVoteShouldExist()
|
||||
let lastDayVoteShouldExist = ShowBasedOnVoteLogics.getLastDateVoteShouldExist(onboardingData: onboardingData)
|
||||
return "how was \(Random.weekdayName(fromDate: lastDayVoteShouldExist))"
|
||||
case (false, .Today):
|
||||
// if we're passed time to vote and the voting type is previous - last vote should be -1
|
||||
@@ -75,10 +74,13 @@ class ShowBasedOnVoteLogics {
|
||||
}
|
||||
}
|
||||
|
||||
static func dateForHeaderVote() -> Date? {
|
||||
static func dateForHeaderVote(onboardingData: OnboardingData) -> Date? {
|
||||
let passedTimeToVote = onboardingData.ableToVoteBasedOnCurentTime()
|
||||
let inputDay = onboardingData.inputDay
|
||||
|
||||
var date: Date?
|
||||
|
||||
switch (currentVoting.passTimeToVote, currentVoting.dayOptions) {
|
||||
switch (passedTimeToVote, inputDay) {
|
||||
case (true, .Previous):
|
||||
// if we're passed time to vote and the voting type is previous - last vote should be -1
|
||||
date = Calendar.current.date(byAdding: .day, value: -1, to: Date())
|
||||
@@ -100,10 +102,13 @@ class ShowBasedOnVoteLogics {
|
||||
return nil
|
||||
}
|
||||
|
||||
static func getLastDateVoteShouldExist() -> Date {
|
||||
static func getLastDateVoteShouldExist(onboardingData: OnboardingData) -> Date {
|
||||
let passedTimeToVote = onboardingData.ableToVoteBasedOnCurentTime()
|
||||
let inputDay = onboardingData.inputDay
|
||||
|
||||
var endDate: Date?
|
||||
|
||||
switch (currentVoting.passTimeToVote, currentVoting.dayOptions) {
|
||||
switch (passedTimeToVote, inputDay) {
|
||||
case (true, .Previous):
|
||||
// if we're passed time to vote and the voting type is previous - last vote should -1
|
||||
endDate = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||||
|
||||
Reference in New Issue
Block a user