Skip to content

Commit

Permalink
Merge pull request #20885 from wordpress-mobile/disable-posts-list-ac…
Browse files Browse the repository at this point in the history
…tion-menu-when-uploading

PostsList - Disable the menu button/action bar when a post is being uploaded
  • Loading branch information
Gerardo Pacheco authored Jun 19, 2023
2 parents de22f2a + bf99521 commit b39df1b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* [**] Fixed crash issue when accessing drafts that are mid-upload from the Home 'Work on a Draft Post' card. [#20872]
* [**] [internal] Make sure a database tidy-up task (null blog property sanitizer) is completed before any other Core Data queries. [#20867]
* [**] [internal] Make sure media-related features function correctly. [#20889], [20887]
* [*] [internal] Posts list: Disable action bar/menu button when a post is being uploaded [#20885]

22.6
-----
Expand Down
17 changes: 17 additions & 0 deletions WordPress/Classes/ViewRelated/Post/PostCardCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class PostCardCell: UITableViewCell, ConfigurablePostView {
configureProgressView()
configureActionBar()
configureAccessibility()
configureActionBarInteraction()
}

override func awakeFromNib() {
Expand Down Expand Up @@ -360,6 +361,22 @@ class PostCardCell: UITableViewCell, ConfigurablePostView {
.joined(separator: " ")
}

private func configureActionBarInteraction() {
guard let viewModel = viewModel else {
return
}

let isProgressBarVisible = !viewModel.shouldHideProgressView

if isProgressBarVisible {
actionBarView.isUserInteractionEnabled = false
actionBarView.alpha = 0.3
} else {
actionBarView.isUserInteractionEnabled = true
actionBarView.alpha = 1.0
}
}

private func setupBorders() {
WPStyleGuide.applyBorderStyle(upperBorder)
WPStyleGuide.applyBorderStyle(bottomBorder)
Expand Down
17 changes: 17 additions & 0 deletions WordPress/Classes/ViewRelated/Post/PostCompactCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PostCompactCell: UITableViewCell, ConfigurablePostView {
configureStatus()
configureFeaturedImage()
configureProgressView()
configureMenuInteraction()
}

@IBAction func more(_ sender: Any) {
Expand Down Expand Up @@ -179,6 +180,22 @@ class PostCompactCell: UITableViewCell, ConfigurablePostView {
}
}

private func configureMenuInteraction() {
guard let viewModel = viewModel else {
return
}

let isProgressBarVisible = !viewModel.shouldHideProgressView

if isProgressBarVisible {
menuButton.isEnabled = false
menuButton.alpha = 0.3
} else {
menuButton.isEnabled = true
menuButton.alpha = 1.0
}
}

private func setupAccessibility() {
menuButton.accessibilityLabel =
NSLocalizedString("More", comment: "Accessibility label for the More button in Post List (compact view).")
Expand Down
10 changes: 9 additions & 1 deletion WordPress/WordPressTest/PostCardCellGhostableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,21 @@ class PostCardCellGhostableTests: CoreDataTestCase {
}

func testActionBarOpacityAfterConfigure() {
let post = PostBuilder(mainContext).build()
let post = PostBuilder(mainContext).with(remoteStatus: .sync).build()
assert(post.managedObjectContext != nil)
postCell.configure(with: post)

XCTAssertEqual(postCell.actionBarView.layer.opacity, 1)
}

func testActionBarOpacityAfterConfigureWithPushingStatus() {
let post = PostBuilder(mainContext).with(remoteStatus: .pushing).build()
assert(post.managedObjectContext != nil)
postCell.configure(with: post)

XCTAssertEqual(postCell.actionBarView.layer.opacity, 0.3)
}

func testHideGhostView() {
let post = PostBuilder(mainContext).build()

Expand Down
18 changes: 13 additions & 5 deletions WordPress/WordPressTest/PostCompactCellGhostableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest

@testable import WordPress

class PostCompactCellGhostableTests: XCTestCase {
class PostCompactCellGhostableTests: CoreDataTestCase {

var postCell: PostCompactCell!

Expand All @@ -30,23 +30,23 @@ class PostCompactCellGhostableTests: XCTestCase {
}

func testIsInteractiveAfterAConfigure() {
let post = PostBuilder().build()
let post = PostBuilder(mainContext).build()

postCell.configure(with: post)

XCTAssertTrue(postCell.isUserInteractionEnabled)
}

func testShowBadgesLabelAfterConfigure() {
let post = PostBuilder().build()
let post = PostBuilder(mainContext).build()

postCell.configure(with: post)

XCTAssertFalse(postCell.badgesLabel.isHidden)
}

func testHideGhostAfterConfigure() {
let post = PostBuilder().build()
let post = PostBuilder(mainContext).build()

postCell.configure(with: post)

Expand All @@ -55,13 +55,21 @@ class PostCompactCellGhostableTests: XCTestCase {
}

func testMenuButtonOpacityAfterConfigure() {
let post = PostBuilder().build()
let post = PostBuilder(mainContext).with(remoteStatus: .sync).build()

postCell.configure(with: post)

XCTAssertEqual(postCell.menuButton.layer.opacity, 1)
}

func testMenuButtonOpacityAfterConfigureWithPushingStatus() {
let post = PostBuilder(mainContext).with(remoteStatus: .pushing).build()

postCell.configure(with: post)

XCTAssertEqual(postCell.menuButton.layer.opacity, 0.3)
}

private func postCellFromNib() -> PostCompactCell {
let bundle = Bundle(for: PostCardCell.self)
guard let postCell = bundle.loadNibNamed("PostCompactCell", owner: nil)?.first as? PostCompactCell else {
Expand Down

0 comments on commit b39df1b

Please sign in to comment.