From 522f00f316bdb743004f171b6e90bbde824412ee Mon Sep 17 00:00:00 2001 From: Razvan Litianu Date: Thu, 25 Sep 2025 16:33:08 +0300 Subject: [PATCH 1/3] FXIOS-13606 #29553 Remove delay while clicking "Set as Default Browser" --- .../BottomSheetViewController.swift | 4 +-- .../OnboardingBottomSheetViewController.swift | 30 +++++++++++++++++++ .../Protocols/OnboardingService.swift | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift diff --git a/BrowserKit/Sources/ComponentLibrary/BottomSheet/BottomSheetViewController.swift b/BrowserKit/Sources/ComponentLibrary/BottomSheet/BottomSheetViewController.swift index cd73982d1b993..544234d9fd54c 100644 --- a/BrowserKit/Sources/ComponentLibrary/BottomSheet/BottomSheetViewController.swift +++ b/BrowserKit/Sources/ComponentLibrary/BottomSheet/BottomSheetViewController.swift @@ -37,7 +37,7 @@ public class BottomSheetViewController: UIViewController, public var themeManager: ThemeManager public var themeListenerCancellable: Any? - private let viewModel: BottomSheetViewModel + internal let viewModel: BottomSheetViewModel private var useDimmedBackground: Bool private let childViewController: BottomSheetChild @@ -62,7 +62,7 @@ public class BottomSheetViewController: UIViewController, private lazy var sheetView: UIView = .build { _ in } private lazy var contentView: UIView = .build { _ in } private lazy var scrollContentView: UIView = .build { _ in } - private var contentViewBottomConstraint: NSLayoutConstraint? + internal var contentViewBottomConstraint: NSLayoutConstraint? private var viewTranslation = CGPoint(x: 0, y: 0) private let windowUUID: WindowUUID private var glassEffectView: UIVisualEffectView? diff --git a/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift b/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift new file mode 100644 index 0000000000000..7e51d7032cf1e --- /dev/null +++ b/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift @@ -0,0 +1,30 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import Common +import Foundation +import UIKit + +/// A specialized bottom sheet controller for onboarding flows that uses viewWillAppear for animations +@MainActor +public class OnboardingBottomSheetViewController: BottomSheetViewController { + + // MARK: - View lifecycle + + override public func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + // Move animation from viewDidAppear to viewWillAppear for onboarding + // We need to access the parent's properties, so we'll call the parent's viewDidAppear logic here + contentViewBottomConstraint?.constant = 0 + UIView.animate(withDuration: viewModel.animationTransitionDuration) { + self.view.backgroundColor = self.viewModel.backgroundColor + self.view.layoutIfNeeded() + } + } + + override public func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + // No animation here - it's handled in viewWillAppear + } +} diff --git a/firefox-ios/Client/Frontend/Onboarding/Protocols/OnboardingService.swift b/firefox-ios/Client/Frontend/Onboarding/Protocols/OnboardingService.swift index 13c990b75951a..c35845c871fe9 100644 --- a/firefox-ios/Client/Frontend/Onboarding/Protocols/OnboardingService.swift +++ b/firefox-ios/Client/Frontend/Onboarding/Protocols/OnboardingService.swift @@ -311,7 +311,7 @@ final class OnboardingService: FeatureFlaggable { closeButtonA11yIdentifier: AccessibilityIdentifiers.Onboarding.bottomSheetCloseButton ) - let bottomSheetVC = BottomSheetViewController( + let bottomSheetVC = OnboardingBottomSheetViewController( viewModel: bottomSheetViewModel, childViewController: instructionsVC, usingDimmedBackground: true, From 8e53efee83915ab0f19d6fd3492c63fe0994f543 Mon Sep 17 00:00:00 2001 From: Razvan Litianu Date: Thu, 25 Sep 2025 16:35:32 +0300 Subject: [PATCH 2/3] swiftlint --- .../OnboardingBottomSheetViewController.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift b/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift index 7e51d7032cf1e..bb36a50a6fba0 100644 --- a/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift +++ b/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift @@ -9,22 +9,21 @@ import UIKit /// A specialized bottom sheet controller for onboarding flows that uses viewWillAppear for animations @MainActor public class OnboardingBottomSheetViewController: BottomSheetViewController { - // MARK: - View lifecycle - + override public func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Move animation from viewDidAppear to viewWillAppear for onboarding - // We need to access the parent's properties, so we'll call the parent's viewDidAppear logic here contentViewBottomConstraint?.constant = 0 UIView.animate(withDuration: viewModel.animationTransitionDuration) { self.view.backgroundColor = self.viewModel.backgroundColor self.view.layoutIfNeeded() } } - + + // swiftlint:disable:next unneeded_override override public func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - // No animation here - it's handled in viewWillAppear + // No animation here - it's handled in viewWillAppear to prevent double animation } } From 4e2296cb2a9b892131358e62cc1b2a1d917ded8b Mon Sep 17 00:00:00 2001 From: Razvan Litianu Date: Fri, 26 Sep 2025 16:32:22 +0300 Subject: [PATCH 3/3] Update comments --- .../OnboardingBottomSheetViewController.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift b/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift index bb36a50a6fba0..3a49e88a2af94 100644 --- a/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift +++ b/BrowserKit/Sources/ComponentLibrary/BottomSheet/OnboardingBottomSheetViewController.swift @@ -13,7 +13,10 @@ public class OnboardingBottomSheetViewController: BottomSheetViewController { override public func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - // Move animation from viewDidAppear to viewWillAppear for onboarding + + // For onboarding flows, we animate the bottom sheet presentation earlier in the lifecycle + // This ensures the animation starts before the view becomes visible, creating a smoother + // user experience during onboarding transitions contentViewBottomConstraint?.constant = 0 UIView.animate(withDuration: viewModel.animationTransitionDuration) { self.view.backgroundColor = self.viewModel.backgroundColor @@ -24,6 +27,8 @@ public class OnboardingBottomSheetViewController: BottomSheetViewController { // swiftlint:disable:next unneeded_override override public func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - // No animation here - it's handled in viewWillAppear to prevent double animation + // Override viewDidAppear without additional animation logic since we handle + // all presentation animations in viewWillAppear. This prevents duplicate + // animations that could cause visual glitches in onboarding flows. } }