Skip to content

Commit 8831b4c

Browse files
Merge pull request #18216 from wordpress-mobile/issue/18194_posts_content_has_bigger_margin_on_ipad
My Site Dashboard: fix lateral margins for iPad and separator
2 parents b2a55ff + 62893c8 commit 8831b4c

File tree

6 files changed

+163
-14
lines changed

6 files changed

+163
-14
lines changed

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/PostsCardViewController.swift

+3-9
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ protocol PostsCardViewControllerDelegate: AnyObject {
5151

5252
override func viewWillAppear(_ animated: Bool) {
5353
super.viewWillAppear(animated)
54-
hideSeparatorForGhostCells()
5554
}
5655

5756
override func viewDidAppear(_ animated: Bool) {
@@ -103,10 +102,10 @@ private extension PostsCardViewController {
103102
ghostableTableView.isScrollEnabled = false
104103
ghostableTableView.separatorStyle = .none
105104

106-
let postCompactCellNib = PostCompactCell.defaultNib
107-
ghostableTableView.register(postCompactCellNib, forCellReuseIdentifier: PostCompactCell.defaultReuseID)
105+
let postCompactCellNib = BlogDashboardPostCardGhostCell.defaultNib
106+
ghostableTableView.register(postCompactCellNib, forCellReuseIdentifier: BlogDashboardPostCardGhostCell.defaultReuseID)
108107

109-
let ghostOptions = GhostOptions(displaysSectionHeader: false, reuseIdentifier: PostCompactCell.defaultReuseID, rowsPerSection: [Constants.numberOfPosts])
108+
let ghostOptions = GhostOptions(displaysSectionHeader: false, reuseIdentifier: BlogDashboardPostCardGhostCell.defaultReuseID, rowsPerSection: [Constants.numberOfPosts])
110109
let style = GhostStyle(beatDuration: GhostStyle.Defaults.beatDuration,
111110
beatStartColor: .placeholderElement,
112111
beatEndColor: .placeholderElementFaded)
@@ -120,11 +119,6 @@ private extension PostsCardViewController {
120119
ghostableTableView?.removeFromSuperview()
121120
}
122121

123-
func hideSeparatorForGhostCells() {
124-
ghostableTableView?.visibleCells
125-
.forEach { ($0 as? PostCompactCell)?.hideSeparator() }
126-
}
127-
128122
func presentEditor() {
129123
let editor = EditPostViewController(blog: blog)
130124
present(editor, animated: true)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import UIKit
2+
3+
class BlogDashboardPostCardGhostCell: UITableViewCell, NibReusable {
4+
@IBOutlet weak var titleLabel: UILabel!
5+
@IBOutlet weak var timestampLabel: UILabel!
6+
7+
override func awakeFromNib() {
8+
super.awakeFromNib()
9+
10+
WPStyleGuide.configureTableViewCell(self)
11+
WPStyleGuide.applyPostCardStyle(self)
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?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">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
7+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<objects>
11+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
12+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
13+
<tableViewCell contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" selectionStyle="default" indentationWidth="10" rowHeight="99" id="I5t-CH-v6f" customClass="BlogDashboardPostCardGhostCell" customModule="WordPress" customModuleProvider="target">
14+
<rect key="frame" x="0.0" y="0.0" width="320" height="99"/>
15+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
16+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" tableViewCell="I5t-CH-v6f" id="Q79-tN-qHr">
17+
<rect key="frame" x="0.0" y="0.0" width="320" height="99"/>
18+
<autoresizingMask key="autoresizingMask"/>
19+
<subviews>
20+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4j2-Ve-ekh">
21+
<rect key="frame" x="0.0" y="0.0" width="320" height="99"/>
22+
<subviews>
23+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="kbh-Ck-sE6" userLabel="Inner Stack View">
24+
<rect key="frame" x="16" y="8" width="312" height="83"/>
25+
<subviews>
26+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yzx-SY-SGf">
27+
<rect key="frame" x="0.0" y="0.0" width="312" height="83"/>
28+
<subviews>
29+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Yj1-10-Dz3">
30+
<rect key="frame" x="0.0" y="24" width="312" height="35"/>
31+
<subviews>
32+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zJb-yj-c1C">
33+
<rect key="frame" x="0.0" y="0.0" width="272" height="13.5"/>
34+
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
35+
<nil key="textColor"/>
36+
<nil key="highlightedColor"/>
37+
</label>
38+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VgR-q3-yxV">
39+
<rect key="frame" x="0.0" y="21.5" width="192" height="13.5"/>
40+
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption2"/>
41+
<nil key="textColor"/>
42+
<nil key="highlightedColor"/>
43+
</label>
44+
</subviews>
45+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
46+
<constraints>
47+
<constraint firstItem="VgR-q3-yxV" firstAttribute="top" secondItem="zJb-yj-c1C" secondAttribute="bottom" constant="8" id="1ol-4A-Rfh"/>
48+
<constraint firstAttribute="trailing" secondItem="zJb-yj-c1C" secondAttribute="trailing" constant="40" id="49t-Em-RBE"/>
49+
<constraint firstItem="zJb-yj-c1C" firstAttribute="top" secondItem="Yj1-10-Dz3" secondAttribute="top" id="6t6-7q-mDD"/>
50+
<constraint firstAttribute="bottom" secondItem="VgR-q3-yxV" secondAttribute="bottom" id="760-l2-GmL"/>
51+
<constraint firstItem="zJb-yj-c1C" firstAttribute="leading" secondItem="Yj1-10-Dz3" secondAttribute="leading" id="Vqn-8n-spa"/>
52+
<constraint firstAttribute="trailing" secondItem="VgR-q3-yxV" secondAttribute="trailing" constant="120" id="Wmz-X5-JO7"/>
53+
<constraint firstItem="VgR-q3-yxV" firstAttribute="leading" secondItem="zJb-yj-c1C" secondAttribute="leading" id="fBe-hc-pjp"/>
54+
</constraints>
55+
</view>
56+
</subviews>
57+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
58+
<constraints>
59+
<constraint firstAttribute="trailing" secondItem="Yj1-10-Dz3" secondAttribute="trailing" id="G43-bO-eNp"/>
60+
<constraint firstItem="Yj1-10-Dz3" firstAttribute="centerY" secondItem="yzx-SY-SGf" secondAttribute="centerY" id="ZUc-99-5rc"/>
61+
<constraint firstItem="Yj1-10-Dz3" firstAttribute="leading" secondItem="yzx-SY-SGf" secondAttribute="leading" id="elk-Ee-xOz"/>
62+
</constraints>
63+
</view>
64+
</subviews>
65+
<color key="backgroundColor" systemColor="secondarySystemGroupedBackgroundColor"/>
66+
</stackView>
67+
</subviews>
68+
<color key="backgroundColor" systemColor="secondarySystemGroupedBackgroundColor"/>
69+
<constraints>
70+
<constraint firstAttribute="bottom" secondItem="kbh-Ck-sE6" secondAttribute="bottom" constant="8" id="EAD-zc-JTh"/>
71+
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="999" constant="60" id="OcJ-tn-E7x"/>
72+
<constraint firstAttribute="trailing" secondItem="kbh-Ck-sE6" secondAttribute="trailing" constant="-8" id="Z3w-wQ-jiF"/>
73+
<constraint firstItem="kbh-Ck-sE6" firstAttribute="top" secondItem="4j2-Ve-ekh" secondAttribute="top" constant="8" id="a1K-da-e78"/>
74+
<constraint firstItem="kbh-Ck-sE6" firstAttribute="leading" secondItem="4j2-Ve-ekh" secondAttribute="leading" constant="16" id="rFw-1c-vxN"/>
75+
</constraints>
76+
</view>
77+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="t9m-fX-UGv">
78+
<rect key="frame" x="0.0" y="98" width="320" height="1"/>
79+
<color key="backgroundColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
80+
<constraints>
81+
<constraint firstAttribute="height" constant="1" placeholder="YES" id="Eos-wQ-OaH"/>
82+
</constraints>
83+
</view>
84+
</subviews>
85+
<color key="backgroundColor" systemColor="secondarySystemGroupedBackgroundColor"/>
86+
<constraints>
87+
<constraint firstAttribute="bottom" secondItem="4j2-Ve-ekh" secondAttribute="bottom" id="TlK-Ne-mgt"/>
88+
<constraint firstAttribute="trailing" secondItem="t9m-fX-UGv" secondAttribute="trailing" id="b6s-os-xxh"/>
89+
<constraint firstItem="4j2-Ve-ekh" firstAttribute="top" secondItem="Q79-tN-qHr" secondAttribute="top" id="bN3-jA-XK5"/>
90+
<constraint firstAttribute="trailing" secondItem="4j2-Ve-ekh" secondAttribute="trailing" priority="999" id="eNp-ns-Wbl"/>
91+
<constraint firstItem="t9m-fX-UGv" firstAttribute="leading" secondItem="Q79-tN-qHr" secondAttribute="leading" id="poK-76-ZcI"/>
92+
<constraint firstItem="4j2-Ve-ekh" firstAttribute="leading" secondItem="Q79-tN-qHr" secondAttribute="leading" priority="999" id="sbb-HI-X9X"/>
93+
<constraint firstItem="t9m-fX-UGv" firstAttribute="bottom" secondItem="4j2-Ve-ekh" secondAttribute="bottom" id="uAQ-QU-sOb"/>
94+
</constraints>
95+
</tableViewCellContentView>
96+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
97+
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
98+
<connections>
99+
<outlet property="timestampLabel" destination="VgR-q3-yxV" id="XnM-f2-gcX"/>
100+
<outlet property="titleLabel" destination="zJb-yj-c1C" id="pRO-vQ-ymN"/>
101+
</connections>
102+
<point key="canvasLocation" x="135" y="179.72222222222223"/>
103+
</tableViewCell>
104+
</objects>
105+
<resources>
106+
<systemColor name="secondarySystemGroupedBackgroundColor">
107+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
108+
</systemColor>
109+
</resources>
110+
</document>

WordPress/Classes/ViewRelated/Blog/Blog Details/Detail Header/BlogDetailHeaderView.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,12 @@ class BlogDetailHeaderView: UIView {
151151
}
152152

153153
private func constraintsForTitleView() -> [NSLayoutConstraint] {
154-
var constraints = [
154+
return [
155155
titleView.topAnchor.constraint(equalTo: topAnchor, constant: LayoutSpacing.top),
156156
titleView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: LayoutSpacing.atSides),
157157
titleView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor, constant: -LayoutSpacing.atSides),
158158
titleView.bottomAnchor.constraint(equalTo: bottomAnchor)
159159
]
160-
161-
return constraints
162160
}
163161

164162
// MARK: - User Action Handlers

WordPress/Classes/ViewRelated/Post/PostCompactCell.swift

+16-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class PostCompactCell: UITableViewCell, ConfigurablePostView {
1717

1818
@IBOutlet weak var trailingContentConstraint: NSLayoutConstraint!
1919

20+
private var iPadReadableLeadingAnchor: NSLayoutConstraint?
21+
private var iPadReadableTrailingAnchor: NSLayoutConstraint?
22+
2023
private weak var actionSheetDelegate: PostActionSheetDelegate?
2124

2225
lazy var imageLoader: ImageLoader = {
@@ -32,6 +35,7 @@ class PostCompactCell: UITableViewCell, ConfigurablePostView {
3235
viewModel = PostCardStatusViewModel(post: post)
3336
}
3437
}
38+
3539
private var viewModel: PostCardStatusViewModel?
3640

3741
func configure(with post: Post) {
@@ -96,8 +100,11 @@ class PostCompactCell: UITableViewCell, ConfigurablePostView {
96100
private func setupReadableGuideForiPad() {
97101
guard WPDeviceIdentification.isiPad() else { return }
98102

99-
innerView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor).isActive = true
100-
innerView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor).isActive = true
103+
iPadReadableLeadingAnchor = innerView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor)
104+
iPadReadableTrailingAnchor = innerView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor)
105+
106+
iPadReadableLeadingAnchor?.isActive = true
107+
iPadReadableTrailingAnchor?.isActive = true
101108
}
102109

103110
private func configureFeaturedImage() {
@@ -231,6 +238,8 @@ extension PostCompactCell {
231238
trailingContentConstraint.constant = Constants.margin
232239
headerStackView.spacing = Constants.margin
233240

241+
disableiPadReadableMargin()
242+
234243
if !post.isScheduled() {
235244
configureExcerpt()
236245
}
@@ -239,4 +248,9 @@ extension PostCompactCell {
239248
func hideSeparator() {
240249
separator.isHidden = true
241250
}
251+
252+
func disableiPadReadableMargin() {
253+
iPadReadableLeadingAnchor?.isActive = false
254+
iPadReadableTrailingAnchor?.isActive = false
255+
}
242256
}

0 commit comments

Comments
 (0)