forked from organicmaps/organicmaps
[ios] Fixed crash on menu click after hiding the interface
Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
parent
572cee320a
commit
8ab6ab2266
7 changed files with 5 additions and 60 deletions
|
@ -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<MWMNavigationDashboardObserver>_Nonnull)observer;
|
||||
+ (void)removeObserver:(id<MWMNavigationDashboardObserver>_Nonnull)observer;
|
||||
|
||||
@property(nonatomic, readonly) MWMNavigationDashboardState state;
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@ namespace {
|
|||
NSString *const kRoutePreviewIPhoneXibName = @"MWMiPhoneRoutePreview";
|
||||
NSString *const kNavigationInfoViewXibName = @"MWMNavigationInfoView";
|
||||
NSString *const kNavigationControlViewXibName = @"NavigationControlView";
|
||||
|
||||
using Observer = id<MWMNavigationDashboardObserver>;
|
||||
using Observers = NSHashTable<Observer>;
|
||||
} // namespace
|
||||
|
||||
@interface MWMMapViewControlsManager ()
|
||||
|
@ -35,7 +32,6 @@ using Observers = NSHashTable<Observer>;
|
|||
@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<Observer>;
|
|||
self = [super init];
|
||||
if (self) {
|
||||
_ownerView = view;
|
||||
_observers = [Observers weakObjectsHashTable];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -235,23 +230,6 @@ using Observers = NSHashTable<Observer>;
|
|||
[MWMRouter stopRouting];
|
||||
}
|
||||
|
||||
#pragma mark - Add/Remove Observers
|
||||
|
||||
+ (void)addObserver:(id<MWMNavigationDashboardObserver>)observer {
|
||||
[[self sharedManager].observers addObject:observer];
|
||||
}
|
||||
|
||||
+ (void)removeObserver:(id<MWMNavigationDashboardObserver>)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<Observer>;
|
|||
}
|
||||
_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;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
@protocol MWMNavigationDashboardObserver<NSObject>
|
||||
|
||||
- (void)onNavigationDashboardStateChanged;
|
||||
|
||||
@end
|
|
@ -853,7 +853,6 @@
|
|||
34AB65C51FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "MWMNavigationDashboardManager+Entity.mm"; sourceTree = "<group>"; };
|
||||
34AB65C61FC5AA320078E451 /* MWMNavigationDashboardManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNavigationDashboardManager.mm; sourceTree = "<group>"; };
|
||||
34AB65C71FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MWMNavigationDashboardManager+Entity.h"; sourceTree = "<group>"; };
|
||||
34AB65C81FC5AA320078E451 /* MWMNavigationDashboardObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardObserver.h; sourceTree = "<group>"; };
|
||||
34AB65C91FC5AA320078E451 /* MWMNavigationDashboardEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardEntity.h; sourceTree = "<group>"; };
|
||||
34AB65CA1FC5AA320078E451 /* MWMNavigationDashboardManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationDashboardManager.h; sourceTree = "<group>"; };
|
||||
34AB65CB1FC5AA320078E451 /* MWMNavigationDashboardEntity.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNavigationDashboardEntity.mm; sourceTree = "<group>"; };
|
||||
|
@ -2267,7 +2266,6 @@
|
|||
34AB65C61FC5AA320078E451 /* MWMNavigationDashboardManager.mm */,
|
||||
34AB65C71FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.h */,
|
||||
34AB65C51FC5AA320078E451 /* MWMNavigationDashboardManager+Entity.mm */,
|
||||
34AB65C81FC5AA320078E451 /* MWMNavigationDashboardObserver.h */,
|
||||
34AB65CC1FC5AA320078E451 /* Views */,
|
||||
);
|
||||
name = NavigationDashboard;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue