Skip to content

Commit 92a975f

Browse files
authored
Merge pull request #18490 from wordpress-mobile/feature/18176-compact_height_header
Feature Introduction: show header titles in compact height
2 parents 08f36c6 + 3f3c2cc commit 92a975f

4 files changed

Lines changed: 41 additions & 6 deletions

File tree

WordPress/Classes/ViewRelated/Feature Introduction/Blogging Prompts/BloggingPromptsFeatureIntroduction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UIKit
22

3-
// TODO: add description
3+
/// This displays a Feature Introduction specifically for Blogging Prompts.
44

55
class BloggingPromptsFeatureIntroduction: FeatureIntroductionViewController {
66

WordPress/Classes/ViewRelated/Feature Introduction/FeatureIntroductionViewController.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import UIKit
55
@objc optional func secondaryActionSelected()
66
}
77

8-
// TODO: add description
8+
/// This is used to display a modal with information about a new feature.
9+
/// The feature description is displayed via the provided featureDescriptionView,
10+
/// which is presented in the scrollable area of the view.
11+
/// A primary action button is always displayed.
12+
/// A secondary action button is displayed if a secondaryButtonTitle is provided.
913

1014
class FeatureIntroductionViewController: CollapsableHeaderViewController {
1115

@@ -25,6 +29,20 @@ class FeatureIntroductionViewController: CollapsableHeaderViewController {
2529

2630
weak var featureIntroductionDelegate: FeatureIntroductionDelegate?
2731

32+
// MARK: - Header View Configuration
33+
34+
override var separatorStyle: SeparatorStyle {
35+
return .hidden
36+
}
37+
38+
override var alwaysResetHeaderOnRotation: Bool {
39+
WPDeviceIdentification.isiPhone()
40+
}
41+
42+
override var alwaysShowHeaderTitles: Bool {
43+
true
44+
}
45+
2846
// MARK: - Init
2947

3048
init(headerTitle: String,

WordPress/Classes/ViewRelated/Gutenberg/Collapsable Header/CollapsableHeaderViewController.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
3030
false
3131
}
3232

33+
// If set to true, all header titles will always be shown.
34+
// If set to false, largeTitleView and promptView labels are hidden in compact height (default behavior).
35+
//
36+
var alwaysShowHeaderTitles: Bool {
37+
false
38+
}
39+
3340
private let hasDefaultAction: Bool
3441
private var notificationObservers: [NSObjectProtocol] = []
3542
@IBOutlet weak var containerView: UIView!
@@ -55,6 +62,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
5562
@IBOutlet weak var promptView: UILabel!
5663
@IBOutlet weak var accessoryBar: UIView!
5764
@IBOutlet weak var accessoryBarHeightConstraint: NSLayoutConstraint!
65+
@IBOutlet weak var accessoryBarTopCompactConstraint: NSLayoutConstraint!
5866
@IBOutlet weak var footerView: UIView!
5967
@IBOutlet weak var footerHeightContraint: NSLayoutConstraint!
6068
@IBOutlet weak var defaultActionButton: UIButton!
@@ -118,7 +126,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
118126
}
119127

120128
private var shouldUseCompactLayout: Bool {
121-
return traitCollection.verticalSizeClass == .compact
129+
return !alwaysShowHeaderTitles && traitCollection.verticalSizeClass == .compact
122130
}
123131

124132
private var topInset: CGFloat = 0
@@ -241,6 +249,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
241249
layoutHeader()
242250
}
243251

252+
configureHeaderTitleVisibility()
244253
startObservingKeyboardChanges()
245254
super.viewWillAppear(animated)
246255
}
@@ -257,9 +266,12 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
257266
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
258267
super.viewWillTransition(to: size, with: coordinator)
259268

260-
guard isShowingNoResults || alwaysResetHeaderOnRotation else { return }
269+
guard isShowingNoResults || alwaysResetHeaderOnRotation else {
270+
return
271+
}
261272

262273
coordinator.animate(alongsideTransition: nil) { (_) in
274+
self.accessoryBarTopCompactConstraint.isActive = self.shouldUseCompactLayout
263275
self.updateHeaderDisplay()
264276
// we're keeping this only for no results,
265277
// as originally intended before introducing the flag alwaysResetHeaderOnRotation
@@ -279,6 +291,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
279291

280292
if let previousTraitCollection = previousTraitCollection, traitCollection.verticalSizeClass != previousTraitCollection.verticalSizeClass {
281293
isUserInitiatedScroll = false
294+
configureHeaderTitleVisibility()
282295
layoutHeaderInsets()
283296

284297
// This helps reset the header changes after a rotation.
@@ -372,6 +385,11 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
372385
headerImageView.image = headerImage
373386
}
374387

388+
func configureHeaderTitleVisibility() {
389+
largeTitleView.isHidden = shouldUseCompactLayout
390+
promptView.isHidden = shouldUseCompactLayout
391+
}
392+
375393
private func styleButtons() {
376394
let seperator = UIColor.separator
377395

WordPress/Classes/ViewRelated/Gutenberg/Collapsable Header/CollapsableHeaderViewController.xib

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<connections>
1515
<outlet property="accessoryBar" destination="DE5-R9-8tB" id="IAj-gK-2g6"/>
1616
<outlet property="accessoryBarHeightConstraint" destination="Eej-Tm-ddy" id="xGU-f0-4kH"/>
17+
<outlet property="accessoryBarTopCompactConstraint" destination="uVe-Ze-eIF" id="VXw-pp-QBH"/>
1718
<outlet property="containerView" destination="WmP-bw-ceT" id="lul-gs-fMI"/>
1819
<outlet property="defaultActionButton" destination="dmc-kV-0d8" id="NfO-bU-Zl7"/>
1920
<outlet property="footerHeightContraint" destination="lle-48-IUZ" id="CV2-G2-ryj"/>
@@ -84,7 +85,6 @@
8485
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle0"/>
8586
<nil key="textColor"/>
8687
<nil key="highlightedColor"/>
87-
<variation key="heightClass=compact" hidden="YES"/>
8888
</label>
8989
</subviews>
9090
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -100,7 +100,6 @@
100100
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
101101
<color key="textColor" systemColor="secondaryLabelColor"/>
102102
<nil key="highlightedColor"/>
103-
<variation key="heightClass=compact" hidden="YES"/>
104103
</label>
105104
<view clipsSubviews="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="DE5-R9-8tB" userLabel="Accessory Bar">
106105
<rect key="frame" x="0.0" y="163" width="414" height="44"/>

0 commit comments

Comments
 (0)