Skip to content

Commit d23b903

Browse files
authored
Stats Revamp: Fix Insights cards not adapting to large device text size (#19392)
* Stats cell heading label and details button dynamic type support * Don't truncate this week / previous week labels in Views & Visitors stats cell * Limit the size of StatsLineChart x and y axis labels * Expand guide label attributed text * Increase countLabel font size * Allow heading label to take all space if details button is not visible * Do not truncate labels in MostPopular cell by allowing multiline labels * Do not truncate labels in LatestPostSummary * Don't truncate in AllTime/ThisYear cards * Dynamic Type support in Posting Activity cell * Fix PostingActivity month label clipping when height changes * More spacing for heading label and less spacing for details button * Remove unused viewMoreHeightConstraint
1 parent c4bd00d commit d23b903

14 files changed

+126
-79
lines changed

WordPress/Classes/ViewRelated/Stats/Charts/StatsLineChartView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private extension StatsLineChartView {
221221
xAxis.drawLabelsEnabled = true
222222
xAxis.labelPosition = .bottom
223223
xAxis.labelTextColor = styling.labelColor
224-
xAxis.labelFont = UIFont.preferredFont(forTextStyle: .footnote)
224+
xAxis.labelFont = WPStyleGuide.fontForTextStyle(.footnote, symbolicTraits: [], maximumPointSize: WPStyleGuide.Stats.maximumChartAxisFontPointSize)
225225
xAxis.setLabelCount(Constants.horizontalAxisLabelCount, force: true)
226226

227227
let dateValueFormattter = DateValueFormatter()
@@ -250,7 +250,7 @@ private extension StatsLineChartView {
250250
yAxis.drawZeroLineEnabled = true
251251
yAxis.gridColor = styling.lineColor
252252
yAxis.labelTextColor = styling.labelColor
253-
yAxis.labelFont = UIFont.preferredFont(forTextStyle: .footnote)
253+
yAxis.labelFont = WPStyleGuide.fontForTextStyle(.footnote, symbolicTraits: [], maximumPointSize: WPStyleGuide.Stats.maximumChartAxisFontPointSize)
254254
yAxis.setLabelCount(Constants.verticalAxisLabelCount, force: true)
255255
yAxis.valueFormatter = styling.yAxisValueFormatter
256256
yAxis.zeroLineColor = styling.lineColor

WordPress/Classes/ViewRelated/Stats/Extensions/WPStyleGuide+Stats.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ extension WPStyleGuide {
8383

8484
static func configureLabelAsCellRowTitle(_ label: UILabel) {
8585
label.textColor = defaultTextColor
86+
label.numberOfLines = 0
8687
}
8788

8889
static func configureLabelAsData(_ label: UILabel) {
@@ -100,10 +101,14 @@ extension WPStyleGuide {
100101
static func configureLabelAsPostingMonth(_ label: UILabel) {
101102
label.textColor = defaultTextColor
102103
label.font = subTitleFont
104+
label.adjustsFontSizeToFitWidth = true
105+
label.numberOfLines = 0
106+
label.lineBreakMode = .byClipping
103107
}
104108

105109
static func configureLabelAsPostingLegend(_ label: UILabel) {
106110
label.textColor = defaultTextColor
111+
label.numberOfLines = 0
107112
}
108113

109114
static func configureLabelAsPostingDate(_ label: UILabel) {
@@ -199,6 +204,10 @@ extension WPStyleGuide {
199204
}
200205
}
201206

207+
// MARK: - Font Size
208+
209+
static let maximumChartAxisFontPointSize: CGFloat = 22
210+
202211
// MARK: - Style Values
203212

204213
static let defaultTextColor = UIColor.text

WordPress/Classes/ViewRelated/Stats/Insights/Posting Activity/PostingActivityCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class PostingActivityCell: StatsBaseCell, NibLoadable, Accessible {
66

77
@IBOutlet weak var monthsStackView: UIStackView!
88
@IBOutlet weak var viewMoreLabel: UILabel!
9-
@IBOutlet weak var legendView: UIView!
9+
@IBOutlet weak var legendView: UIStackView!
1010

1111
@IBOutlet weak var topSeparatorLine: UIView!
1212
@IBOutlet weak var bottomSeparatorLine: UIView!
@@ -66,7 +66,7 @@ private extension PostingActivityCell {
6666

6767
func addLegend() {
6868
let legend = PostingActivityLegend.loadFromNib()
69-
legendView.addSubview(legend)
69+
legendView.addArrangedSubview(legend)
7070
}
7171

7272
func addMonths(monthsData: [[PostingStreakEvent]]) {

WordPress/Classes/ViewRelated/Stats/Insights/Posting Activity/PostingActivityCell.xib

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99
</dependencies>
@@ -13,33 +13,42 @@
1313
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="242" id="KGk-i7-Jjw" customClass="PostingActivityCell" customModule="WordPress" customModuleProvider="target">
1414
<rect key="frame" x="0.0" y="0.0" width="342" height="242"/>
1515
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
16-
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
16+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
1717
<rect key="frame" x="0.0" y="0.0" width="342" height="242"/>
1818
<autoresizingMask key="autoresizingMask"/>
1919
<subviews>
20-
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="BVC-pc-qhM" userLabel="Months Stack View">
20+
<stackView opaque="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="1000" distribution="fillEqually" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="BVC-pc-qhM" userLabel="Months Stack View">
2121
<rect key="frame" x="20" y="8" width="302" height="135"/>
2222
<constraints>
2323
<constraint firstAttribute="height" constant="135" id="Gdi-iJ-OMR"/>
2424
</constraints>
2525
</stackView>
2626
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MNM-OS-iwT" userLabel="Legend View">
27-
<rect key="frame" x="0.0" y="151" width="342" height="44"/>
27+
<rect key="frame" x="0.0" y="151" width="342" height="46.5"/>
28+
<subviews>
29+
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MY1-06-Ewu">
30+
<rect key="frame" x="0.0" y="0.0" width="342" height="46.5"/>
31+
</stackView>
32+
</subviews>
2833
<constraints>
29-
<constraint firstAttribute="height" constant="44" id="mRd-EA-DY4"/>
34+
<constraint firstItem="MY1-06-Ewu" firstAttribute="leading" secondItem="MNM-OS-iwT" secondAttribute="leading" id="PMd-w4-ZBW"/>
35+
<constraint firstAttribute="trailing" secondItem="MY1-06-Ewu" secondAttribute="trailing" id="jDu-fT-YXj"/>
36+
<constraint firstAttribute="bottom" secondItem="MY1-06-Ewu" secondAttribute="bottom" id="jSj-9I-9fX"/>
37+
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="44" id="mRd-EA-DY4"/>
38+
<constraint firstItem="MY1-06-Ewu" firstAttribute="top" secondItem="MNM-OS-iwT" secondAttribute="top" id="v5x-n5-YyM"/>
3039
</constraints>
3140
</view>
3241
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="A6f-g5-v7s" userLabel="View More View">
33-
<rect key="frame" x="0.0" y="195" width="342" height="44"/>
42+
<rect key="frame" x="0.0" y="197.5" width="342" height="44.5"/>
3443
<subviews>
3544
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="View more" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D7G-gg-9QM" userLabel="View More Label">
36-
<rect key="frame" x="16" y="12" width="286" height="20"/>
45+
<rect key="frame" x="16" y="12" width="286" height="20.5"/>
3746
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
3847
<nil key="textColor"/>
3948
<nil key="highlightedColor"/>
4049
</label>
4150
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="disclosure-chevron" translatesAutoresizingMaskIntoConstraints="NO" id="T5g-sS-mGT" userLabel="Disclosure Image">
42-
<rect key="frame" x="318" y="15.5" width="8" height="13"/>
51+
<rect key="frame" x="318" y="16" width="8" height="13"/>
4352
<constraints>
4453
<constraint firstAttribute="height" constant="13" id="Mdf-mA-WPT"/>
4554
<constraint firstAttribute="width" constant="8" id="THc-DV-57t"/>
@@ -51,14 +60,14 @@
5160
<constraint firstItem="D7G-gg-9QM" firstAttribute="top" secondItem="A6f-g5-v7s" secondAttribute="top" constant="12" id="0GN-so-rhg"/>
5261
<constraint firstItem="D7G-gg-9QM" firstAttribute="leading" secondItem="A6f-g5-v7s" secondAttribute="leading" constant="16" id="63L-Sx-Txn"/>
5362
<constraint firstItem="T5g-sS-mGT" firstAttribute="leading" secondItem="D7G-gg-9QM" secondAttribute="trailing" constant="16" id="HpU-7v-ggz"/>
54-
<constraint firstAttribute="height" constant="44" id="PwU-dj-XrK"/>
63+
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="44" id="PwU-dj-XrK"/>
5564
<constraint firstAttribute="trailing" secondItem="T5g-sS-mGT" secondAttribute="trailing" constant="16" id="d8o-Dz-AGa"/>
5665
<constraint firstAttribute="bottom" secondItem="D7G-gg-9QM" secondAttribute="bottom" constant="12" id="duR-t9-5Tn"/>
5766
<constraint firstItem="T5g-sS-mGT" firstAttribute="centerY" secondItem="A6f-g5-v7s" secondAttribute="centerY" id="jy0-ih-OB7"/>
5867
</constraints>
5968
</view>
6069
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XhD-aG-GxJ" userLabel="View More Button">
61-
<rect key="frame" x="0.0" y="195" width="342" height="44"/>
70+
<rect key="frame" x="0.0" y="197.5" width="342" height="44.5"/>
6271
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
6372
<connections>
6473
<action selector="didTapViewMoreButton:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="U1p-3L-m3M"/>
@@ -72,7 +81,7 @@
7281
</constraints>
7382
</view>
7483
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="K5q-Qa-Pnh" userLabel="Bottom Seperator Line">
75-
<rect key="frame" x="0.0" y="239" width="342" height="0.5"/>
84+
<rect key="frame" x="0.0" y="241.5" width="342" height="0.5"/>
7685
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7786
<constraints>
7887
<constraint firstAttribute="height" constant="0.5" id="Ebs-qL-BEp"/>
@@ -88,7 +97,6 @@
8897
<constraint firstItem="MNM-OS-iwT" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="KRO-SV-yPt"/>
8998
<constraint firstItem="BVC-pc-qhM" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="OWn-0r-61f"/>
9099
<constraint firstItem="XhD-aG-GxJ" firstAttribute="bottom" secondItem="A6f-g5-v7s" secondAttribute="bottom" id="Or8-T0-83W"/>
91-
<constraint firstItem="K5q-Qa-Pnh" firstAttribute="top" secondItem="A6f-g5-v7s" secondAttribute="bottom" placeholder="YES" id="S3M-pg-jE1"/>
92100
<constraint firstItem="A6f-g5-v7s" firstAttribute="top" secondItem="MNM-OS-iwT" secondAttribute="bottom" id="Sns-td-yrm"/>
93101
<constraint firstAttribute="trailing" secondItem="BVC-pc-qhM" secondAttribute="trailing" constant="20" id="bCQ-sr-6gB"/>
94102
<constraint firstItem="A6f-g5-v7s" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="c2q-6v-gHN"/>
@@ -109,7 +117,7 @@
109117
</constraints>
110118
<connections>
111119
<outlet property="bottomSeparatorLine" destination="K5q-Qa-Pnh" id="y35-PR-cqI"/>
112-
<outlet property="legendView" destination="MNM-OS-iwT" id="3sj-wa-JnR"/>
120+
<outlet property="legendView" destination="MY1-06-Ewu" id="ocU-dZ-FRp"/>
113121
<outlet property="monthsStackView" destination="BVC-pc-qhM" id="IlC-oK-tm8"/>
114122
<outlet property="topConstraint" destination="OWn-0r-61f" id="P96-ck-qph"/>
115123
<outlet property="topSeparatorLine" destination="SrM-6z-hC1" id="AGS-zl-lmo"/>

WordPress/Classes/ViewRelated/Stats/Insights/Posting Activity/PostingActivityLegend.xib

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
97
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
108
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
119
</dependencies>
@@ -19,11 +17,11 @@
1917
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="meU-pl-4m0">
2018
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
2119
<subviews>
22-
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ARE-aC-ip9">
23-
<rect key="frame" x="16" y="12" width="242.5" height="20"/>
20+
<stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ARE-aC-ip9">
21+
<rect key="frame" x="16" y="12" width="248" height="20"/>
2422
<subviews>
2523
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Fewer Posts" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FnP-mY-N0W" userLabel="Fewer Posts Label">
26-
<rect key="frame" x="0.0" y="0.0" width="74" height="20"/>
24+
<rect key="frame" x="0.0" y="2" width="74" height="16"/>
2725
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
2826
<nil key="textColor"/>
2927
<nil key="highlightedColor"/>
@@ -35,29 +33,33 @@
3533
</constraints>
3634
</stackView>
3735
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="More Posts" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uAC-fC-aPR" userLabel="More Posts Label">
38-
<rect key="frame" x="174" y="0.0" width="68.5" height="20"/>
36+
<rect key="frame" x="174" y="2" width="74" height="16"/>
3937
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
4038
<nil key="textColor"/>
4139
<nil key="highlightedColor"/>
4240
</label>
4341
</subviews>
42+
<constraints>
43+
<constraint firstItem="uAC-fC-aPR" firstAttribute="width" secondItem="FnP-mY-N0W" secondAttribute="width" id="Uan-jL-ClD"/>
44+
</constraints>
4445
</stackView>
4546
</subviews>
4647
<constraints>
4748
<constraint firstAttribute="bottom" secondItem="ARE-aC-ip9" secondAttribute="bottom" constant="12" id="1R0-gc-zaa"/>
4849
<constraint firstItem="ARE-aC-ip9" firstAttribute="leading" secondItem="meU-pl-4m0" secondAttribute="leading" constant="16" id="Oiu-FI-wYs"/>
4950
<constraint firstItem="ARE-aC-ip9" firstAttribute="top" secondItem="meU-pl-4m0" secondAttribute="top" constant="12" id="PA6-Ot-8ss"/>
51+
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ARE-aC-ip9" secondAttribute="trailing" constant="16" id="Uqz-21-2i7"/>
5052
</constraints>
5153
</view>
5254
</subviews>
55+
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
5356
<constraints>
5457
<constraint firstItem="meU-pl-4m0" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="3M2-yi-jf4"/>
5558
<constraint firstItem="meU-pl-4m0" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="4af-BS-OXx"/>
5659
<constraint firstItem="meU-pl-4m0" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="Odm-be-aBL"/>
5760
<constraint firstItem="meU-pl-4m0" firstAttribute="bottom" secondItem="vUN-kp-3ea" secondAttribute="bottom" id="wGv-0S-Tig"/>
5861
</constraints>
5962
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
60-
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
6163
<connections>
6264
<outlet property="colorsStackView" destination="T4z-BI-Pdv" id="Db2-0w-czW"/>
6365
<outlet property="fewerPostsLabel" destination="FnP-mY-N0W" id="fkh-2s-Jzd"/>

0 commit comments

Comments
 (0)