everything changed

This commit is contained in:
Trey t
2022-02-20 14:33:58 -06:00
parent 1cf38cb854
commit 0035f61204
50 changed files with 2155 additions and 875 deletions

View File

@@ -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())!