closed #37
This commit is contained in:
@@ -34,6 +34,24 @@ final class OnboardingData: NSObject, ObservableObject, Codable {
|
||||
title = try container.decode(String.self, forKey: .title)
|
||||
}
|
||||
|
||||
func ableToVoteBasedOnCurentTime() -> Bool {
|
||||
let currentDateComp = Calendar.current.dateComponents([.hour, .minute], from: Date())
|
||||
let savedDateComp = Calendar.current.dateComponents([.hour, .minute], from: self.date)
|
||||
|
||||
if let currentHour = currentDateComp.hour,
|
||||
let currentMin = currentDateComp.minute,
|
||||
let savedHour = savedDateComp.hour,
|
||||
let savedMin = savedDateComp.minute {
|
||||
if currentHour >= savedHour &&
|
||||
currentMin >= savedMin {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override init() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ struct ContentView: View {
|
||||
BGView()
|
||||
VStack{
|
||||
settingsButtonView
|
||||
if viewModel.shouldShowTodayInput() {
|
||||
if viewModel.shouldShowTodayInput() && savedOnboardingData.ableToVoteBasedOnCurentTime() {
|
||||
AddMoodHeaderView(addItemClosure: { (mood, date) in
|
||||
withAnimation {
|
||||
viewModel.add(mood: mood, forDate: date)
|
||||
|
||||
Reference in New Issue
Block a user