Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/iphone
diff options
context:
space:
mode:
authorZoia Pribytkova <niakris90@gmail.com>2019-04-23 18:30:31 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2019-05-08 16:49:33 +0300
commit5b41fbc9bc66b38274b8d3e85d4e2aa6f771bcd3 (patch)
tree4720880032a2c6c0d17eb372f686efe647eb13f4 /iphone
parent39ba8fc18ed67c682888644876c1de28be04ca29 (diff)
[iOS] attributes fixes for the place description
Diffstat (limited to 'iphone')
-rw-r--r--iphone/Maps/Categories/NSAttributedString+HTML.swift7
-rw-r--r--iphone/Maps/UI/PlacePage/PlacePageDescriptionViewController.swift13
-rw-r--r--iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.mm34
-rw-r--r--iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.xib19
4 files changed, 43 insertions, 30 deletions
diff --git a/iphone/Maps/Categories/NSAttributedString+HTML.swift b/iphone/Maps/Categories/NSAttributedString+HTML.swift
index 211c4c5055..49ca56c283 100644
--- a/iphone/Maps/Categories/NSAttributedString+HTML.swift
+++ b/iphone/Maps/Categories/NSAttributedString+HTML.swift
@@ -13,6 +13,13 @@ extension NSAttributedString {
}
extension NSMutableAttributedString {
+ @objc convenience init?(htmlString: String, baseFont: UIFont, paragraphStyle: NSParagraphStyle?) {
+ self.init(htmlString: htmlString, baseFont: baseFont)
+ if let paragraphStyle = paragraphStyle {
+ addAttribute(.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, length))
+ }
+ }
+
@objc convenience init?(htmlString: String, baseFont: UIFont) {
guard let data = htmlString.data(using: .utf8) else { return nil }
diff --git a/iphone/Maps/UI/PlacePage/PlacePageDescriptionViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageDescriptionViewController.swift
index 4e595612ef..9cb32e2716 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageDescriptionViewController.swift
+++ b/iphone/Maps/UI/PlacePage/PlacePageDescriptionViewController.swift
@@ -12,8 +12,17 @@ final class PlacePageDescriptionViewController: WebViewController {
}
override func configuredHtml(withText htmlText: String) -> String {
- var html = htmlText.replacingOccurrences(of: "<body>", with: "<body><font face=\"helvetica\" size=\"14pt\">")
- html = html.replacingOccurrences(of: "</body>", with: "<p><b>wikipedia.org</b></p></font></body>")
+ let scale = UIScreen.main.scale
+ let styleTags = """
+ <head>
+ <style type=\"text/css\">
+ body{font-family:'-apple-system','HelveticaNeue'; font-size:\(14 * scale); line-height:1.5em;}
+ </style>
+ </head>
+ <body>
+ """
+ var html = htmlText.replacingOccurrences(of: "<body>", with: styleTags)
+ html = html.replacingOccurrences(of: "</body>", with: "<p><b>wikipedia.org</b></p></body>")
return html
}
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.mm
index cd09a951b4..7fb35c01c4 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.mm
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.mm
@@ -12,8 +12,7 @@
@implementation MWMPlaceDescriptionCell
-- (void)configureWithDescription:(NSString *)text delegate:(id<MWMPlacePageButtonsProtocol>)delegate
-{
+- (void)configureWithDescription:(NSString *)text delegate:(id<MWMPlacePageButtonsProtocol>)delegate {
self.delegate = delegate;
self.attributedHTML = nil;
self.originalText = text;
@@ -22,37 +21,34 @@
[self configHTML:text];
}
-- (void)configHTML:(NSString *)text
-{
- if (self.attributedHTML)
- {
+- (void)configHTML:(NSString *)text {
+ if (self.attributedHTML) {
if (self.attributedHTML.length <= 500) {
self.textView.attributedText = self.attributedHTML;
} else {
self.textView.attributedText = [self.attributedHTML attributedSubstringFromRange:NSMakeRange(0, 500)];
}
- }
- else
- {
+ } else {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- auto font = [UIFont regular16];
- auto color = [UIColor blackPrimaryText];
- auto str = [[NSMutableAttributedString alloc] initWithHtmlString:text baseFont:font];
- if (str)
- {
+ UIFont *font = [UIFont regular14];
+ UIColor *color = [UIColor blackPrimaryText];
+ NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
+ style.lineSpacing = 4.0;
+ NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithHtmlString:text
+ baseFont:font
+ paragraphStyle:style];
+ if (str) {
[str addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, str.length)];
self.attributedHTML = str;
- }
- else
- {
+ } else {
self.attributedHTML =
[[NSAttributedString alloc] initWithString:text
attributes:@{
NSFontAttributeName : font,
- NSForegroundColorAttributeName : color
+ NSForegroundColorAttributeName : color,
+ NSParagraphStyleAttributeName : style
}];
}
-
dispatch_async(dispatch_get_main_queue(), ^{
[self configHTML:nil];
});
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.xib
index 8367fd46b1..b3fa6a575d 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.xib
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/DescriptionCell/MWMPlaceDescriptionCell.xib
@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
- <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MWMPlaceDescriptionCell" rowHeight="184" id="Nyp-bg-ADZ" customClass="MWMPlaceDescriptionCell">
- <rect key="frame" x="0.0" y="0.0" width="320" height="184"/>
+ <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MWMPlaceDescriptionCell" rowHeight="178" id="Nyp-bg-ADZ" customClass="MWMPlaceDescriptionCell">
+ <rect key="frame" x="0.0" y="0.0" width="320" height="178"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="Nyp-bg-ADZ" id="g5P-Il-QmR">
- <rect key="frame" x="0.0" y="0.0" width="320" height="183.5"/>
+ <rect key="frame" x="0.0" y="0.0" width="320" height="177.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
- <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="HsW-qJ-7Mr">
+ <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="HsW-qJ-7Mr">
<rect key="frame" x="16" y="0.0" width="288" height="150"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
@@ -37,11 +37,12 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</textView>
- <button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VLo-nL-mRa">
- <rect key="frame" x="0.0" y="150" width="320" height="33"/>
+ <button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VLo-nL-mRa">
+ <rect key="frame" x="0.0" y="142" width="320" height="33"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="4iI-De-Y6q"/>
</constraints>
+ <fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="contentEdgeInsets" minX="16" minY="0.0" maxX="16" maxY="0.0"/>
<state key="normal" title="more"/>
<state key="highlighted" backgroundImage="dialog_btn_press"/>
@@ -64,7 +65,7 @@
<constraint firstItem="VLo-nL-mRa" firstAttribute="leading" secondItem="g5P-Il-QmR" secondAttribute="leading" id="kJX-Ud-LbI"/>
<constraint firstItem="HsW-qJ-7Mr" firstAttribute="leading" secondItem="g5P-Il-QmR" secondAttribute="leading" constant="16" id="mLz-lf-63L"/>
<constraint firstAttribute="trailing" secondItem="HsW-qJ-7Mr" secondAttribute="trailing" constant="16" id="xN4-ge-7YV"/>
- <constraint firstItem="VLo-nL-mRa" firstAttribute="top" secondItem="HsW-qJ-7Mr" secondAttribute="bottom" id="xNE-Tk-ucl"/>
+ <constraint firstItem="VLo-nL-mRa" firstAttribute="top" secondItem="HsW-qJ-7Mr" secondAttribute="bottom" constant="-8" id="xNE-Tk-ucl"/>
</constraints>
</tableViewCellContentView>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>