Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
chore: hide view all dates button from snack bar when showing on date…
Browse files Browse the repository at this point in the history
…s tab
  • Loading branch information
saeedbashir committed May 19, 2023
1 parent 4f99e01 commit ebd85b3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
11 changes: 9 additions & 2 deletions Source/CourseOutlineViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class CourseOutlineViewController :
private(set) var courseOutlineMode: CourseOutlineMode
private var loadCachedResponse: Bool = true
private lazy var courseUpgradeHelper = CourseUpgradeHelper.shared
weak var newDashboardDelegate: NewCourseDashboardViewControllerDelegate?

/// Strictly a test variable used as a trigger flag. Not to be used out of the test scope
fileprivate var t_hasTriggeredSetResumeCourse = false
Expand Down Expand Up @@ -85,7 +86,7 @@ public class CourseOutlineViewController :
tableController = CourseOutlineTableController(environment: environment, courseID: courseID, forMode: courseOutlineMode, courseBlockID: rootID)
tableController.newDashboardDelegate = newDashboardDelegate
resumeCourseController = ResumeCourseController(blockID: rootID , dataManager: environment.dataManager, networkManager: environment.networkManager, courseQuerier: courseQuerier, forMode: courseOutlineMode)

self.newDashboardDelegate = newDashboardDelegate
super.init(env: environment, shouldShowOfflineSnackBar: false)

addObservers()
Expand Down Expand Up @@ -405,7 +406,13 @@ public class CourseOutlineViewController :
}

private func showSnackBar() {
showDateResetSnackBar(message: Strings.Coursedates.toastSuccessMessage, buttonText: Strings.Coursedates.viewAllDates, showButton: true) { [weak self] in
guard let topController = UIApplication.shared.topMostController() else { return }
var showViewDatesButton = true
if let selectedController = newDashboardDelegate?.selectedController() {
showViewDatesButton = !(selectedController is CourseDatesViewController)
}

topController.showDateResetSnackBar(message: Strings.Coursedates.toastSuccessMessage, buttonText: Strings.Coursedates.viewAllDates, showButton: showViewDatesButton) { [weak self] in
if let weakSelf = self {
weakSelf.environment.router?.showDatesTabController(controller: weakSelf)
weakSelf.hideSnackBar()
Expand Down
11 changes: 11 additions & 0 deletions Source/NewCourseDashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import UIKit
public protocol NewCourseDashboardViewControllerDelegate: AnyObject {
func showCourseDates(bannerInfo: DatesBannerInfo?, delegate: CourseOutlineTableController?)
func hideCourseDates()
func selectedController() -> UIViewController?
}

extension NewCourseDashboardViewControllerDelegate {
public func selectedController() -> UIViewController? {
return nil
}
}

class NewCourseDashboardViewController: UIViewController, InterfaceOrientationOverriding {
Expand Down Expand Up @@ -557,4 +564,8 @@ extension NewCourseDashboardViewController: NewCourseDashboardViewControllerDele
func hideCourseDates() {
headerView.removeDatesBanner()
}

func selectedController() -> UIViewController? {
return selectedTabbarItem?.viewController
}
}
8 changes: 6 additions & 2 deletions Source/OEXRouter+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,12 @@ extension OEXRouter {

func showDatesTabController(controller: UIViewController) {
if environment.config.isNewDashboardEnabled {
guard let dashboardController = controller.navigationController?.viewControllers.first as? NewCourseDashboardViewController else { return }
popToRoot(controller: dashboardController) {
if let dashboardController = controller.navigationController?.viewControllers.first as? NewCourseDashboardViewController {
popToRoot(controller: dashboardController) {
dashboardController.switchTab(with: .courseDates)
}
}
else if let dashboardController = UIApplication.shared.topMostController() as? NewCourseDashboardViewController {
dashboardController.switchTab(with: .courseDates)
}
} else {
Expand Down

0 comments on commit ebd85b3

Please sign in to comment.