diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift index 82913b477c..a24b62f46a 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift @@ -1,6 +1,7 @@ protocol BottomTabBarInteractorProtocol: AnyObject { func openSearch() func openHelp() + func openFaq() func openBookmarks() func openMenu() } @@ -32,6 +33,10 @@ extension BottomTabBarInteractor: BottomTabBarInteractorProtocol { MapViewController.shared()?.navigationController?.pushViewController(AboutController(), animated: true) } + func openFaq() { + MapViewController.shared()?.navigationController?.pushViewController(FaqController(), animated: true) + } + func openBookmarks() { mapViewController?.bookmarksCoordinator.open() } diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift index de11abfc46..b3df38d462 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift @@ -1,7 +1,7 @@ protocol BottomTabBarPresenterProtocol: AnyObject { func configure() func onSearchButtonPressed() - func onHelpButtonPressed() + func onHelpButtonPressed(withBadge: Bool) func onBookmarksButtonPressed() func onMenuButtonPressed() } @@ -21,15 +21,15 @@ extension BottomTabBarPresenter: BottomTabBarPresenterProtocol { func onSearchButtonPressed() { interactor.openSearch() } - - func onHelpButtonPressed() { - interactor.openHelp() + + func onHelpButtonPressed(withBadge: Bool) { + withBadge ? interactor.openFaq() : interactor.openHelp() } - + func onBookmarksButtonPressed() { interactor.openBookmarks() } - + func onMenuButtonPressed() { interactor.openMenu() } diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift index a280fbaf87..af3da08ffa 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift @@ -1,3 +1,6 @@ + +private let kUDDidShowFirstTimeRoutingEducationalHint = "kUDDidShowFirstTimeRoutingEducationalHint" + class BottomTabBarViewController: UIViewController { var presenter: BottomTabBarPresenterProtocol! @@ -6,6 +9,7 @@ class BottomTabBarViewController: UIViewController { @IBOutlet var bookmarksButton: MWMButton! @IBOutlet var moreButton: MWMButton! @IBOutlet var downloadBadge: UIView! + @IBOutlet var helpBadge: UIView! private var avaliableArea = CGRect.zero @objc var isHidden: Bool = false { @@ -25,24 +29,20 @@ class BottomTabBarViewController: UIViewController { return MWMMapViewControlsManager.manager()?.tabBarController } + override func viewDidLoad() { + super.viewDidLoad() + presenter.configure() + + MWMSearchManager.add(self) + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if Settings.isNY() { helpButton.setTitle("🎄", for: .normal) helpButton.setImage(nil, for: .normal) } - } - - override func viewDidLoad() { - super.viewDidLoad() - presenter.configure() updateBadge() - - MWMSearchManager.add(self) - } - - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) } deinit { @@ -56,9 +56,14 @@ class BottomTabBarViewController: UIViewController { @IBAction func onSearchButtonPressed(_ sender: Any) { presenter.onSearchButtonPressed() } - + @IBAction func onHelpButtonPressed(_ sender: Any) { - presenter.onHelpButtonPressed() + if !helpBadge.isHidden { + presenter.onHelpButtonPressed(withBadge: true) + setHelpBadgeShown() + } else { + presenter.onHelpButtonPressed(withBadge: false) + } } @IBAction func onBookmarksButtonPressed(_ sender: Any) { @@ -69,7 +74,6 @@ class BottomTabBarViewController: UIViewController { presenter.onMenuButtonPressed() } - private func updateAvailableArea(_ frame:CGRect) { avaliableArea = frame updateFrame(animated: false) @@ -90,8 +94,8 @@ class BottomTabBarViewController: UIViewController { delay: 0, options: [.beginFromCurrentState], animations: { - self.view.frame = newFrame - self.view.alpha = alpha + self.view.frame = newFrame + self.view.alpha = alpha }, completion: nil) } else { self.view.frame = newFrame @@ -101,11 +105,22 @@ class BottomTabBarViewController: UIViewController { private func updateBadge() { downloadBadge.isHidden = isApplicationBadgeHidden + helpBadge.isHidden = !needsToShowHelpBadge() + } +} + +// MARK: - Help badge +private extension BottomTabBarViewController { + private func needsToShowHelpBadge() -> Bool { + !UserDefaults.standard.bool(forKey: kUDDidShowFirstTimeRoutingEducationalHint) + } + + private func setHelpBadgeShown() { + UserDefaults.standard.set(true, forKey: kUDDidShowFirstTimeRoutingEducationalHint) } } // MARK: - MWMSearchManagerObserver - extension BottomTabBarViewController: MWMSearchManagerObserver { func onSearchManagerStateChanged() { let state = MWMSearchManager.manager().state; diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.xib b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.xib index 0c4a7ce402..4c33c2f7b6 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.xib +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.xib @@ -12,6 +12,7 @@ + @@ -82,12 +83,24 @@ + + + + + + + + + + + + @@ -97,6 +110,7 @@ +