diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift
index e57d669d56..b0b43c5d4a 100644
--- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift
+++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift
@@ -33,7 +33,9 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
self.indexPath = indexPath
addSubView(cell: cell, dragPoint: dragPoint)
controller.tableView.heightUpdateStyle = .off
- controller.dimView.state = .visible
+ if controller.canDeleteRow {
+ controller.dimView.state = .visible
+ }
}
private func addSubView(cell: UITableViewCell, dragPoint: CGPoint) {
@@ -51,7 +53,9 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
func move(dragPoint: CGPoint, indexPath: IndexPath?, inManagerView: Bool) {
snapshot.center = dragPoint
- controller.dimView.state = inManagerView ? .visible : .binOpenned
+ if controller.canDeleteRow {
+ controller.dimView.state = inManagerView ? .visible : .binOpenned
+ }
guard let newIP = indexPath else { return }
let tv = controller.tableView!
let cell = tv.cellForRow(at: newIP)
@@ -87,7 +91,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
}
let containerView = controller.containerView!
let tv = controller.tableView!
- if inManagerView {
+ if inManagerView || !controller.canDeleteRow {
let dropCenter = tv.cellForRow(at: indexPath)?.center ?? snapshot.center
UIView.animate(withDuration: kDefaultAnimationDuration,
animations: { [snapshot] in
@@ -99,9 +103,11 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
removeSnapshot()
})
} else {
- controller.viewModel.deletePoint(at: indexPath.row)
tv.heightUpdateStyle = .animated
- tv.deleteRows(at: [indexPath], with: .automatic)
+ tv.update {
+ controller.viewModel.deletePoint(at: indexPath.row)
+ tv.deleteRows(at: [indexPath], with: .automatic)
+ }
let dimView = controller.dimView!
UIView.animate(withDuration: kDefaultAnimationDuration,
animations: { [snapshot] in
@@ -147,6 +153,11 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
}
}
viewModel.refreshControlsCallback()
+
+ viewModel.reloadCallback = { [tableView] in
+ tableView?.reloadSections(IndexSet(integer: 0), with: .fade)
+ }
+
viewModel.startTransaction()
}
@@ -201,8 +212,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource
})
}
- @IBAction private func longPressGestureRecognized(_ longPress: UILongPressGestureRecognizer) {
- guard canDeleteRow else { return }
+ @IBAction private func gestureRecognized(_ longPress: UIGestureRecognizer) {
let locationInView = gestureLocation(longPress, in: containerView)
let locationInTableView = gestureLocation(longPress, in: tableView)
switch longPress.state {
diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.xib
index 6fa619e238..308392a711 100644
--- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.xib
+++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.xib
@@ -197,7 +197,7 @@
-
+
@@ -229,16 +229,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModel.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModel.swift
index d2a9c4d01c..57ff63eb14 100644
--- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModel.swift
+++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModel.swift
@@ -2,6 +2,7 @@
final class RouteManagerViewModel: NSObject, RouteManagerViewModelProtocol {
var routePoints: [MWMRoutePoint] { return MWMRouter.points() }
var refreshControlsCallback: (() -> Void)!
+ var reloadCallback: (() -> Void)!
func startTransaction() { MWMRouter.openRouteManagerTransaction() }
@@ -26,5 +27,6 @@ final class RouteManagerViewModel: NSObject, RouteManagerViewModelProtocol {
MWMRouter.removePoint(routePoints[index])
MWMRouter.updatePreviewMode()
refreshControlsCallback()
+ reloadCallback()
}
}
diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModelProtocol.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModelProtocol.swift
index 1dcd471daf..85133766d6 100644
--- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModelProtocol.swift
+++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModelProtocol.swift
@@ -3,6 +3,7 @@ protocol RouteManagerViewModelProtocol: class {
var routePoints: [MWMRoutePoint] { get }
var refreshControlsCallback: (() -> Void)! { get set }
+ var reloadCallback: (() -> Void)! { get set }
func startTransaction()
func finishTransaction()
diff --git a/iphone/Maps/Core/Routing/MWMRoutePoint.mm b/iphone/Maps/Core/Routing/MWMRoutePoint.mm
index 54b5f3b667..492497906c 100644
--- a/iphone/Maps/Core/Routing/MWMRoutePoint.mm
+++ b/iphone/Maps/Core/Routing/MWMRoutePoint.mm
@@ -32,6 +32,8 @@
_isMyPosition = YES;
_type = type;
_intermediateIndex = intermediateIndex;
+
+ [self validatePoint];
}
return self;
}
@@ -49,6 +51,8 @@
_isMyPosition = NO;
_type = type;
_intermediateIndex = intermediateIndex;
+
+ [self validatePoint];
}
return self;
}
@@ -69,6 +73,8 @@
case RouteMarkType::Intermediate: _type = MWMRoutePointTypeIntermediate; break;
case RouteMarkType::Finish: _type = MWMRoutePointTypeFinish; break;
}
+
+ [self validatePoint];
}
return self;
}
@@ -88,10 +94,17 @@
_isMyPosition = NO;
_type = type;
_intermediateIndex = intermediateIndex;
+
+ [self validatePoint];
}
return self;
}
+- (void)validatePoint
+{
+ NSAssert(_intermediateIndex >= 0 && _intermediateIndex <= 2, @"Invalid intermediateIndex");
+}
+
- (double)latitude { return MercatorBounds::YToLat(self.point.y); }
- (double)longitude { return MercatorBounds::XToLon(self.point.x); }
@@ -102,6 +115,8 @@
- (RouteMarkData)routeMarkData
{
+ [self validatePoint];
+
RouteMarkData pt;
switch (self.type)
{
@@ -117,4 +132,21 @@
return pt;
}
+- (NSString *)debugDescription
+{
+ NSString * type = nil;
+ switch (_type)
+ {
+ case MWMRoutePointTypeStart: type = @"Start"; break;
+ case MWMRoutePointTypeIntermediate: type = @"Intermediate"; break;
+ case MWMRoutePointTypeFinish: type = @"Finish"; break;
+ }
+
+ return [NSString stringWithFormat:@"<%@: %p> Position: [%@, %@] | IsMyPosition: %@ | Type: %@ | "
+ @"IntermediateIndex: %@ | Title: %@ | Subtitle: %@",
+ [self class], self, @(_point.x), @(_point.y),
+ _isMyPosition ? @"true" : @"false", type, @(_intermediateIndex),
+ _title, _subtitle];
+}
+
@end