Skip to content

Commit 5ef12d7

Browse files
authored
Merge pull request #18454 from wordpress-mobile/feature/18176-prompt_card_size
Blogging Prompts Feature Introduction: allow prompt card size to be dynamic
2 parents fd72e9b + 0a30b78 commit 5ef12d7

4 files changed

Lines changed: 43 additions & 38 deletions

File tree

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Prompts/DashboardPromptsCardCell.swift

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
1313
}
1414
}
1515

16+
// This is public so it can be accessed from the BloggingPromptsFeatureDescriptionView.
17+
private(set) lazy var cardFrameView: BlogDashboardCardFrameView = {
18+
let frameView = BlogDashboardCardFrameView()
19+
frameView.translatesAutoresizingMaskIntoConstraints = false
20+
frameView.title = Strings.cardFrameTitle
21+
frameView.icon = Style.frameIconImage
22+
23+
// NOTE: Remove the logic for iOS 13 once we drop that version.
24+
if #available (iOS 14.0, *) {
25+
// assign an empty closure so the button appears.
26+
frameView.onEllipsisButtonTap = {}
27+
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
28+
frameView.ellipsisButton.menu = contextMenu
29+
} else {
30+
// Show a fallback implementation using `MenuSheetViewController`.
31+
// iOS 13 doesn't support showing UIMenu programmatically.
32+
frameView.onEllipsisButtonTap = { [weak self] in
33+
self?.showMenuSheet()
34+
}
35+
}
36+
37+
return frameView
38+
}()
39+
40+
// MARK: - Private Properties
41+
1642
/// When set to true, a "default" version of the card is displayed. That is:
1743
/// - `maxAvatarCount` number of avatars.
1844
/// - `maxAvatarCount` answer count.
@@ -25,8 +51,6 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
2551
}
2652
}
2753

28-
// MARK: - Private Properties
29-
3054
// Used to present the menu sheet for contextual menu.
3155
// NOTE: Remove this once we drop support for iOS 13.
3256
private weak var presenterViewController: BlogDashboardViewController? = nil
@@ -39,29 +63,6 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
3963
return stackView
4064
}()
4165

42-
private lazy var cardFrameView: BlogDashboardCardFrameView = {
43-
let frameView = BlogDashboardCardFrameView()
44-
frameView.translatesAutoresizingMaskIntoConstraints = false
45-
frameView.title = Strings.cardFrameTitle
46-
frameView.icon = Style.frameIconImage
47-
48-
// NOTE: Remove the logic for iOS 13 once we drop that version.
49-
if #available (iOS 14.0, *) {
50-
// assign an empty closure so the button appears.
51-
frameView.onEllipsisButtonTap = {}
52-
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
53-
frameView.ellipsisButton.menu = contextMenu
54-
} else {
55-
// Show a fallback implementation using `MenuSheetViewController`.
56-
// iOS 13 doesn't support showing UIMenu programmatically.
57-
frameView.onEllipsisButtonTap = { [weak self] in
58-
self?.showMenuSheet()
59-
}
60-
}
61-
62-
return frameView
63-
}()
64-
6566
// MARK: Top row views
6667

