Skip to content

Commit

Permalink
[iOS] Map controls refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Belousov committed Nov 11, 2020
1 parent 44cb3a6 commit 96eeaf1
Show file tree
Hide file tree
Showing 40 changed files with 1,255 additions and 928 deletions.
4 changes: 3 additions & 1 deletion iphone/CoreApi/CoreApi/Framework/MWMFrameworkHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ NS_SWIFT_NAME(FrameworkHelper)
+ (void)showBookmark:(MWMMarkID)bookmarkId;
+ (void)showTrack:(MWMTrackID)trackId;
+ (void)updatePlacePageData;

+ (void)setPlacePageSelectedCallback:(MWMVoidBlock)selected
deselectedCallback:(MWMBoolBlock)deselected
updatedCallback:(MWMVoidBlock)updated;
@end

NS_ASSUME_NONNULL_END
8 changes: 8 additions & 0 deletions iphone/CoreApi/CoreApi/Framework/MWMFrameworkHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,12 @@ + (void)updatePlacePageData {
GetFramework().UpdatePlacePageInfoForCurrentSelection();
}

+ (void)setPlacePageSelectedCallback:(MWMVoidBlock)selected
deselectedCallback:(MWMBoolBlock)deselected
updatedCallback:(MWMVoidBlock)updated {
GetFramework().SetPlacePageListeners([selected]() { selected(); },
[deselected](bool switchFullScreen) { deselected(switchFullScreen); },
[updated]() { updated(); });
}

@end
2 changes: 1 addition & 1 deletion iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef NS_ENUM(NSUInteger, MWMMapOverlayIsolinesState) {
MWMMapOverlayIsolinesStateEnabled,
MWMMapOverlayIsolinesStateExpiredData,
MWMMapOverlayIsolinesStateNoData,
} NS_SWIFT_NAME(MapOverlayTransitState);
} NS_SWIFT_NAME(MapOverlayIsolinesState);

typedef NS_ENUM(NSUInteger, MWMMapOverlayGuidesState) {
MWMMapOverlayGuidesStateDisabled,
Expand Down
10 changes: 4 additions & 6 deletions iphone/Maps/Bookmarks/BookmarksCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import UIKit
}

private weak var navigationController: UINavigationController?
private weak var controlsManager: MWMMapViewControlsManager?
weak var mapControlsViewController: MapControlsViewController?
private weak var navigationManager: MWMNavigationDashboardManager?
private var bookmarksControllers: [UIViewController]?
private var state: BookmarksState = .closed {
Expand All @@ -18,10 +18,8 @@ import UIKit
}

@objc init(navigationController: UINavigationController,
controlsManager: MWMMapViewControlsManager,
navigationManager: MWMNavigationDashboardManager) {
self.navigationController = navigationController
self.controlsManager = controlsManager
self.navigationManager = navigationManager
}

