[MAPSME-5513] [ios] Fixed route evelation for iPhone.

This commit is contained in:
Ilya Grechuhin 2017-09-01 12:38:55 +03:00 committed by Vladimir Byko-Ianko
parent d5a7f6cdc7
commit 939456efa6
5 changed files with 58 additions and 30 deletions

View file

@ -1,6 +1,7 @@
@interface MWMNavigationDashboardEntity : NSObject
@property(copy, nonatomic, readonly) NSAttributedString * estimate;
@property(copy, nonatomic, readonly) NSAttributedString * estimateDot;
@property(copy, nonatomic, readonly) NSString * distanceToTurn;
@property(copy, nonatomic, readonly) NSString * streetName;
@property(copy, nonatomic, readonly) NSString * targetDistance;

View file

@ -9,6 +9,7 @@
@interface MWMNavigationDashboardEntity ()
@property(copy, nonatomic, readwrite) NSAttributedString * estimate;
@property(copy, nonatomic, readwrite) NSAttributedString * estimateDot;
@property(copy, nonatomic, readwrite) NSString * distanceToTurn;
@property(copy, nonatomic, readwrite) NSString * streetName;
@property(copy, nonatomic, readwrite) NSString * targetDistance;
@ -50,4 +51,15 @@
timeStyle:NSDateFormatterShortStyle];
}
- (NSAttributedString *)estimateDot
{
if (!_estimateDot)
{
auto attributes = @{NSForegroundColorAttributeName : [UIColor blackSecondaryText],
NSFontAttributeName : [UIFont medium17]};
_estimateDot = [[NSAttributedString alloc] initWithString:@" • " attributes:attributes];
}
return _estimateDot;
}
@end

View file

@ -98,11 +98,10 @@ UIImage * image(routing::turns::CarDirection t, bool isNextTurn)
entity.nextTurnImage = image(info.m_nextTurn, true);
NSString * eta = [NSDateComponentsFormatter etaStringFrom:entity.timeToTarget];
NSString * resultString =
[NSString stringWithFormat:@"%@ • %@ %@", eta, entity.targetDistance, entity.targetUnits];
NSMutableAttributedString * result =
[[NSMutableAttributedString alloc] initWithString:resultString];
[result addAttributes:self.etaAttributes range:NSMakeRange(0, resultString.length)];
auto result = [[NSMutableAttributedString alloc] initWithString:eta attributes:self.etaAttributes];
[result appendAttributedString:entity.estimateDot];
auto target = [NSString stringWithFormat:@"%@ %@", entity.targetDistance, entity.targetUnits];
[result appendAttributedString:[[NSAttributedString alloc] initWithString:target attributes:self.etaAttributes]];
entity.estimate = result;
using namespace routing::turns;

View file

