make reading tuple easier

This commit is contained in:
Trey t
2022-04-11 23:09:47 -04:00
parent 26fea28b26
commit 1cfb4c1b2e

View File

@@ -30,7 +30,7 @@ import SwiftUI
*/ */
class ShowBasedOnVoteLogics { class ShowBasedOnVoteLogics {
static private func returnCurrentVoteStatus(onboardingData: OnboardingData) -> (Bool, DayOptions) { static private func returnCurrentVoteStatus(onboardingData: OnboardingData) -> (passedTimeToVote: Bool, inputDay: DayOptions) {
let passedTimeToVote = ShowBasedOnVoteLogics.passedTodaysVotingUnlock(voteDate: onboardingData.date) let passedTimeToVote = ShowBasedOnVoteLogics.passedTodaysVotingUnlock(voteDate: onboardingData.date)
let inputDay: DayOptions = onboardingData.inputDay let inputDay: DayOptions = onboardingData.inputDay
@@ -75,9 +75,10 @@ class ShowBasedOnVoteLogics {
static public func getCurrentVotingDate(onboardingData: OnboardingData) -> Date { static public func getCurrentVotingDate(onboardingData: OnboardingData) -> Date {
var date: Date? var date: Date?
let currentVoteStatus = ShowBasedOnVoteLogics.returnCurrentVoteStatus(onboardingData: onboardingData)
// note to future self, this should account for midnight until next voting unlock // note to future self, this should account for midnight until next voting unlock
// the vote at 12:03 am will not be passed time, and will be for yesterday // the vote at 12:03 am will not be passed time, and will be for yesterday
switch ShowBasedOnVoteLogics.returnCurrentVoteStatus(onboardingData: onboardingData) { switch (currentVoteStatus.passedTimeToVote, currentVoteStatus.inputDay) {
case (false, .Today): case (false, .Today):
// if we're passed time to vote and the voting type is previous - last vote should be -1 // 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()) date = Calendar.current.date(byAdding: .day, value: -1, to: Date())
@@ -101,7 +102,8 @@ class ShowBasedOnVoteLogics {
} }
static public func getVotingTitle(onboardingData: OnboardingData) -> String { static public func getVotingTitle(onboardingData: OnboardingData) -> String {
switch ShowBasedOnVoteLogics.returnCurrentVoteStatus(onboardingData: onboardingData) { let currentVoteStatus = ShowBasedOnVoteLogics.returnCurrentVoteStatus(onboardingData: onboardingData)
switch (currentVoteStatus.passedTimeToVote, currentVoteStatus.inputDay) {
case (false, .Today): case (false, .Today):
return String(localized: "add_mood_header_view_title_yesterday") return String(localized: "add_mood_header_view_title_yesterday")
case (true, .Today): case (true, .Today):