From 0a2e1f2fc8cfb219c8dbea64e1d8e012bd1794ec Mon Sep 17 00:00:00 2001 From: osy <50960678+osy@users.noreply.github.com> Date: Mon, 10 Jan 2022 17:23:28 -0800 Subject: [PATCH] toolbar: increased opacity of dim view Also made animation smooth for transition back to visible. --- Platform/iOS/Display/VMToolbarActions.swift | 20 ++++++++++++-------- Platform/iOS/Display/VMToolbarView.swift | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Platform/iOS/Display/VMToolbarActions.swift b/Platform/iOS/Display/VMToolbarActions.swift index b3849b917..0be4414ec 100644 --- a/Platform/iOS/Display/VMToolbarActions.swift +++ b/Platform/iOS/Display/VMToolbarActions.swift @@ -128,6 +128,16 @@ import SwiftUI } } + private func setIsUserInteracting(_ value: Bool) { + if #available(iOS 14, *), !UIAccessibility.isReduceMotionEnabled { + withAnimation { + self.isUserInteracting = value + } + } else { + self.isUserInteracting = value + } + } + func assertUserInteraction() { guard !hasLegacyToolbar else { return @@ -135,16 +145,10 @@ import SwiftUI if let task = longIdleTask { task.cancel() } - isUserInteracting = true + setIsUserInteracting(true) longIdleTask = DispatchWorkItem { self.longIdleTask = nil - if #available(iOS 14, *), !UIAccessibility.isReduceMotionEnabled { - withAnimation { - self.isUserInteracting = false - } - } else { - self.isUserInteracting = false - } + self.setIsUserInteracting(false) } DispatchQueue.main.asyncAfter(deadline: .now() + 15, execute: longIdleTask!) } diff --git a/Platform/iOS/Display/VMToolbarView.swift b/Platform/iOS/Display/VMToolbarView.swift index 51e3df777..e3bf1b8f2 100644 --- a/Platform/iOS/Display/VMToolbarView.swift +++ b/Platform/iOS/Display/VMToolbarView.swift @@ -68,7 +68,7 @@ struct VMToolbarView: View { if !state.isUserInteracting { return 0 } else if isIdle { - return 0.2 + return 0.4 } else { return 1 }