Skip to content

Commit 1b0c5c5

Browse files
committed
Use the prompt card's cardFrameView so it will resize dynamically.
1 parent af33921 commit 1b0c5c5

2 files changed

Lines changed: 35 additions & 32 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+
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() {

0 commit comments

Comments
 (0)