Skip to content

Commit e51afa7

Browse files
author
Aleksey Belousov
committed
[iOS] Map controls refactoring
1 parent 44cb3a6 commit e51afa7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1410
-1196
lines changed

iphone/CoreApi/CoreApi/Framework/MWMFrameworkHelper.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ NS_SWIFT_NAME(FrameworkHelper)
4444
+ (void)showBookmark:(MWMMarkID)bookmarkId;
4545
+ (void)showTrack:(MWMTrackID)trackId;
4646
+ (void)updatePlacePageData;
47-
47+
+ (void)setPlacePageSelectedCallback:(MWMVoidBlock)selected
48+
deselectedCallback:(MWMBoolBlock)deselected
49+
updatedCallback:(MWMVoidBlock)updated;
4850
@end
4951

5052
NS_ASSUME_NONNULL_END

iphone/CoreApi/CoreApi/Framework/MWMFrameworkHelper.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,12 @@ + (void)updatePlacePageData {
190190
GetFramework().UpdatePlacePageInfoForCurrentSelection();
191191
}
192192

193+
+ (void)setPlacePageSelectedCallback:(MWMVoidBlock)selected
194+
deselectedCallback:(MWMBoolBlock)deselected
195+
updatedCallback:(MWMVoidBlock)updated {
196+
GetFramework().SetPlacePageListeners([selected]() { selected(); },
197+
[deselected](bool switchFullScreen) { deselected(switchFullScreen); },
198+
[updated]() { updated(); });
199+
}
200+
193201
@end

iphone/CoreApi/CoreApi/Metrics/MWMEye.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
#import <UIKit/UIKit.h>
22

3-
typedef NS_ENUM(NSUInteger, MWMTip)
4-
{
5-
MWMTipBookmarks,
6-
MWMTipSearch,
7-
MWMTipDiscovery,
8-
MWMTipSubway,
9-
MWMTipIsolines,
10-
MWMTipNone
11-
};
3+
typedef NS_ENUM(NSUInteger, MWMTipType) {
4+
MWMTipTypeBookmarks,
5+
MWMTipTypeSearch,
6+
MWMTipTypeDiscovery,
7+
MWMTipTypeSubway,
8+
MWMTipTypeIsolines,
9+
MWMTipTypeNone
10+
} NS_SWIFT_NAME(TipType);
1211

13-
typedef NS_ENUM(NSUInteger, MWMTipEvent)
14-
{
12+
typedef NS_ENUM(NSUInteger, MWMTipEvent) {
1513
MWMTipEventAction,
1614
MWMTipEventGotIt
17-
};
15+
} NS_SWIFT_NAME(TipEvent);
1816

19-
typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent)
20-
{
17+
typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent) {
2118
MWMEyeDiscoveryEventHotels,
2219
MWMEyeDiscoveryEventAttractions,
2320
MWMEyeDiscoveryEventCafes,
@@ -28,10 +25,10 @@ typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent)
2825
MWMEyeDiscoveryEventMoreLocals
2926
};
3027

31-
@interface MWMEye : NSObject
28+
@interface MWMEye: NSObject
3229

33-
+ (MWMTip)getTipType;
34-
+ (void)tipClickedWithType:(MWMTip)type event:(MWMTipEvent)event;
30+
+ (MWMTipType)getTipType;
31+
+ (void)tipClickedWithType:(MWMTipType)type event:(MWMTipEvent)event;
3532
+ (void)bookingFilterUsed;
3633
+ (void)boomarksCatalogShown;
3734
+ (void)discoveryShown;

iphone/CoreApi/CoreApi/Metrics/MWMEye.mm

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,36 @@
44

55
@implementation MWMEye
66

