Skip to content

Remove BottomSheetViewController usages – #1#23448

Merged
kean merged 2 commits intotrunkfrom
task/remove-bottomvc-1
Aug 2, 2024
Merged

Remove BottomSheetViewController usages – #1#23448
kean merged 2 commits intotrunkfrom
task/remove-bottomvc-1

Conversation

@kean
Copy link
Contributor

@kean kean commented Jul 29, 2024

This is some background work to remove BottomSheetViewController, which is a quite large class that also has a couple of warnings. We don't want to maintain that, and the UIKit components do the same but better now.

Before → After (iPhone)

The new version is better for accessibility with a visible close button.

Screenshot 2024-07-29 at 3 02 03 PM Screenshot 2024-07-29 at 3 01 32 PM

Before → After (iPad)

On iPad, you should just use a popover for this scenarios. It a much quicker and lighter interaction. There are many other cases where we could take some quick wins by simply using popovers on iPad.

Screenshot 2024-07-29 at 2 25 19 PM Screenshot 2024-07-29 at 2 56 05 PM

To test:

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@kean kean added the General label Jul 29, 2024
@kean kean added this to the Pending milestone Jul 29, 2024
@kean kean requested review from crazytonyli and jkmassel July 29, 2024 19:08
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jul 29, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23448-6c9bb90
Version25.2
Bundle IDorg.wordpress.alpha
Commit6c9bb90
App Center BuildWPiOS - One-Offs #10409
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jul 29, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23448-6c9bb90
Version25.2
Bundle IDcom.jetpack.alpha
Commit6c9bb90
App Center Buildjetpack-installable-builds #9451
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

extension CommentDetailInfoViewController {
func show(from presentingViewController: UIViewController, sourceView: UIView) {
let navigationController = UINavigationController(rootViewController: self)
if UIDevice.isPad() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put the app on iPad into split screen, this branch will be executed and the view controller will be presented as a full screen modal instead of popover. Maybe we should check horizontal size class instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I changed it to presentingViewController.traitCollection.horizontalSizeClass == .regular.

Btw, the Split View is pretty much completely broken on iPad as you can't access any of your site menus.

Screenshot 2024-08-01 at 12 11 24 PM

} else {
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: SharedStrings.Button.close, primaryAction: UIAction { [weak presentingViewController] _ in
presentingViewController?.dismiss(animated: true)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it makes better sense to put this code into the if let sheet block below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's presented modally with the default settings, it still needs a "Cancel" button.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah of course. I misread the code...

sheet.detents = [.medium(), .large()]
sheet.prefersGrabberVisible = true
navigationController.additionalSafeAreaInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) // For grabber
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking iPad or size class, maybe we can present the info either in sheet if available, and fallback to popover if sheet is not available?

@kean kean force-pushed the task/remove-bottomvc-1 branch from 3c85985 to 572ebbc Compare August 1, 2024 16:16
@kean kean requested a review from crazytonyli August 1, 2024 16:19
tableView.layoutIfNeeded()
preferredContentSize = tableView.contentSize

if UIDevice.isPad() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think changing this condition to something like navigationController?.modalPresentationStyle == .popover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, forgot to remove it. It's safe to not have any condition here. preferredContentSize will only be used by the presentation controllers that need it, like the popover. Updated.


if UIDevice.isPad() {
preferredContentSize = CGSize(width: 320, height: tableView.contentSize.height)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you can delete this setting preferredContentSize code if setting tableView.scrollable = false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or other ways to make UITableView display its full content.

I'm not sure using UITableView is a good choice here... I presume UIKit would take autolayout into account when displaying a popover. We probably don't need to set preferredContentSize if using a UIStackView instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the existing implementation. I'm not planning to rework it in the scope of this PR.

@kean kean requested a review from crazytonyli August 1, 2024 22:49
@kean kean enabled auto-merge August 2, 2024 00:36
@kean kean added this pull request to the merge queue Aug 2, 2024
Merged via the queue into trunk with commit 084d645 Aug 2, 2024
@kean kean deleted the task/remove-bottomvc-1 branch August 2, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants