From d94f05b1ea71014ab904658d2f61aa5ef630abba Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Tue, 13 Jun 2017 15:52:02 +0300 Subject: [PATCH] [MAPSME-4728] [ios] Removed old route preview. --- .../Views/RoutePreview/MWMRoutePointCell.h | 17 -- .../Views/RoutePreview/MWMRoutePointCell.m | 29 --- .../Views/RoutePreview/MWMRoutePointCell.xib | 126 ------------- .../Views/RoutePreview/MWMRoutePointLayout.h | 6 - .../Views/RoutePreview/MWMRoutePointLayout.mm | 66 ------- .../Views/RoutePreview/MWMRoutePreview.h | 2 - .../Views/RoutePreview/MWMRoutePreview.mm | 177 +----------------- .../Views/RoutePreview/MWMRoutePreview.xib | 60 ++---- .../RoutePreview/MWMiPadRoutePreview.xib | 62 +++--- iphone/Maps/Core/Routing/MWMRouter.mm | 2 - iphone/Maps/Maps.xcodeproj/project.pbxproj | 36 ---- 11 files changed, 50 insertions(+), 533 deletions(-) delete mode 100644 iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.h delete mode 100644 iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.m delete mode 100644 iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.xib delete mode 100644 iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.h delete mode 100644 iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.mm diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.h deleted file mode 100644 index 4a160d3045..0000000000 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.h +++ /dev/null @@ -1,17 +0,0 @@ -@class MWMRoutePointCell; - -@protocol MWMRoutePointCellDelegate - -@required -- (void)didPan:(UIPanGestureRecognizer *)pan cell:(MWMRoutePointCell *)cell; -- (void)startEditingCell:(MWMRoutePointCell *)cell; - -@end - -@interface MWMRoutePointCell : UICollectionViewCell - -@property (weak, nonatomic) IBOutlet UITextField * title; -@property (weak, nonatomic) IBOutlet UILabel * number; -@property (weak, nonatomic) id delegate; - -@end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.m b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.m deleted file mode 100644 index 04db02eff6..0000000000 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.m +++ /dev/null @@ -1,29 +0,0 @@ -#import "MWMRoutePointCell.h" - -@interface MWMRoutePointCell () - -@property (weak, nonatomic) IBOutlet UIView * moveView; - -@end - -@implementation MWMRoutePointCell - -- (void)awakeFromNib -{ - [super awakeFromNib]; - UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)]; - [self.moveView addGestureRecognizer:pan]; -} - -- (void)didPan:(UIPanGestureRecognizer *)sender -{ - [self.delegate didPan:sender cell:self]; -} - -- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField -{ - [self.delegate startEditingCell:self]; - return NO; -} - -@end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.xib deleted file mode 100644 index 155f9204f3..0000000000 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointCell.xib +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.h deleted file mode 100644 index 43364cdfa8..0000000000 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.h +++ /dev/null @@ -1,6 +0,0 @@ -@interface MWMRoutePointLayout : UICollectionViewFlowLayout - -@property (nonatomic) BOOL isNeedToInitialLayout; -@property (weak, nonatomic) IBOutlet UIView * parentView; - -@end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.mm deleted file mode 100644 index b108d6c6f0..0000000000 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePointLayout.mm +++ /dev/null @@ -1,66 +0,0 @@ -#import "MWMRoutePointLayout.h" - -static CGFloat const kHeight = 36.; - -@implementation MWMRoutePointLayout - -- (instancetype)initWithCoder:(NSCoder *)aDecoder -{ - self = [super initWithCoder:aDecoder]; - if (self) - self.isNeedToInitialLayout = YES; - return self; -} - -- (CGSize)collectionViewContentSize -{ - return self.collectionView.bounds.size; -} - -- (CGFloat)minimumLineSpacing -{ - return 8.; -} - -- (CGFloat)minimumInteritemSpacing -{ - return 8.; -} - -- (CGSize)itemSize -{ - if (IPAD) - return {304., kHeight}; - return self.actualSize; -} - -- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath -{ - if (!self.isNeedToInitialLayout) - return nil; - UICollectionViewLayoutAttributes * attr = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:itemIndexPath]; - attr.alpha = 0.; - return attr; -} - -- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath -{ - UICollectionViewLayoutAttributes * attr = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath]; - attr.center = {self.collectionView.midX, self.collectionView.maxY}; - return attr; -} - -- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds -{ - self.itemSize = self.actualSize; - return YES; -} - -- (CGSize)actualSize -{ - BOOL const isPortrait = self.parentView.superview.height > self.parentView.superview.width; - CGFloat const width = isPortrait ? self.collectionView.width : self.collectionView.width / 2. - self.minimumInteritemSpacing / 2.; - return {width, kHeight}; -} - -@end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h index 3e122a0589..2b83dc946c 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h @@ -8,14 +8,12 @@ @interface MWMRoutePreview : MWMNavigationView -@property(weak, nonatomic, readonly) IBOutlet UIButton * extendButton; @property(weak, nonatomic, readonly) IBOutlet MWMTaxiCollectionView * taxiCollectionView; @property(weak, nonatomic) MWMNavigationDashboardManager * dashboardManager; - (void)statePrepare; - (void)stateError; - (void)stateReady; -- (void)reloadData; - (void)selectRouter:(MWMRouterType)routerType; - (void)router:(MWMRouterType)routerType setState:(MWMCircularProgressState)state; - (void)router:(MWMRouterType)routerType setProgress:(CGFloat)progress; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm index e70b37dff4..ae15528593 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm @@ -2,8 +2,6 @@ #import "MWMCircularProgress.h" #import "MWMCommon.h" #import "MWMNavigationDashboardManager.h" -#import "MWMRoutePointCell.h" -#import "MWMRoutePointLayout.h" #import "MWMRouter.h" #import "MWMTaxiPreviewDataSource.h" #import "Statistics.h" @@ -16,19 +14,14 @@ namespace CGFloat constexpr kAdditionalHeight = 20.; } // namespace -@interface MWMRoutePreview () +@interface MWMRoutePreview () @property(weak, nonatomic) IBOutlet UIButton * backButton; @property(weak, nonatomic) IBOutlet UIView * pedestrian; @property(weak, nonatomic) IBOutlet UIView * vehicle; @property(weak, nonatomic) IBOutlet UIView * bicycle; @property(weak, nonatomic) IBOutlet UIView * taxi; -@property(weak, nonatomic) IBOutlet NSLayoutConstraint * planningRouteViewHeight; -@property(weak, nonatomic) IBOutlet UIButton * extendButton; @property(weak, nonatomic) IBOutlet UIButton * goButton; -@property(weak, nonatomic) IBOutlet UICollectionView * collectionView; -@property(weak, nonatomic) IBOutlet MWMRoutePointLayout * layout; -@property(weak, nonatomic) IBOutlet UIImageView * arrowImageView; @property(weak, nonatomic) IBOutlet UIView * statusBox; @property(weak, nonatomic) IBOutlet UIView * planningBox; @property(weak, nonatomic) IBOutlet UIView * resultsBox; @@ -65,7 +58,6 @@ CGFloat constexpr kAdditionalHeight = 20.; self.autoresizingMask = UIViewAutoresizingFlexibleWidth; self.layer.shouldRasterize = YES; self.layer.rasterizationScale = UIScreen.mainScreen.scale; - [self.collectionView registerWithCellClass:[MWMRoutePointCell class]]; [self setupProgresses]; [self.backButton matchInterfaceOrientation]; @@ -113,13 +105,9 @@ CGFloat constexpr kAdditionalHeight = 20.; for (auto const & progress : m_progresses) progress.second.state = MWMCircularProgressStateNormal; - self.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI); self.goButton.hidden = NO; self.goButton.enabled = NO; - self.extendButton.selected = YES; [self setupActualHeight]; - [self reloadData]; - [self.layout invalidateLayout]; self.statusBox.hidden = YES; self.resultsBox.hidden = YES; self.heightBox.hidden = YES; @@ -218,7 +206,6 @@ CGFloat constexpr kAdditionalHeight = 20.; }]; } -- (void)reloadData { [self.collectionView reloadData]; } - (void)selectRouter:(MWMRouterType)routerType { for (auto const & progress : m_progresses) @@ -296,62 +283,15 @@ CGFloat constexpr kAdditionalHeight = 20.; return {{origin, self.topBound}, {width, self.superview.height - kAdditionalHeight}}; } -- (CGFloat)visibleHeight { return self.planningRouteViewHeight.constant + kAdditionalHeight; } -- (IBAction)extendTap -{ - BOOL const isExtended = !self.extendButton.selected; - [Statistics logEvent:kStatEventName(kStatPointToPoint, kStatExpand) - withParameters:@{kStatValue : (isExtended ? kStatYes : kStatNo)}]; - self.extendButton.selected = isExtended; - [self layoutIfNeeded]; - [self setupActualHeight]; - [UIView animateWithDuration:kDefaultAnimationDuration - animations:^{ - self.arrowImageView.transform = isExtended - ? CGAffineTransformMakeRotation(M_PI) - : CGAffineTransformIdentity; - [self layoutIfNeeded]; - }]; -} - - (void)setupActualHeight { if (!self.superview) return; - if (IPAD) - { - CGFloat const selfHeight = self.superview.height - kAdditionalHeight; - self.defaultHeight = selfHeight; - self.height = selfHeight; - return; - } - BOOL const isPortrait = self.superview.height > self.superview.width; - CGFloat const height = isPortrait ? 140. : 96.; - CGFloat const selfHeight = self.extendButton.selected ? height : 44.; - self.planningRouteViewHeight.constant = selfHeight; + CGFloat const selfHeight = IPAD ? self.superview.height - kAdditionalHeight : 44; self.defaultHeight = selfHeight; self.height = selfHeight; } -- (void)snapshotCell:(MWMRoutePointCell *)cell -{ - UIGraphicsBeginImageContextWithOptions(cell.bounds.size, NO, 0.); - [cell drawViewHierarchyInRect:cell.bounds afterScreenUpdates:YES]; - UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - self.movingCellImage = [[UIImageView alloc] initWithImage:image]; - self.movingCellImage.alpha = 0.8; - [self.collectionView addSubview:self.movingCellImage]; - CALayer * l = self.movingCellImage.layer; - l.masksToBounds = NO; - l.shadowColor = UIColor.blackColor.CGColor; - l.shadowRadius = 4.; - l.shadowOpacity = 0.4; - l.shadowOffset = {0., 0.}; - l.shouldRasterize = YES; - l.rasterizationScale = [[UIScreen mainScreen] scale]; -} - #pragma mark - MWMNavigationDashboardInfoProtocol - (void)updateNavigationInfo:(MWMNavigationDashboardEntity *)info @@ -367,119 +307,6 @@ CGFloat constexpr kAdditionalHeight = 20.; self.arriveLabel.text = [NSString stringWithFormat:L(@"routing_arrive"), arriveStr.UTF8String]; } -#pragma mark - MWMRoutePointCellDelegate - -- (void)startEditingCell:(MWMRoutePointCell *)cell -{ - NSUInteger const index = [self.collectionView indexPathForCell:cell].row; - [self.dashboardManager.delegate didStartEditingRoutePoint:index == 0]; -} - -#pragma mark - PanGestureRecognizer - -- (void)didPan:(UIPanGestureRecognizer *)pan cell:(MWMRoutePointCell *)cell -{ - CGPoint const locationPoint = [pan locationInView:self.collectionView]; - if (pan.state == UIGestureRecognizerStateBegan) - { - self.layout.isNeedToInitialLayout = NO; - self.isNeedToMove = NO; - self.indexPathOfMovingCell = [self.collectionView indexPathForCell:cell]; - [self snapshotCell:cell]; - [UIView animateWithDuration:kDefaultAnimationDuration - animations:^{ - cell.contentView.alpha = 0.; - CGFloat const scaleY = 1.05; - self.movingCellImage.transform = CGAffineTransformMakeScale(1., scaleY); - }]; - } - - if (pan.state == UIGestureRecognizerStateChanged) - { - self.movingCellImage.center = {locationPoint.x - cell.width / 2 + 30, locationPoint.y}; - NSIndexPath * finalIndexPath = [self.collectionView indexPathForItemAtPoint:locationPoint]; - if (finalIndexPath && ![finalIndexPath isEqual:self.indexPathOfMovingCell]) - { - if (self.isNeedToMove) - return; - self.isNeedToMove = YES; - [self.collectionView performBatchUpdates:^{ - [self.collectionView moveItemAtIndexPath:finalIndexPath - toIndexPath:self.indexPathOfMovingCell]; - self.indexPathOfMovingCell = finalIndexPath; - } - completion:nil]; - } - else - { - self.isNeedToMove = NO; - } - } - - if (pan.state == UIGestureRecognizerStateEnded) - { - self.layout.isNeedToInitialLayout = YES; - NSIndexPath * finalIndexPath = [self.collectionView indexPathForItemAtPoint:locationPoint]; - self.isNeedToMove = finalIndexPath && ![finalIndexPath isEqual:self.indexPathOfMovingCell]; - if (self.isNeedToMove) - { - cell.contentView.alpha = 1.; - [self.collectionView performBatchUpdates:^{ - [self.collectionView moveItemAtIndexPath:self.indexPathOfMovingCell - toIndexPath:finalIndexPath]; - } - completion:^(BOOL finished) { - [self.movingCellImage removeFromSuperview]; - self.movingCellImage.transform = CGAffineTransformIdentity; - }]; - } - else - { - cell.contentView.alpha = 1.; - [self.movingCellImage removeFromSuperview]; - [[MWMRouter router] swapPointsAndRebuild]; - [self reloadData]; - } - } -} - -@end - -#pragma mark - UICollectionView - -@interface MWMRoutePreview (UICollectionView) - -@end - -@implementation MWMRoutePreview (UICollectionView) - -- (NSInteger)collectionView:(UICollectionView *)collectionView - numberOfItemsInSection:(NSInteger)section -{ - return 2; -} - -- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView - cellForItemAtIndexPath:(NSIndexPath *)indexPath -{ - Class cls = [MWMRoutePointCell class]; - auto cell = static_cast( - [collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath]); - cell.number.text = @(indexPath.row + 1).stringValue; - if (indexPath.row == 0) - { - cell.title.text = [MWMRouter router].startPoint.name; - cell.title.placeholder = L(@"p2p_from"); - } - else - { - cell.title.text = [MWMRouter router].finishPoint.name; - cell.title.placeholder = L(@"p2p_to"); - } - cell.delegate = self; - return cell; -} - #pragma mark - VisibleArea - (MWMVisibleAreaAffectDirection)visibleAreaAffectDirection diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib index d8f94215b6..d8cafc99d0 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib @@ -1,7 +1,11 @@ - + + + + - + + @@ -12,12 +16,14 @@ - + + + + @@ -37,6 +45,7 @@ + @@ -44,6 +53,7 @@ + @@ -51,6 +61,7 @@ + @@ -72,49 +83,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - @@ -130,15 +106,10 @@ - - - - - @@ -146,7 +117,6 @@ - diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib index cec95551e3..abd17e021c 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib @@ -1,8 +1,11 @@ - + + + + - + @@ -23,8 +26,10 @@ + + + + + + @@ -78,48 +88,28 @@ - - - - - - - - - - - - - - - - - - - - - + - - - + + + + + + + + - + + + @@ -242,8 +244,10 @@ +