From 8ab6ab22664d04a33593259b1eb47d4b905b20ac Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Sat, 12 Feb 2022 19:41:38 +0100 Subject: [PATCH] [ios] Fixed crash on menu click after hiding the interface Signed-off-by: Alexander Borsuk --- .../MWMNavigationDashboardManager.h | 4 --- .../MWMNavigationDashboardManager.mm | 26 +++---------------- .../MWMNavigationDashboardObserver.h | 5 ---- iphone/Maps/Maps.xcodeproj/project.pbxproj | 2 -- .../TabBar/BottomTabBarBuilder.swift | 2 +- .../TabBar/BottomTabBarPresenter.swift | 5 +--- .../TabBar/BottomTabBarViewController.swift | 21 --------------- 7 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardObserver.h diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h index 5ca8d72d22..e8e901024b 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h @@ -1,5 +1,3 @@ -#import "MWMNavigationDashboardObserver.h" - typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) { MWMNavigationDashboardStateHidden, MWMNavigationDashboardStatePrepare, @@ -12,8 +10,6 @@ typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) { @interface MWMNavigationDashboardManager : NSObject + (nonnull MWMNavigationDashboardManager *)sharedManager; -+ (void)addObserver:(id_Nonnull)observer; -+ (void)removeObserver:(id_Nonnull)observer; @property(nonatomic, readonly) MWMNavigationDashboardState state; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index a37760eafe..93aeab6455 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -11,9 +11,6 @@ namespace { NSString *const kRoutePreviewIPhoneXibName = @"MWMiPhoneRoutePreview"; NSString *const kNavigationInfoViewXibName = @"MWMNavigationInfoView"; NSString *const kNavigationControlViewXibName = @"NavigationControlView"; - -using Observer = id; -using Observers = NSHashTable; } // namespace @interface MWMMapViewControlsManager () @@ -35,7 +32,6 @@ using Observers = NSHashTable; @property(nonatomic) IBOutletCollection(MWMRouteStartButton) NSArray *goButtons; @property(nonatomic) MWMNavigationDashboardEntity *entity; @property(nonatomic) MWMRouteManagerTransitioningManager *routeManagerTransitioningManager; -@property(nonatomic) Observers *observers; @property(weak, nonatomic) IBOutlet UIButton *showRouteManagerButton; @property(weak, nonatomic) IBOutlet UIView *goButtonsContainer; @property(weak, nonatomic) UIView *ownerView; @@ -52,7 +48,6 @@ using Observers = NSHashTable; self = [super init]; if (self) { _ownerView = view; - _observers = [Observers weakObjectsHashTable]; } return self; } @@ -235,23 +230,6 @@ using Observers = NSHashTable; [MWMRouter stopRouting]; } -#pragma mark - Add/Remove Observers - -+ (void)addObserver:(id)observer { - [[self sharedManager].observers addObject:observer]; -} - -+ (void)removeObserver:(id)observer { - [[self sharedManager].observers removeObject:observer]; -} - -#pragma mark - MWMNavigationDashboardObserver - -- (void)onNavigationDashboardStateChanged { - for (Observer observer in self.observers) - [observer onNavigationDashboardStateChanged]; -} - #pragma mark - MWMSearchManagerObserver - (void)onSearchManagerStateChanged { @@ -314,7 +292,9 @@ using Observers = NSHashTable; } _state = state; [[MapViewController sharedController] updateStatusBarStyle]; - [self onNavigationDashboardStateChanged]; + // Restore bottom buttons only if they were not already hidden by tapping anywhere on an empty map. + if (!MWMMapViewControlsManager.manager.hidden) + BottomTabBarViewController.controller.isHidden = state != MWMNavigationDashboardStateHidden; } @synthesize routePreview = _routePreview; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardObserver.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardObserver.h deleted file mode 100644 index 2db38612c0..0000000000 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardObserver.h +++ /dev/null @@ -1,5 +0,0 @@ -@protocol MWMNavigationDashboardObserver - -- (void)onNavigationDashboardStateChanged; - -@end diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index ba48cb269d..446c1359f0 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -853,7 +853,6 @@ 34AB65C51FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MWMNavigationDashboardManager+Entity.mm"; sourceTree = ""; }; 34AB65C61FC5AA320078E451 /* MWMNavigationDashboardManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNavigationDashboardManager.mm; sourceTree = ""; }; 34AB65C71FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MWMNavigationDashboardManager+Entity.h"; sourceTree = ""; }; - 34AB65C81FC5AA320078E451 /* MWMNavigationDashboardObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardObserver.h; sourceTree = ""; }; 34AB65C91FC5AA320078E451 /* MWMNavigationDashboardEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardEntity.h; sourceTree = ""; }; 34AB65CA1FC5AA320078E451 /* MWMNavigationDashboardManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardManager.h; sourceTree = ""; }; 34AB65CB1FC5AA320078E451 /* MWMNavigationDashboardEntity.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNavigationDashboardEntity.mm; sourceTree = ""; }; @@ -2267,7 +2266,6 @@ 34AB65C61FC5AA320078E451 /* MWMNavigationDashboardManager.mm */, 34AB65C71FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.h */, 34AB65C51FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.mm */, - 34AB65C81FC5AA320078E451 /* MWMNavigationDashboardObserver.h */, 34AB65CC1FC5AA320078E451 /* Views */, ); name = NavigationDashboard; diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarBuilder.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarBuilder.swift index 39695b5aa7..493db1ff97 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarBuilder.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarBuilder.swift @@ -4,7 +4,7 @@ let interactor = BottomTabBarInteractor(viewController: viewController, mapViewController: mapViewController, controlsManager: controlsManager) - let presenter = BottomTabBarPresenter(view: viewController, interactor: interactor) + let presenter = BottomTabBarPresenter(interactor: interactor) interactor.presenter = presenter viewController.presenter = presenter diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift index e33cbd6d4b..8853bf6b90 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarPresenter.swift @@ -8,12 +8,9 @@ protocol BottomTabBarPresenterProtocol: AnyObject { } class BottomTabBarPresenter: NSObject { - private weak var view: BottomTabBarViewProtocol? private let interactor: BottomTabBarInteractorProtocol - init(view: BottomTabBarViewProtocol, - interactor: BottomTabBarInteractorProtocol) { - self.view = view + init(interactor: BottomTabBarInteractorProtocol) { self.interactor = interactor } } diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift index dd85d76e01..fc258d1e90 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift @@ -1,9 +1,3 @@ -protocol BottomTabBarViewProtocol: AnyObject { - var presenter: BottomTabBarPresenterProtocol! { get set } - var isHidden: Bool { get } - var isApplicationBadgeHidden: Bool { get set } -} - class BottomTabBarViewController: UIViewController { var presenter: BottomTabBarPresenterProtocol! @@ -38,7 +32,6 @@ class BottomTabBarViewController: UIViewController { updateBadge() MWMSearchManager.add(self) - MWMNavigationDashboardManager.add(self) } override func viewDidAppear(_ animated: Bool) { @@ -47,7 +40,6 @@ class BottomTabBarViewController: UIViewController { deinit { MWMSearchManager.remove(self) - MWMNavigationDashboardManager.remove(self) } static func updateAvailableArea(_ frame: CGRect) { @@ -109,19 +101,6 @@ class BottomTabBarViewController: UIViewController { } } -extension BottomTabBarViewController: BottomTabBarViewProtocol { - -} - -// MARK: - MWMNavigationDashboardObserver - -extension BottomTabBarViewController: MWMNavigationDashboardObserver { - func onNavigationDashboardStateChanged() { - let state = MWMNavigationDashboardManager.shared().state - self.isHidden = state != .hidden; - } -} - // MARK: - MWMSearchManagerObserver extension BottomTabBarViewController: MWMSearchManagerObserver {