Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve animation issues with Date picker #75

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Updated code in ReminderDetailsViewModel.swift to satisfy Egyptian ty…
…pe if else formatting. Updated one instance of newvalue to newValue.
  • Loading branch information
disc0infern0 committed Dec 8, 2021
commit cfa4c7b722d51e87c0d421ab512061c408c9c080
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ class ReminderDetailsViewModel: ObservableObject {
if newValue == true {
reminder.dueDate = Date()
setPickerState(.date)
} else {
}
else
{
reminder.dueDate = nil
reminder.hasDueTime = false
setPickerState(.none)
Expand All @@ -153,7 +155,9 @@ class ReminderDetailsViewModel: ObservableObject {
dueDate = nearestHour
reminder.hasDueTime = true
setPickerState(.time)
} else {
}
else
{
dueDate = dueDate.startOfDay()
reminder.hasDueTime = false
setPickerState(.none)
Expand All @@ -165,14 +169,16 @@ class ReminderDetailsViewModel: ObservableObject {
// so define an enum to control view state of the pickers
@Published var pickerState: PickerState = .none

func setPickerState(_ newvalue: PickerState) {
func setPickerState(_ newValue: PickerState) {
// Dont animate if transitioning from state where date picker is shown
if pickerState == .date {
pickerState = newvalue
} else {
pickerState = newValue
}
else
{
// Animate transition if Accessibility setting allows.
withOptionalAnimation {
pickerState = newvalue
pickerState = newValue
}
}
}
Expand All @@ -189,7 +195,9 @@ class ReminderDetailsViewModel: ObservableObject {
func withOptionalAnimation<Result>(_ animation: Animation? = .default, _ body: () throws -> Result) rethrows -> Result {
if UIAccessibility.isReduceMotionEnabled {
return try body()
} else {
}
else
{
return try withAnimation(animation, body)
}
}
Expand Down