From a7cfb5ced543c62bc3c74d37321f8c6758cc58a4 Mon Sep 17 00:00:00 2001 From: Saeed Bashir Date: Thu, 2 May 2024 18:08:06 +0500 Subject: [PATCH] fix: improve showing of IAP unlock controller --- Source/CourseUpgradeHelper.swift | 6 ++++++ Source/NewCourseDashboardViewController.swift | 4 ++++ Source/ValuePropUnlockViewContainer.swift | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/Source/CourseUpgradeHelper.swift b/Source/CourseUpgradeHelper.swift index 5f7db2aed4..1e6c868c41 100644 --- a/Source/CourseUpgradeHelper.swift +++ b/Source/CourseUpgradeHelper.swift @@ -238,6 +238,12 @@ class CourseUpgradeHelper: NSObject { } } + // presented view appears on the uplock controller + // need to bring it to front for better user experience + func bringLoaderToFront() { + unlockController.bringToFront() + } + func removeLoader(success: Bool? = false, removeView: Bool? = false, completion: (()-> ())? = nil) { self.completion = completion if success == true { diff --git a/Source/NewCourseDashboardViewController.swift b/Source/NewCourseDashboardViewController.swift index b94a7aefa6..0dfa278a6d 100644 --- a/Source/NewCourseDashboardViewController.swift +++ b/Source/NewCourseDashboardViewController.swift @@ -118,6 +118,10 @@ class NewCourseDashboardViewController: UIViewController, InterfaceOrientationOv navigationItem.setHidesBackButton(true, animated: true) navigationController?.setNavigationBarHidden(true, animated: true) environment.analytics.trackScreen(withName: OEXAnalyticsScreenCourseDashboard, courseID: courseID, value: nil) + + if let _ = courseUpgradeHelper.courseUpgradeModel { + courseUpgradeHelper.bringLoaderToFront() + } } override func viewWillDisappear(_ animated: Bool) { diff --git a/Source/ValuePropUnlockViewContainer.swift b/Source/ValuePropUnlockViewContainer.swift index e1f182dff5..9bda12fba9 100644 --- a/Source/ValuePropUnlockViewContainer.swift +++ b/Source/ValuePropUnlockViewContainer.swift @@ -48,6 +48,14 @@ class ValuePropUnlockViewContainer: NSObject { } } + // the bring subview to front isn't work here because of hierarchy + // removing and readding the view + func bringToFront() { + removeView() { [weak self] in + self?.showView() + } + } + @objc private func finishTimer() { shouldDismiss.value = true }