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 18, 2020
1 parent 44cb3a6 commit e51afa7
Show file tree
Hide file tree
Showing 43 changed files with 1,410 additions and 1,196 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
31 changes: 14 additions & 17 deletions iphone/CoreApi/CoreApi/Metrics/MWMEye.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSUInteger, MWMTip)
{
MWMTipBookmarks,
MWMTipSearch,
MWMTipDiscovery,
MWMTipSubway,
MWMTipIsolines,
MWMTipNone
};
typedef NS_ENUM(NSUInteger, MWMTipType) {
MWMTipTypeBookmarks,
MWMTipTypeSearch,
MWMTipTypeDiscovery,
MWMTipTypeSubway,
MWMTipTypeIsolines,
MWMTipTypeNone
} NS_SWIFT_NAME(TipType);

typedef NS_ENUM(NSUInteger, MWMTipEvent)
{
typedef NS_ENUM(NSUInteger, MWMTipEvent) {
MWMTipEventAction,
MWMTipEventGotIt
};
} NS_SWIFT_NAME(TipEvent);

typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent)
{
typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent) {
MWMEyeDiscoveryEventHotels,
MWMEyeDiscoveryEventAttractions,
MWMEyeDiscoveryEventCafes,
Expand All @@ -28,10 +25,10 @@ typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent)
MWMEyeDiscoveryEventMoreLocals
};

@interface MWMEye : NSObject
@interface MWMEye: NSObject

+ (MWMTip)getTipType;
+ (void)tipClickedWithType:(MWMTip)type event:(MWMTipEvent)event;
+ (MWMTipType)getTipType;
+ (void)tipClickedWithType:(MWMTipType)type event:(MWMTipEvent)event;
+ (void)bookingFilterUsed;
+ (void)boomarksCatalogShown;
+ (void)discoveryShown;
Expand Down
26 changes: 9 additions & 17 deletions iphone/CoreApi/CoreApi/Metrics/MWMEye.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,36 @@

@implementation MWMEye

+ (MWMTip)getTipType
{
+ (MWMTipType)getTipType {
auto tutorialType = GetFramework().GetTipsApi().GetTip();
return tutorialType ? (MWMTip)*tutorialType : MWMTipNone;
return tutorialType ? (MWMTipType)*tutorialType : MWMTipTypeNone;
}

+ (void)tipClickedWithType:(MWMTip)type event:(MWMTipEvent)event
{
+ (void)tipClickedWithType:(MWMTipType)type event:(MWMTipEvent)event {
eye::Eye::Event::TipClicked((eye::Tip::Type)type, (eye::Tip::Event)event);
}

+ (void)bookingFilterUsed
{
+ (void)bookingFilterUsed {
eye::Eye::Event::BookingFilterUsed();
}

+ (void)boomarksCatalogShown
{
+ (void)boomarksCatalogShown {
eye::Eye::Event::BoomarksCatalogShown();
}

+ (void)discoveryShown
{
+ (void)discoveryShown {
eye::Eye::Event::DiscoveryShown();
}

+ (void)discoveryItemClickedWithEvent:(MWMEyeDiscoveryEvent)event
{
+ (void)discoveryItemClickedWithEvent:(MWMEyeDiscoveryEvent)event {
eye::Eye::Event::DiscoveryItemClicked((eye::Discovery::Event)event);
}

+ (void)transitionToBookingWithPos:(CGPoint)pos
{
+ (void)transitionToBookingWithPos:(CGPoint)pos {
eye::Eye::Event::TransitionToBooking({pos.x, pos.y});
}

+ (void)promoAfterBookingShownWithCityId:(NSString *)cityId
{
+ (void)promoAfterBookingShownWithCityId:(NSString *)cityId {
eye::Eye::Event::PromoAfterBookingShown(cityId.UTF8String);
}

Expand Down
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,33 +5,22 @@

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

@interface MWMMapViewControlsManager : NSObject

+ (MWMMapViewControlsManager *)manager NS_SWIFT_NAME(manager());

@property(nonatomic) BOOL hidden;
@property(nonatomic) BOOL zoomHidden;
@property(nonatomic) BOOL sideButtonsHidden;
@property(nonatomic) BOOL trafficButtonHidden;
@property(nonatomic, readonly) BOOL guidesNavigationBarHidden;
@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 Expand Up @@ -62,6 +51,6 @@

- (id<MWMFeatureHolder>)featureHolder;

- (void)showAdditionalViewsIfNeeded;
//- (void)showAdditionalViewsIfNeeded;

@end
Loading

0 comments on commit e51afa7

Please sign in to comment.