Expand Down Expand Up @@ -59,11 +57,11 @@ import UIKit
}, completion: nil)
FrameworkHelper.deactivateMapSelection(notifyUI: true)
self.bookmarksControllers = nil
controlsManager?.hideGuidesNavigationBar()
mapControlsViewController?.hideGuidesNavigationBar()
case .closed:
navigationController.popToRootViewController(animated: true)
bookmarksControllers = nil
controlsManager?.hideGuidesNavigationBar()
mapControlsViewController?.hideGuidesNavigationBar()
case let .hidden(categoryId):
UIView.transition(with: self.navigationController!.view,
duration: kDefaultAnimationDuration,
Expand All @@ -73,7 +71,7 @@ import UIKit
}, completion: nil)
let isNavigation = navigationManager?.state != .hidden
if isNavigation == false {
controlsManager?.showGuidesNavigationBar(categoryId)
mapControlsViewController?.showGuidesNavigationBar(categoryId)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion iphone/Maps/Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
#import "MWMTextToSpeech.h"
#import "MWMTextToSpeechObserver.h"
#import "MWMTextView.h"
#import "MWMTrafficButtonViewController.h"
#import "MWMViewController.h"
#import "MapViewController.h"
#import "MapsAppDelegate.h"
Expand Down
18 changes: 0 additions & 18 deletions iphone/Maps/Classes/CircleView.h

This file was deleted.

80 changes: 0 additions & 80 deletions iphone/Maps/Classes/CircleView.m

This file was deleted.

4 changes: 2 additions & 2 deletions iphone/Maps/Classes/CustomAlert/MWMEditorViralAlert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ - (IBAction)shareTap {
[Statistics logEvent:kStatEditorSecondTimeShareClick];
[self close:^{
MWMActivityViewController* shareVC = [MWMActivityViewController shareControllerForEditorViral];
[shareVC presentInParentViewController:self.alertController.ownerViewController
anchorView:[BottomTabBarViewController controller].view];
// [shareVC presentInParentViewController:self.alertController.ownerViewController
// anchorView:[BottomTabBarViewController controller].view];
}];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
static NSTimeInterval const kMenuViewHideFramesCount = 4.0;

static inline NSTimeInterval framesDuration(NSTimeInterval const framesCount)
{
static NSTimeInterval const kFPS = 30.0;
static NSTimeInterval const kFrameDuration = 1.0 / kFPS;
return kFrameDuration * framesCount;
static inline NSTimeInterval framesDuration(NSTimeInterval const framesCount) {
return framesCount / 30;
}

static CGFloat const kViewControlsOffsetToBounds = 6;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class GuidesNavigationBarViewController: UIViewController {
@IBOutlet var navigationBar: UINavigationBar!
@IBOutlet var navigationBarItem: UINavigationItem!

@objc init(categoryId: MWMMarkGroupID) {
init(categoryId: MWMMarkGroupID) {
category = BookmarksManager.shared().category(withId: categoryId)
super.init(nibName: nil, bundle: nil)
}
Expand All @@ -31,35 +31,6 @@ class GuidesNavigationBarViewController: UIViewController {
style: .plain,
target: self,
action: #selector(onCancelPessed))
refreshLayout(false)
}

@objc func configLayout() {
guard let superview = view.superview else {
fatalError()
}

NSLayoutConstraint.activate([
view.topAnchor.constraint(equalTo: superview.topAnchor),
view.leftAnchor.constraint(equalTo: superview.leftAnchor),
view.rightAnchor.constraint(equalTo: superview.rightAnchor)
])
}

func refreshLayout(_ animated: Bool = true) {
DispatchQueue.main.async {
let availableArea = self.availableArea
self.view.alpha = min(1, availableArea.height / self.view.height)
}
}

class func updateAvailableArea(_ frame: CGRect) {
guard let controller = MWMMapViewControlsManager.manager()?.guidesNavigationBar,
!controller.availableArea.equalTo(frame) else {
return
}
controller.availableArea = frame
controller.refreshLayout()
}

@objc func onBackPressed(_ sender: Any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

@class MapViewController;
@class BottomTabBarViewController;
@class GuidesNavigationBarViewController;
@protocol MWMFeatureHolder;

@interface MWMMapViewControlsManager : NSObject
Expand All @@ -20,18 +19,12 @@
@property(nonatomic) MWMBottomMenuState menuState;
@property(nonatomic) MWMBottomMenuState menuRestoreState;
@property(nonatomic) BOOL isDirectionViewHidden;
@property(nonatomic) BottomTabBarViewController *tabBarController;
@property(nonatomic) GuidesNavigationBarViewController *guidesNavigationBar;

- (instancetype)init __attribute__((unavailable("init is not available")));
- (instancetype)initWithParentController:(MapViewController *)controller;

- (UIStatusBarStyle)preferredStatusBarStyle;

#pragma mark GuidesNavigationBar
- (void)showGuidesNavigationBar:(MWMMarkGroupID)categoryId;
- (void)hideGuidesNavigationBar;

#pragma mark - Layout

- (UIView *)anchorView;
Expand Down
Loading

0 comments on commit 96eeaf1

Please sign in to comment.