[ios] modify search result description to be multiline

Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com>
This commit is contained in:
David Martinez 2022-07-22 00:16:04 +02:00 committed by Alexander Borsuk
parent f9010b4aac
commit ab568b42d5
2 changed files with 17 additions and 55 deletions

View file

@ -20,9 +20,7 @@ bool PopularityHasHigherPriority(bool hasPosition, double distanceInMeters)
@property(weak, nonatomic) IBOutlet UILabel * distanceLabel;
@property(weak, nonatomic) IBOutlet UILabel * infoLabel;
@property(weak, nonatomic) IBOutlet UILabel * locationLabel;
@property(weak, nonatomic) IBOutlet UILabel * typeLabel;
@property(weak, nonatomic) IBOutlet UILabel * openLabel;
@property(weak, nonatomic) IBOutlet UIView * infoView;
@property(weak, nonatomic) IBOutlet UIView * popularView;
@end
@ -35,8 +33,6 @@ bool PopularityHasHigherPriority(bool hasPosition, double distanceInMeters)
{
[super config:result localizedTypeName:localizedTypeName];
self.typeLabel.text = localizedTypeName;
self.locationLabel.text = @(result.GetAddress().c_str());
[self.locationLabel sizeToFit];
@ -47,22 +43,27 @@ bool PopularityHasHigherPriority(bool hasPosition, double distanceInMeters)
NSString * brand = @"";
if (!result.GetBrand().empty())
brand = @(platform::GetLocalizedBrandName(result.GetBrand()).c_str());
NSString * description = @"";
static NSString * fiveStars = [NSString stringWithUTF8String:"★★★★★"];
if (starsCount > 0)
[self setInfoText:[fiveStars substringToIndex:starsCount]];
description = [fiveStars substringToIndex:starsCount];
else if (airportIata.length > 0)
[self setInfoText:airportIata];
description = airportIata;
else if (roadShields.length > 0)
[self setInfoText:roadShields];
description = roadShields;
else if (brand.length > 0 && cuisine.length > 0)
[self setInfoText:[NSString stringWithFormat:@"%@ • %@", brand, cuisine]];
description = [NSString stringWithFormat:@"%@ • %@", brand, cuisine];
else if (brand.length > 0)
[self setInfoText:brand];
description = brand;
else if (cuisine.length > 0)
[self setInfoText:cuisine];
description = cuisine;
if ([description length] == 0)
self.infoLabel.text = localizedTypeName;
else
[self clearInfo];
self.infoLabel.text = [NSString stringWithFormat:@"%@ • %@", localizedTypeName, description];
CLLocation * lastLocation = [MWMLocationManager lastLocation];
double distanceInMeters = 0.0;
@ -130,14 +131,6 @@ bool PopularityHasHigherPriority(bool hasPosition, double distanceInMeters)
[self setStyleAndApply: @"Background"];
}
- (void)setInfoText:(NSString *)infoText
{
self.infoView.hidden = NO;
self.infoLabel.text = infoText;
}
- (void)clearInfo { self.infoView.hidden = YES; }
- (NSDictionary *)selectedTitleAttributes
{
return @{

View file

@ -71,7 +71,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="SearchPopularView"/>
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Сafe" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5UO-MD-Hgx">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Сafe" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5UO-MD-Hgx">
<rect key="frame" x="16" y="36" width="26" height="14"/>
<accessibility key="accessibilityConfiguration" identifier="searchType"/>
<constraints>
@ -84,7 +84,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular12:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Open" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SDd-3c-YeL">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" text="Open" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SDd-3c-YeL">
<rect key="frame" x="274.5" y="36" width="29.5" height="14"/>
<accessibility key="accessibilityConfiguration" identifier="searchType"/>
<constraints>
@ -97,32 +97,6 @@
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular12:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AXe-5n-maZ" userLabel="Info">
<rect key="frame" x="46" y="36" width="224.5" height="14"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vjT-oU-iIA">
<rect key="frame" x="8" y="0.0" width="71" height="14"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="12"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular12:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="•" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tUT-ew-nNT" userLabel="Dot">
<rect key="frame" x="2" y="0.0" width="4" height="14"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="12"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular12:blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<constraints>
<constraint firstItem="vjT-oU-iIA" firstAttribute="leading" secondItem="tUT-ew-nNT" secondAttribute="trailing" constant="2" id="UAm-zh-FNA"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" ambiguous="YES" text="Russia, Moscow &amp; Central, Moscow" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6pc-4s-GyP">
<rect key="frame" x="16" y="59" width="220" height="14"/>
<accessibility key="accessibilityConfiguration" identifier="searchSubTitle"/>
@ -139,11 +113,8 @@
<constraint firstItem="P8X-Xp-AaE" firstAttribute="leading" secondItem="6pc-4s-GyP" secondAttribute="trailing" id="0hr-QT-t0D"/>
<constraint firstItem="5UO-MD-Hgx" firstAttribute="top" secondItem="4FD-RE-ffF" secondAttribute="bottom" constant="4" id="5dn-ca-dCn"/>
<constraint firstItem="6pc-4s-GyP" firstAttribute="top" secondItem="5UO-MD-Hgx" secondAttribute="bottom" constant="8" id="7pm-XZ-vLK"/>
<constraint firstItem="AXe-5n-maZ" firstAttribute="leading" secondItem="5UO-MD-Hgx" secondAttribute="trailing" constant="4" id="A63-OI-W5K"/>
<constraint firstItem="AXe-5n-maZ" firstAttribute="trailing" secondItem="SDd-3c-YeL" secondAttribute="leading" constant="-4" id="Jcf-PD-ZFs"/>
<constraint firstItem="AXe-5n-maZ" firstAttribute="top" secondItem="5UO-MD-Hgx" secondAttribute="top" id="PNu-ZN-b8a"/>
<constraint firstItem="4FD-RE-ffF" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="Qld-dY-CQN"/>
<constraint firstItem="AXe-5n-maZ" firstAttribute="bottom" secondItem="5UO-MD-Hgx" secondAttribute="bottom" id="SgY-ef-ISG"/>
<constraint firstItem="5UO-MD-Hgx" firstAttribute="trailing" relation="lessThanOrEqual" secondItem="SDd-3c-YeL" secondAttribute="leading" id="SJj-b5-T2k"/>
<constraint firstAttribute="trailing" secondItem="4FD-RE-ffF" secondAttribute="trailing" constant="84" id="Ugu-lP-b9G"/>
<constraint firstAttribute="trailing" secondItem="P8X-Xp-AaE" secondAttribute="trailing" constant="16" id="VJE-wo-TBb"/>
<constraint firstItem="4FD-RE-ffF" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="hM6-br-iKE"/>
@ -152,10 +123,10 @@
<constraint firstItem="5UO-MD-Hgx" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="nGL-Ta-pBZ"/>
<constraint firstAttribute="trailing" secondItem="6pc-4s-GyP" secondAttribute="trailing" constant="84" id="nfE-NI-LX9"/>
<constraint firstItem="6pc-4s-GyP" firstAttribute="bottom" secondItem="P8X-Xp-AaE" secondAttribute="bottom" id="q7E-Jg-MYT"/>
<constraint firstItem="SDd-3c-YeL" firstAttribute="bottom" secondItem="AXe-5n-maZ" secondAttribute="bottom" id="qba-9O-tbL"/>
<constraint firstItem="HGm-lZ-JNr" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="sq9-C3-M3R"/>
<constraint firstAttribute="bottom" secondItem="HGm-lZ-JNr" secondAttribute="bottom" id="vJc-aE-MsA"/>
<constraint firstAttribute="trailing" secondItem="SDd-3c-YeL" secondAttribute="trailing" constant="16" id="vay-ux-6dA"/>
<constraint firstItem="SDd-3c-YeL" firstAttribute="top" secondItem="5UO-MD-Hgx" secondAttribute="top" id="wXg-ce-SnG"/>
<constraint firstAttribute="trailing" secondItem="HGm-lZ-JNr" secondAttribute="trailing" id="xt0-86-Efu"/>
</constraints>
</tableViewCellContentView>
@ -164,13 +135,11 @@
</userDefinedRuntimeAttributes>
<connections>
<outlet property="distanceLabel" destination="P8X-Xp-AaE" id="Kaw-aR-8uJ"/>
<outlet property="infoLabel" destination="vjT-oU-iIA" id="K5N-O7-B0x"/>
<outlet property="infoView" destination="AXe-5n-maZ" id="obW-dd-NLt"/>
<outlet property="locationLabel" destination="6pc-4s-GyP" id="Te0-y3-sVQ"/>
<outlet property="openLabel" destination="SDd-3c-YeL" id="5Rv-fO-g4x"/>
<outlet property="popularView" destination="uWz-7m-GUu" id="LAK-NA-Fea"/>
<outlet property="titleLabel" destination="4FD-RE-ffF" id="OQm-o8-LUd"/>
<outlet property="typeLabel" destination="5UO-MD-Hgx" id="lgJ-zE-omX"/>
<outlet property="infoLabel" destination="5UO-MD-Hgx" id="lgJ-zE-omX"/>
</connections>
<point key="canvasLocation" x="314.49275362318843" y="297.99107142857139"/>
</tableViewCell>