[iOS] Added "Distance: " prefix to ruler route lower panel

Signed-off-by: S. Kozyr <s.trump@gmail.com>
This commit is contained in:
Sergiy Kozyr 2023-08-27 13:16:12 +03:00 committed by Viktor Govako
parent a168138f59
commit 82cb2df135
4 changed files with 27 additions and 17 deletions

View file

@ -6,7 +6,7 @@
#import "SwiftBridge.h"
#import <AudioToolbox/AudioServices.h>
#include <CoreApi/Framework.h>
#import <CoreApi/Framework.h>
#include "routing/following_info.hpp"
#include "routing/turns.hpp"
@ -101,25 +101,26 @@ NSAttributedString *estimate(NSTimeInterval time, NSString *distance, NSString *
}
NSArray<MWMRouterTransitStepInfo *> *buildRouteTransitSteps(NSArray<MWMRoutePoint *> *points) {
NSMutableArray<MWMRouterTransitStepInfo *> *steps = [NSMutableArray arrayWithCapacity:[points count]*2-1];
// Generate step info in format: (Segment 1 distance) (1) (Segment 2 distance) (2) ... (n-1) (Segment N distance).
NSMutableArray<MWMRouterTransitStepInfo *> *steps = [NSMutableArray arrayWithCapacity:[points count] * 2 - 1];
auto const numPoints = [points count];
for (int i = 0; i < numPoints-1; i++) {
for (int i = 0; i < numPoints - 1; i++) {
MWMRoutePoint* segmentStart = points[i];
MWMRoutePoint* segmentEnd = points[i+1];
MWMRoutePoint* segmentEnd = points[i + 1];
auto const distance = platform::Distance::CreateFormatted(
ms::DistanceOnEarth(segmentStart.latitude, segmentStart.longitude, segmentEnd.latitude, segmentEnd.longitude));
ms::DistanceOnEarth(segmentStart.latitude, segmentStart.longitude, segmentEnd.latitude, segmentEnd.longitude));
MWMRouterTransitStepInfo* segmentInfo = [[MWMRouterTransitStepInfo alloc] init];
segmentInfo.type = MWMRouterTransitTypeRuler;
segmentInfo.distance = @(distance.GetDistanceString().c_str());
segmentInfo.distanceUnits = @(distance.GetUnitsString().c_str());
steps[i*2] = segmentInfo;
steps[i * 2] = segmentInfo;
if (i < numPoints-2) {
if (i < numPoints - 2) {
MWMRouterTransitStepInfo* stopInfo = [[MWMRouterTransitStepInfo alloc] init];
stopInfo.type = MWMRouterTransitTypeIntermediatePoint;
stopInfo.intermediateIndex = i;
steps[i*2+1] = stopInfo;
steps[i * 2 + 1] = stopInfo;
}
}
@ -193,7 +194,7 @@ NSArray<MWMRouterTransitStepInfo *> *buildRouteTransitSteps(NSArray<MWMRoutePoin
}
if (auto entity = self.entity) {
BOOL showEta = (type != MWMRouterTypeRuler);
BOOL const showEta = (type != MWMRouterTypeRuler);
entity.isValid = YES;
entity.timeToTarget = info.m_time;

View file

@ -82,8 +82,10 @@ NSString *const kNavigationControlViewXibName = @"NavigationControlView";
if (!entity.isValid)
return;
[_navigationInfoView onNavigationInfoUpdated:entity];
if ([MWMRouter type] == MWMRouterTypePublicTransport || [MWMRouter type] == MWMRouterTypeRuler)
[_transportRoutePreviewStatus onNavigationInfoUpdated:entity];
bool const isPublicTransport = [MWMRouter type] == MWMRouterTypePublicTransport;
bool const isRuler = [MWMRouter type] == MWMRouterTypeRuler;
if (isPublicTransport || isRuler)
[_transportRoutePreviewStatus onNavigationInfoUpdated:entity prependDistance:isRuler];
else
[_baseRoutePreviewStatus onNavigationInfoUpdated:entity];
[_navigationControlView onNavigationInfoUpdated:entity];
@ -176,13 +178,13 @@ NSString *const kNavigationControlViewXibName = @"NavigationControlView";
NSAssert(_state == MWMNavigationDashboardStatePlanning || _state == MWMNavigationDashboardStateReady, @"Invalid state change (ready)");
[self setRouteBuilderProgress:100.];
[self updateGoButtonTitle];
auto const isTransport = ([MWMRouter type] == MWMRouterTypePublicTransport);
auto const isRuler = ([MWMRouter type] == MWMRouterTypeRuler);
bool const isTransport = ([MWMRouter type] == MWMRouterTypePublicTransport);
bool const isRuler = ([MWMRouter type] == MWMRouterTypeRuler);
if (isTransport || isRuler)
[self.transportRoutePreviewStatus showReady];
else
[self.baseRoutePreviewStatus showReady];
self.goButtonsContainer.hidden = (isTransport || isRuler);
self.goButtonsContainer.hidden = isTransport || isRuler;
for (MWMRouteStartButton *button in self.goButtons)
{
if (isRuler)

View file

@ -38,9 +38,16 @@ final class TransportRoutePreviewStatus: SolidTouchView {
updateHeight()
}
@objc func onNavigationInfoUpdated(_ info: MWMNavigationDashboardEntity) {
@objc func onNavigationInfoUpdated(_ info: MWMNavigationDashboardEntity, prependDistance: Bool) {
navigationInfo = info
etaLabel.attributedText = info.estimate
if (prependDistance) {
let labelText = NSMutableAttributedString(string: NSLocalizedString("placepage_distance", comment: "") + ": ")
labelText.append(info.estimate)
etaLabel.attributedText = labelText
}
else {
etaLabel.attributedText = info.estimate
}
stepsCollectionView.steps = info.transitSteps
// TODO: even when stepsCollectionView is hidden it still takes space in layout

View file

@ -21,7 +21,7 @@ final class TransportTransitStepsCollectionView: UICollectionView {
super.awakeFromNib()
dataSource = self
[TransportTransitIntermediatePoint.self, TransportTransitPedestrian.self,
TransportTransitTrain.self, TransportRuler.self].forEach {
TransportTransitTrain.self, TransportRuler.self].forEach {
register(cellClass: $0)
}
}