@ -151,7 +151,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="64"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="results" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zml-eW-DsI">
<rect key="frame" x="16" y="14" width="289" height="20"/>
<rect key="frame" x="16" y="14" width="303" height="20"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
@ -161,7 +161,7 @@
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Arrive at 12:24" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oec-Ee-6ha">
<rect key="frame" x="16" y="38" width="289" height="17"/>
<rect key="frame" x="16" y="38" width="303" height="17"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
@ -185,20 +185,10 @@
<rect key="frame" x="0.0" y="64" width="375" height="68"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rXP-rM-9cx">
<rect key="frame" x="309" y="-46" width="50" height="12"/>
<rect key="frame" x="323" y="-48" width="36" height="17"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_elevation" translatesAutoresizingMaskIntoConstraints="NO" id="Ac5-gf-3tf">
<rect key="frame" x="0.0" y="0.0" width="10" height="12"/>
<constraints>
<constraint firstAttribute="width" constant="10" id="R4J-Uu-52U"/>
<constraint firstAttribute="height" constant="12" id="v5V-2M-Fnx"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="coloring" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="260" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JtS-om-arD">
<rect key="frame" x="14" y="-2.5" width="36" height="17"/>
<rect key="frame" x="0.0" y="0.0" width="36" height="17"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@ -210,12 +200,10 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Ac5-gf-3tf" firstAttribute="leading" secondItem="rXP-rM-9cx" secondAttribute="leading" id="2Df-WK-py6"/>
<constraint firstItem="JtS-om-arD" firstAttribute="leading" secondItem="rXP-rM-9cx" secondAttribute="leading" id="6FT-YG-m3k"/>
<constraint firstAttribute="bottom" secondItem="JtS-om-arD" secondAttribute="bottom" id="B8p-TU-ROs"/>
<constraint firstAttribute="trailing" secondItem="JtS-om-arD" secondAttribute="trailing" id="CK8-gu-qaf"/>
<constraint firstAttribute="bottom" secondItem="Ac5-gf-3tf" secondAttribute="bottom" id="ULt-mY-leX"/>
<constraint firstItem="JtS-om-arD" firstAttribute="centerY" secondItem="Ac5-gf-3tf" secondAttribute="centerY" id="mrf-cl-Rte"/>
<constraint firstItem="Ac5-gf-3tf" firstAttribute="top" secondItem="rXP-rM-9cx" secondAttribute="top" id="pUr-w4-lnd"/>
<constraint firstItem="JtS-om-arD" firstAttribute="leading" secondItem="Ac5-gf-3tf" secondAttribute="trailing" constant="4" id="qQ6-yw-n2d"/>
<constraint firstItem="JtS-om-arD" firstAttribute="top" secondItem="rXP-rM-9cx" secondAttribute="top" id="szb-xc-aoe"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Apa-nH-KWJ">
@ -257,7 +245,7 @@
</userDefinedRuntimeAttributes>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NAs-km-8uw">
<rect key="frame" x="20" y="15" width="119" height="18"/>
<rect key="frame" x="20" y="12" width="127" height="24"/>
<inset key="contentEdgeInsets" minX="8" minY="0.0" maxX="0.0" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="-16" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="ManageRoute" image="ic_24px_manager"/>
@ -445,8 +433,7 @@
</view>
</objects>
<resources>
<image name="ic_24px_manager" width="16" height="16"/>
<image name="ic_elevation" width="10" height="12"/>
<image name="ic_24px_manager" width="24" height="24"/>
<image name="ic_nav_bar_back" width="14" height="22"/>
</resources>
</document>

View file

@ -39,6 +39,16 @@ final class RoutePreviewStatus: SolidTouchView {
private var hiddenConstraint: NSLayoutConstraint!
weak var ownerView: UIView!
weak var navigationInfo: MWMNavigationDashboardEntity?
var elevation: NSAttributedString? {
didSet {
guard let elevation = elevation else { return }
alternative(iPhone: { self.updateResultsLabel() },
iPad: { self.heightProfileElevationHeight?.attributedText = elevation })()
}
}
var isVisible = false {
didSet {
alternative(iPhone: {
@ -146,8 +156,12 @@ final class RoutePreviewStatus: SolidTouchView {
heightBox.isHidden = false
MWMRouter.routeAltitudeImage(for: heightProfileImage.frame.size,
completion: { image, elevation in
self.heightProfileImage.image = image
self.heightProfileElevationHeight?.text = elevation
self.heightProfileImage.image = image
if let elevation = elevation {
let attributes: [String : Any] = [NSForegroundColorAttributeName : UIColor.linkBlue(),
NSFontAttributeName : UIFont.medium14()]
self.elevation = NSAttributedString(string: "▲▼ \(elevation)", attributes: attributes)
}
})
} else {
heightBox.isHidden = true
@ -161,8 +175,23 @@ final class RoutePreviewStatus: SolidTouchView {
isVisible = false
}
private func updateResultsLabel() {
guard let info = navigationInfo else { return }
resultLabel.attributedText = alternative(iPhone: {
let result = info.estimate.mutableCopy() as! NSMutableAttributedString
if let elevation = self.elevation {
result.append(info.estimateDot)
result.append(elevation)
}
return result.copy() as? NSAttributedString
},
iPad: { info.estimate })()
}
func onNavigationInfoUpdated(_ info: MWMNavigationDashboardEntity) {
resultLabel.attributedText = info.estimate
navigationInfo = info
updateResultsLabel()
arriveLabel?.text = String(coreFormat: L("routing_arrive"), arguments: [info.arrival])
}