diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-10-24 13:18:58 +0300 |
---|---|---|
committer | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-10-24 14:10:59 +0300 |
commit | 6920d70e9cbd09a05bbef61866de5f0c9b553a4a (patch) | |
tree | 952ffe8e4c60d79e59de51dcdfd1910d5f471de5 | |
parent | 1e49627311f29ea7554421ef9cc1f6a1e1ca0cbb (diff) |
[ios] Fixed opening hours layout.
-rw-r--r-- | iphone/Maps/Classes/MWMOpeningHoursCell.mm | 53 | ||||
-rw-r--r-- | iphone/Maps/Classes/_MWMOHHeaderCell.xib | 94 |
2 files changed, 68 insertions, 79 deletions
diff --git a/iphone/Maps/Classes/MWMOpeningHoursCell.mm b/iphone/Maps/Classes/MWMOpeningHoursCell.mm index 3d88c25dd2..6667caa636 100644 --- a/iphone/Maps/Classes/MWMOpeningHoursCell.mm +++ b/iphone/Maps/Classes/MWMOpeningHoursCell.mm @@ -2,6 +2,8 @@ #import "Common.h" #import "MWMOpeningHours.h" #import "MWMPlacePageCellUpdateProtocol.h" +#import "UIColor+MapsMeColor.h" +#import "UIFont+MapsMeFonts.h" #include "std/array.hpp" @@ -11,17 +13,49 @@ array<NSString *, 2> kOHClasses = {{@"_MWMOHHeaderCell", @"_MWMOHSubCell"}}; void * kContext = &kContext; NSString * const kTableViewContentSizeKeyPath = @"contentSize"; +NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow) +{ + auto const richString = ^NSMutableAttributedString * (NSString * str, UIFont * font, UIColor * color) + { + return [[NSMutableAttributedString alloc] initWithString:str + attributes:@{NSFontAttributeName : font, + NSForegroundColorAttributeName : color}]; + }; + + auto str = richString(day.TodayTime(), [UIFont regular17], day.m_isOpen ? [UIColor blackPrimaryText] : + [UIColor red]); + if (day.m_isOpen) + { + auto lineBreak = [[NSAttributedString alloc] initWithString:@"\n"]; + + if (day.m_breaks.length) + { + [str appendAttributedString:lineBreak]; + [str appendAttributedString:richString(day.m_breaks, [UIFont regular13], [UIColor blackSecondaryText])]; + } + + if (isClosedNow) + { + [str appendAttributedString:lineBreak]; + [str appendAttributedString:richString(L(@"closed_now"), [UIFont regular13], [UIColor red])]; + } + + auto paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + paragraphStyle.lineSpacing = 4; + + [str addAttributes:@{NSParagraphStyleAttributeName : paragraphStyle} range:{0, str.length}]; + } + return str; +} + } // namespace #pragma mark - _MWMOHHeaderCell @interface _MWMOHHeaderCell : MWMTableViewCell -@property(weak, nonatomic) IBOutlet UILabel * today; -@property(weak, nonatomic) IBOutlet UILabel * breaks; -@property(weak, nonatomic) IBOutlet UILabel * closedNow; +@property(weak, nonatomic) IBOutlet UILabel * text; @property(weak, nonatomic) IBOutlet UIImageView * arrowIcon; -@property(weak, nonatomic) IBOutlet UIImageView * separator; @property(copy, nonatomic) TMWMVoidBlock tapAction; @@ -120,15 +154,13 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize"; cellForRowAtIndexPath:(NSIndexPath *)indexPath { auto const & day = m_days[indexPath.row]; - BOOL const isSeparatorHidden = - self.isExtended ? indexPath.row == 0 : indexPath.row == m_days.size() - 1; + if (indexPath.row == 0) { _MWMOHHeaderCell * cell = [tableView dequeueReusableCellWithIdentifier:[_MWMOHHeaderCell className]]; - cell.today.text = day.TodayTime(); - cell.breaks.text = day.m_breaks; - cell.closedNow.text = self.isClosedNow ? L(@"closed_now") : nil; + cell.text.attributedText = richStringFromDay(day, self.isClosedNow); + if (m_days.size() > 1) { cell.tapAction = ^{ @@ -153,7 +185,6 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize"; cell.tapAction = nil; cell.arrowIcon.hidden = YES; } - cell.separator.hidden = isSeparatorHidden; return cell; } else @@ -162,7 +193,7 @@ NSString * const kTableViewContentSizeKeyPath = @"contentSize"; cell.days.text = day.m_workingDays; cell.schedule.text = day.m_workingTimes ? day.m_workingTimes : L(@"closed"); cell.breaks.text = day.m_breaks; - cell.separator.hidden = isSeparatorHidden; + cell.separator.hidden = indexPath.row == m_days.size() - 1; return cell; } } diff --git a/iphone/Maps/Classes/_MWMOHHeaderCell.xib b/iphone/Maps/Classes/_MWMOHHeaderCell.xib index efa188bfad..71c771f6ef 100644 --- a/iphone/Maps/Classes/_MWMOHHeaderCell.xib +++ b/iphone/Maps/Classes/_MWMOHHeaderCell.xib @@ -1,5 +1,5 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES"> +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES"> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/> @@ -8,66 +8,36 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="_MWMOHHeaderCell" rowHeight="100" id="LXG-cP-akO" customClass="_MWMOHHeaderCell"> - <rect key="frame" x="0.0" y="0.0" width="375" height="100"/> + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="_MWMOHHeaderCell" id="LXG-cP-akO" customClass="_MWMOHHeaderCell"> + <rect key="frame" x="0.0" y="0.0" width="375" height="48"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="LXG-cP-akO" id="WuT-dc-opP"> - <frame key="frameInset" width="375" height="99.5"/> + <frame key="frameInset" width="375" height="47"/> <autoresizingMask key="autoresizingMask"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_placepage_open_hours" translatesAutoresizingMaskIntoConstraints="NO" id="nwH-Nj-buF"> <constraints> - <constraint firstAttribute="width" constant="24" id="LjC-Sp-k5X"/> - <constraint firstAttribute="height" constant="24" id="gWH-Yu-u9h"/> + <constraint firstAttribute="height" constant="24" id="AU3-h8-Jf3"/> + <constraint firstAttribute="width" constant="24" id="RuT-UD-d6E"/> </constraints> <userDefinedRuntimeAttributes> <userDefinedRuntimeAttribute type="string" keyPath="coloring" value="MWMBlack"/> </userDefinedRuntimeAttributes> </imageView> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Сегодня 8:00 – 18:00" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qDh-SU-MHG" userLabel="Today"> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Сегодня 8:00 – 18:00" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qDh-SU-MHG" userLabel="Text"> <fontDescription key="fontDescription" type="system" pointSize="17"/> <nil key="textColor"/> <nil key="highlightedColor"/> - <userDefinedRuntimeAttributes> - <userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/> - <userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular17"/> - </userDefinedRuntimeAttributes> - </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Перерыв 12:00 – 13:00" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SUY-kO-lcA" userLabel="Break"> - <fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="17"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - <userDefinedRuntimeAttributes> - <userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/> - <userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular13"/> - </userDefinedRuntimeAttributes> - </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Сейчас закрыто" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VBz-au-4xa" userLabel="Closed now"> - <fontDescription key="fontDescription" type="system" pointSize="17"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - <userDefinedRuntimeAttributes> - <userDefinedRuntimeAttribute type="string" keyPath="colorName" value="red"/> - <userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular13"/> - </userDefinedRuntimeAttributes> </label> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_arrow_gray_down" translatesAutoresizingMaskIntoConstraints="NO" id="VHY-FB-giE"> <constraints> - <constraint firstAttribute="width" constant="28" id="OgV-so-hOI"/> - <constraint firstAttribute="height" constant="28" id="dBd-ZI-bu4"/> + <constraint firstAttribute="height" constant="28" id="GMF-Az-vGZ"/> + <constraint firstAttribute="width" constant="28" id="qap-Cz-ia0"/> </constraints> <userDefinedRuntimeAttributes> <userDefinedRuntimeAttribute type="string" keyPath="coloring" value="MWMBlack"/> </userDefinedRuntimeAttributes> </imageView> - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="separator_image" translatesAutoresizingMaskIntoConstraints="NO" id="byE-X8-YBC"> - <constraints> - <constraint firstAttribute="height" constant="1" id="FoK-zb-Rvr"/> - </constraints> - <userDefinedRuntimeAttributes> - <userDefinedRuntimeAttribute type="string" keyPath="coloring" value="MWMSeparator"/> - </userDefinedRuntimeAttributes> - </imageView> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mvv-gY-euE"> <connections> <action selector="extendTap" destination="LXG-cP-akO" eventType="touchUpInside" id="yMy-04-GCs"/> @@ -75,44 +45,32 @@ </button> </subviews> <constraints> - <constraint firstItem="Mvv-gY-euE" firstAttribute="leading" secondItem="WuT-dc-opP" secondAttribute="leading" id="0K0-8b-LPL"/> - <constraint firstItem="byE-X8-YBC" firstAttribute="leading" secondItem="WuT-dc-opP" secondAttribute="leading" constant="60" id="1lE-nc-fFl"/> - <constraint firstItem="Mvv-gY-euE" firstAttribute="top" secondItem="WuT-dc-opP" secondAttribute="top" id="9LV-xR-rNC"/> - <constraint firstItem="SUY-kO-lcA" firstAttribute="top" secondItem="qDh-SU-MHG" secondAttribute="bottom" constant="4" id="F8Z-l6-buM"/> - <constraint firstItem="SUY-kO-lcA" firstAttribute="top" secondItem="qDh-SU-MHG" secondAttribute="bottom" constant="4" id="FDA-zq-wb6"/> - <constraint firstItem="qDh-SU-MHG" firstAttribute="leading" secondItem="nwH-Nj-buF" secondAttribute="trailing" constant="20" id="GdL-ps-Aya"/> - <constraint firstAttribute="trailing" secondItem="VHY-FB-giE" secondAttribute="trailing" constant="8" id="JLG-1w-IGN"/> - <constraint firstItem="nwH-Nj-buF" firstAttribute="leading" secondItem="WuT-dc-opP" secondAttribute="leading" constant="16" id="N1J-dg-rdb"/> - <constraint firstItem="VHY-FB-giE" firstAttribute="leading" secondItem="qDh-SU-MHG" secondAttribute="trailing" constant="8" id="SeW-Tz-hIt"/> - <constraint firstAttribute="trailing" secondItem="byE-X8-YBC" secondAttribute="trailing" id="THx-yW-0Pg"/> - <constraint firstAttribute="trailing" secondItem="Mvv-gY-euE" secondAttribute="trailing" id="VO5-tR-Gb5"/> - <constraint firstAttribute="bottom" secondItem="Mvv-gY-euE" secondAttribute="bottom" id="XA5-h1-bvn"/> - <constraint firstItem="nwH-Nj-buF" firstAttribute="centerY" secondItem="WuT-dc-opP" secondAttribute="centerY" id="YyY-wo-k3r"/> - <constraint firstItem="byE-X8-YBC" firstAttribute="top" secondItem="VBz-au-4xa" secondAttribute="bottom" constant="14" id="bCS-Xw-0sP"/> - <constraint firstItem="VHY-FB-giE" firstAttribute="leading" secondItem="SUY-kO-lcA" secondAttribute="trailing" constant="8" id="cJk-pF-MWB"/> - <constraint firstItem="VHY-FB-giE" firstAttribute="centerY" secondItem="WuT-dc-opP" secondAttribute="centerY" id="dF7-VZ-wCm"/> - <constraint firstAttribute="bottom" secondItem="byE-X8-YBC" secondAttribute="bottom" id="eyh-D3-PL4"/> - <constraint firstItem="VBz-au-4xa" firstAttribute="top" secondItem="SUY-kO-lcA" secondAttribute="bottom" constant="4" id="fam-HS-q2G"/> - <constraint firstItem="qDh-SU-MHG" firstAttribute="top" secondItem="WuT-dc-opP" secondAttribute="top" constant="14" id="rgx-8A-sEE"/> - <constraint firstItem="VHY-FB-giE" firstAttribute="leading" secondItem="VBz-au-4xa" secondAttribute="trailing" constant="8" id="rsi-Hp-ORw"/> - <constraint firstItem="SUY-kO-lcA" firstAttribute="leading" secondItem="nwH-Nj-buF" secondAttribute="trailing" constant="20" id="sNc-db-hOj"/> - <constraint firstItem="VBz-au-4xa" firstAttribute="leading" secondItem="nwH-Nj-buF" secondAttribute="trailing" constant="20" id="vEF-OR-sIn"/> + <constraint firstAttribute="bottom" secondItem="qDh-SU-MHG" secondAttribute="bottom" constant="14" id="0DZ-az-Lhs"/> + <constraint firstItem="nwH-Nj-buF" firstAttribute="leading" secondItem="WuT-dc-opP" secondAttribute="leading" constant="16" id="6Pu-RX-aEk"/> + <constraint firstItem="Mvv-gY-euE" firstAttribute="leading" secondItem="WuT-dc-opP" secondAttribute="leading" id="8P4-c4-MZD"/> + <constraint firstItem="VHY-FB-giE" firstAttribute="leading" secondItem="qDh-SU-MHG" secondAttribute="trailing" constant="8" id="9t0-oW-VAo"/> + <constraint firstItem="qDh-SU-MHG" firstAttribute="top" secondItem="WuT-dc-opP" secondAttribute="top" constant="14" id="EEt-O9-WgL"/> + <constraint firstAttribute="bottom" secondItem="Mvv-gY-euE" secondAttribute="bottom" id="Gbe-0R-FgZ"/> + <constraint firstAttribute="trailing" secondItem="Mvv-gY-euE" secondAttribute="trailing" id="fbo-mH-Bi6"/> + <constraint firstAttribute="trailing" secondItem="VHY-FB-giE" secondAttribute="trailing" constant="8" id="jQX-bd-gBc"/> + <constraint firstItem="qDh-SU-MHG" firstAttribute="leading" secondItem="nwH-Nj-buF" secondAttribute="trailing" constant="20" id="rcw-Eo-aHO"/> + <constraint firstItem="Mvv-gY-euE" firstAttribute="top" secondItem="WuT-dc-opP" secondAttribute="top" id="zyW-ZM-u0d"/> </constraints> </tableViewCellContentView> + <constraints> + <constraint firstItem="nwH-Nj-buF" firstAttribute="centerY" secondItem="LXG-cP-akO" secondAttribute="centerY" id="Fk1-cA-KAh"/> + <constraint firstItem="VHY-FB-giE" firstAttribute="centerY" secondItem="LXG-cP-akO" secondAttribute="centerY" id="x8c-sP-BJ3"/> + </constraints> <connections> <outlet property="arrowIcon" destination="VHY-FB-giE" id="j5m-f3-Wv6"/> - <outlet property="breaks" destination="SUY-kO-lcA" id="hEd-dx-xLq"/> - <outlet property="closedNow" destination="VBz-au-4xa" id="5b6-WK-hzS"/> - <outlet property="separator" destination="byE-X8-YBC" id="oyA-s8-BPp"/> - <outlet property="today" destination="qDh-SU-MHG" id="jYZ-La-UfJ"/> + <outlet property="text" destination="qDh-SU-MHG" id="OTq-0N-S6b"/> </connections> - <point key="canvasLocation" x="45.5" y="71"/> + <point key="canvasLocation" x="45.5" y="43"/> </tableViewCell> </objects> <resources> <image name="ic_arrow_gray_down" width="28" height="28"/> <image name="ic_placepage_open_hours" width="28" height="28"/> - <image name="separator_image" width="1" height="1"/> </resources> <simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedStatusBarMetrics key="statusBar"/> |