From 1870921364ed2cd68d51d7e7837e16e692278ff5 Mon Sep 17 00:00:00 2001 From: Mikhail Maslo Date: Mon, 15 Aug 2022 11:50:48 +0300 Subject: [PATCH] Fix demo: handle size updates animated if navigationController doesn't exist --- .../Screens/Resize/ResizeViewController.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/BottomSheetDemo/Sources/User Interface/Screens/Resize/ResizeViewController.swift b/BottomSheetDemo/Sources/User Interface/Screens/Resize/ResizeViewController.swift index d70c01f..e465435 100644 --- a/BottomSheetDemo/Sources/User Interface/Screens/Resize/ResizeViewController.swift +++ b/BottomSheetDemo/Sources/User Interface/Screens/Resize/ResizeViewController.swift @@ -153,9 +153,17 @@ final class ResizeViewController: UIViewController { private func updateContentHeight(newValue: CGFloat) { guard newValue >= 200 && newValue < 5000 else { return } - - currentHeight = newValue - updatePreferredContentSize() + + let updates = { [self] in + currentHeight = newValue + updatePreferredContentSize() + } + + if navigationController == nil { + UIView.animate(withDuration: 0.25, animations: updates) + } else { + updates() + } } @objc