6768
private lazy var promptLabel: UILabel = {

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ private extension BloggingPromptsFeatureDescriptionView {
2828
func configurePromptCard() {
2929
let promptCard = DashboardPromptsCardCell()
3030
promptCard.configureForExampleDisplay()
31-
promptCard.translatesAutoresizingMaskIntoConstraints = false
3231

33-
promptCard.layer.cornerRadius = Style.cardCornerRadius
34-
promptCard.layer.shadowOffset = Style.cardShadowOffset
35-
promptCard.layer.shadowOpacity = Style.cardShadowOpacity
36-
promptCard.layer.shadowRadius = Style.cardShadowRadius
32+
// The DashboardPromptsCardCell doesn't resize dynamically when used in this context.
33+
// So use its cardFrameView instead.
34+
promptCard.cardFrameView.translatesAutoresizingMaskIntoConstraints = false
35+
promptCard.cardFrameView.layer.cornerRadius = Style.cardCornerRadius
36+
promptCard.cardFrameView.layer.shadowOffset = Style.cardShadowOffset
37+
promptCard.cardFrameView.layer.shadowOpacity = Style.cardShadowOpacity
38+
promptCard.cardFrameView.layer.shadowRadius = Style.cardShadowRadius
3739

38-
promptCardView.addSubview(promptCard)
39-
promptCardView.pinSubviewToSafeArea(promptCard)
40+
promptCardView.addSubview(promptCard.cardFrameView)
41+
promptCardView.pinSubviewToAllEdges(promptCard.cardFrameView)
4042
}
4143

4244
func configureDescription() {

WordPress/Classes/ViewRelated/Feature Introduction/Blogging Prompts/BloggingPromptsFeatureDescriptionView.xib

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1717
<subviews>
1818
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8JU-nl-SWR" userLabel="Prompt Card">
19-
<rect key="frame" x="37" y="0.0" width="340" height="165"/>
19+
<rect key="frame" x="52" y="0.0" width="310.5" height="200.5"/>
2020
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
2121
<constraints>
22-
<constraint firstAttribute="height" constant="165" id="BfW-eb-ZtV"/>
22+
<constraint firstAttribute="height" relation="greaterThanOrEqual" id="BfW-eb-ZtV"/>
2323
</constraints>
2424
</view>
2525
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="We’ll show you a new prompt each day on your dashboard to help get those creative juices flowing!" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1gW-xt-yLe" userLabel="Description">
26-
<rect key="frame" x="16" y="189" width="382" height="36"/>
26+
<rect key="frame" x="16" y="224.5" width="382" height="36"/>
2727
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
2828
<color key="textColor" systemColor="secondaryLabelColor"/>
2929
<nil key="highlightedColor"/>
3030
</label>
3131
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="Note: You can learn more and set up reminders at any time in My Site &gt; Settings &gt; Blogging Reminders." textAlignment="natural" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z9E-X2-t3c" userLabel="Note">
32-
<rect key="frame" x="16" y="249" width="382" height="78"/>
32+
<rect key="frame" x="16" y="284.5" width="382" height="42.5"/>
3333
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
3434
<color key="textColor" systemColor="secondaryLabelColor"/>
3535
<fontDescription key="fontDescription" style="UICTFontTextStyleCaption1"/>
@@ -40,11 +40,11 @@
4040
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
4141
<constraints>
4242
<constraint firstItem="z9E-X2-t3c" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="16" id="1K2-WJ-vdn"/>
43+
<constraint firstItem="8JU-nl-SWR" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" multiplier="0.75" id="4C5-B7-SUy"/>
4344
<constraint firstItem="8JU-nl-SWR" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="95d-85-VYs"/>
4445
<constraint firstAttribute="bottom" secondItem="z9E-X2-t3c" secondAttribute="bottom" id="IUZ-vA-5QN"/>
45-
<constraint firstAttribute="trailing" secondItem="8JU-nl-SWR" secondAttribute="trailing" constant="37" id="KcL-0K-qQO"/>
46-
<constraint firstItem="8JU-nl-SWR" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="37" id="LNK-l6-tLb"/>
4746
<constraint firstItem="1gW-xt-yLe" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="16" id="WJ4-xD-ctR"/>
47+
<constraint firstItem="8JU-nl-SWR" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="sjz-gT-pc8"/>
4848
<constraint firstAttribute="trailing" secondItem="1gW-xt-yLe" secondAttribute="trailing" constant="16" id="srn-mJ-gKe"/>
4949
<constraint firstAttribute="trailing" secondItem="z9E-X2-t3c" secondAttribute="trailing" constant="16" id="vmH-4q-pbI"/>
5050
<constraint firstItem="z9E-X2-t3c" firstAttribute="top" secondItem="1gW-xt-yLe" secondAttribute="bottom" constant="24" id="wED-RV-9Lf"/>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
508508
func configureVerticalButtonView() {
509509
usesVerticalActionButtons = true
510510

511+
footerView.backgroundColor = .systemBackground
511512
footerHeightContraint.constant = footerHeight
512513
selectedStateButtonsContainer.axis = .vertical
513514

@@ -520,6 +521,7 @@ class CollapsableHeaderViewController: UIViewController, NoResultsViewHost {
520521
visualEffects.forEach { (visualEffect) in
521522
visualEffect.isHidden = true
522523
}
524+
navigationController?.navigationBar.backgroundColor = .systemBackground
523525
}
524526

525527
/// In scenarios where the content offset before content changes doesn't align with the available space after the content changes then the offset can be lost. In

0 commit comments

Comments
 (0)