7-
+ (MWMTip)getTipType
8-
{
7+
+ (MWMTipType)getTipType {
98
auto tutorialType = GetFramework().GetTipsApi().GetTip();
10-
return tutorialType ? (MWMTip)*tutorialType : MWMTipNone;
9+
return tutorialType ? (MWMTipType)*tutorialType : MWMTipTypeNone;
1110
}
1211

13-
+ (void)tipClickedWithType:(MWMTip)type event:(MWMTipEvent)event
14-
{
12+
+ (void)tipClickedWithType:(MWMTipType)type event:(MWMTipEvent)event {
1513
eye::Eye::Event::TipClicked((eye::Tip::Type)type, (eye::Tip::Event)event);
1614
}
1715

18-
+ (void)bookingFilterUsed
19-
{
16+
+ (void)bookingFilterUsed {
2017
eye::Eye::Event::BookingFilterUsed();
2118
}
2219

23-
+ (void)boomarksCatalogShown
24-
{
20+
+ (void)boomarksCatalogShown {
2521
eye::Eye::Event::BoomarksCatalogShown();
2622
}
2723

28-
+ (void)discoveryShown
29-
{
24+
+ (void)discoveryShown {
3025
eye::Eye::Event::DiscoveryShown();
3126
}
3227

33-
+ (void)discoveryItemClickedWithEvent:(MWMEyeDiscoveryEvent)event
34-
{
28+
+ (void)discoveryItemClickedWithEvent:(MWMEyeDiscoveryEvent)event {
3529
eye::Eye::Event::DiscoveryItemClicked((eye::Discovery::Event)event);
3630
}
3731

38-
+ (void)transitionToBookingWithPos:(CGPoint)pos
39-
{
32+
+ (void)transitionToBookingWithPos:(CGPoint)pos {
4033
eye::Eye::Event::TransitionToBooking({pos.x, pos.y});
4134
}
4235

43-
+ (void)promoAfterBookingShownWithCityId:(NSString *)cityId
44-
{
36+
+ (void)promoAfterBookingShownWithCityId:(NSString *)cityId {
4537
eye::Eye::Event::PromoAfterBookingShown(cityId.UTF8String);
4638
}
4739

iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef NS_ENUM(NSUInteger, MWMMapOverlayIsolinesState) {
2222
MWMMapOverlayIsolinesStateEnabled,
2323
MWMMapOverlayIsolinesStateExpiredData,
2424
MWMMapOverlayIsolinesStateNoData,
25-
} NS_SWIFT_NAME(MapOverlayTransitState);
25+
} NS_SWIFT_NAME(MapOverlayIsolinesState);
2626

2727
typedef NS_ENUM(NSUInteger, MWMMapOverlayGuidesState) {
2828
MWMMapOverlayGuidesStateDisabled,

iphone/Maps/Bookmarks/BookmarksCoordinator.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import UIKit
88
}
99

1010
private weak var navigationController: UINavigationController?
11-
private weak var controlsManager: MWMMapViewControlsManager?
11+
weak var mapControlsViewController: MapControlsViewController?
1212
private weak var navigationManager: MWMNavigationDashboardManager?
1313
private var bookmarksControllers: [UIViewController]?
1414
private var state: BookmarksState = .closed {
@@ -18,10 +18,8 @@ import UIKit
1818
}
1919

2020
@objc init(navigationController: UINavigationController,
21-
controlsManager: MWMMapViewControlsManager,
2221
navigationManager: MWMNavigationDashboardManager) {
2322
self.navigationController = navigationController
24-
self.controlsManager = controlsManager
2523
self.navigationManager = navigationManager
2624
}
2725

@@ -59,11 +57,11 @@ import UIKit
5957
}, completion: nil)
6058
FrameworkHelper.deactivateMapSelection(notifyUI: true)
6159
self.bookmarksControllers = nil
62-
controlsManager?.hideGuidesNavigationBar()
60+
mapControlsViewController?.hideGuidesNavigationBar()
6361
case .closed:
6462
navigationController.popToRootViewController(animated: true)
6563
bookmarksControllers = nil
66-
controlsManager?.hideGuidesNavigationBar()
64+
mapControlsViewController?.hideGuidesNavigationBar()
6765
case let .hidden(categoryId):
6866
UIView.transition(with: self.navigationController!.view,
6967
duration: kDefaultAnimationDuration,
@@ -73,7 +71,7 @@ import UIKit
7371
}, completion: nil)
7472
let isNavigation = navigationManager?.state != .hidden
7573
if isNavigation == false {
76-
controlsManager?.showGuidesNavigationBar(categoryId)
74+
mapControlsViewController?.showGuidesNavigationBar(categoryId)
7775
}
7876
}
7977
}

iphone/Maps/Bridging-Header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
#import "MWMTextToSpeech.h"
8080
#import "MWMTextToSpeechObserver.h"
8181
#import "MWMTextView.h"
82-
#import "MWMTrafficButtonViewController.h"
8382
#import "MWMViewController.h"
8483
#import "MapViewController.h"
8584
#import "MapsAppDelegate.h"

iphone/Maps/Classes/CircleView.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

iphone/Maps/Classes/CircleView.m

Lines changed: 0 additions & 80 deletions
This file was deleted.

iphone/Maps/Classes/CustomAlert/MWMEditorViralAlert.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ - (IBAction)shareTap {
2121
[Statistics logEvent:kStatEditorSecondTimeShareClick];
2222
[self close:^{
2323
MWMActivityViewController* shareVC = [MWMActivityViewController shareControllerForEditorViral];
24-
[shareVC presentInParentViewController:self.alertController.ownerViewController
25-
anchorView:[BottomTabBarViewController controller].view];
24+
// [shareVC presentInParentViewController:self.alertController.ownerViewController
25+
// anchorView:[BottomTabBarViewController controller].view];
2626
}];
2727
}
2828

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
static NSTimeInterval const kMenuViewHideFramesCount = 4.0;
22

3-
static inline NSTimeInterval framesDuration(NSTimeInterval const framesCount)
4-
{
5-
static NSTimeInterval const kFPS = 30.0;
6-
static NSTimeInterval const kFrameDuration = 1.0 / kFPS;
7-
return kFrameDuration * framesCount;
3+
static inline NSTimeInterval framesDuration(NSTimeInterval const framesCount) {
4+
return framesCount / 30;
85
}
96

107
static CGFloat const kViewControlsOffsetToBounds = 6;

iphone/Maps/Classes/CustomViews/MapViewControls/GuidesNavigationBar/GuidesNavigationBarViewController.swift

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class GuidesNavigationBarViewController: UIViewController {
66
@IBOutlet var navigationBar: UINavigationBar!
77
@IBOutlet var navigationBarItem: UINavigationItem!
88

9-
@objc init(categoryId: MWMMarkGroupID) {
9+
init(categoryId: MWMMarkGroupID) {
1010
category = BookmarksManager.shared().category(withId: categoryId)
1111
super.init(nibName: nil, bundle: nil)
1212
}
@@ -31,35 +31,6 @@ class GuidesNavigationBarViewController: UIViewController {
3131
style: .plain,
3232
target: self,
3333
action: #selector(onCancelPessed))
34-
refreshLayout(false)
35-
}
36-
37-
@objc func configLayout() {
38-
guard let superview = view.superview else {
39-
fatalError()
40-
}
41-
42-
NSLayoutConstraint.activate([
43-
view.topAnchor.constraint(equalTo: superview.topAnchor),
44-
view.leftAnchor.constraint(equalTo: superview.leftAnchor),
45-
view.rightAnchor.constraint(equalTo: superview.rightAnchor)
46-
])
47-
}
48-
49-
func refreshLayout(_ animated: Bool = true) {
50-
DispatchQueue.main.async {
51-
let availableArea = self.availableArea
52-
self.view.alpha = min(1, availableArea.height / self.view.height)
53-
}
54-
}
55-
56-
class func updateAvailableArea(_ frame: CGRect) {
57-
guard let controller = MWMMapViewControlsManager.manager()?.guidesNavigationBar,
58-
!controller.availableArea.equalTo(frame) else {
59-
return
60-
}
61-
controller.availableArea = frame
62-
controller.refreshLayout()
6334
}
6435

6536
@objc func onBackPressed(_ sender: Any) {

iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,22 @@
55

66
@class MapViewController;
77
@class BottomTabBarViewController;
8-
@class GuidesNavigationBarViewController;
98
@protocol MWMFeatureHolder;
109

1110
@interface MWMMapViewControlsManager : NSObject
1211

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

15-
@property(nonatomic) BOOL hidden;
16-
@property(nonatomic) BOOL zoomHidden;
17-
@property(nonatomic) BOOL sideButtonsHidden;
18-
@property(nonatomic) BOOL trafficButtonHidden;
1914
@property(nonatomic, readonly) BOOL guidesNavigationBarHidden;
2015
@property(nonatomic) MWMBottomMenuState menuState;
2116
@property(nonatomic) MWMBottomMenuState menuRestoreState;
2217
@property(nonatomic) BOOL isDirectionViewHidden;
23-
@property(nonatomic) BottomTabBarViewController *tabBarController;
24-
@property(nonatomic) GuidesNavigationBarViewController *guidesNavigationBar;
2518

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

2922
- (UIStatusBarStyle)preferredStatusBarStyle;
3023

31-
#pragma mark GuidesNavigationBar
32-
- (void)showGuidesNavigationBar:(MWMMarkGroupID)categoryId;
33-
- (void)hideGuidesNavigationBar;
34-
3524
#pragma mark - Layout
3625

3726
- (UIView *)anchorView;
@@ -62,6 +51,6 @@
6251

6352
- (id<MWMFeatureHolder>)featureHolder;
6453

65-
- (void)showAdditionalViewsIfNeeded;
54+
//- (void)showAdditionalViewsIfNeeded;
6655

6756
@end

0 commit comments

Comments
 (0)