Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to toggle edit mode for vertical mode #3576

Merged
merged 21 commits into from May 15, 2024

Conversation

porter-stripe
Copy link
Collaborator

@porter-stripe porter-stripe commented May 10, 2024

Summary

  • Shows a toggleable button for "Edit" and "Done" when editing.
  • Adds some delegate methods to pass the button tap back to the view controller
  • Fixed janky push animation
  • Following PRs will update to only show the remove/edit/update buttons when applicable.
Simulator.Screen.Recording.-.iPhone.15.Plus.-.2024-05-12.at.13.54.45.mp4

Motivation

https://jira.corp.stripe.com/browse/MOBILESDK-2026

Testing

  • Manual
  • UI tests to follow in a separate PR

Changelog

N/A

Copy link

github-actions bot commented May 10, 2024

⚠️ Missing Translations

The following translations are missing in Lokalise. While they don't need to be downloaded into the codebase as part of this PR, they do need to exist in Lokalise so that they can be downloaded as part of the release process.

Manage payment methods

By adding the label ship without translations to this PR, I acknowledge that there are missing translations.

@porter-stripe porter-stripe marked this pull request as ready for review May 10, 2024 20:32
@porter-stripe porter-stripe requested review from a team as code owners May 10, 2024 20:32
Comment on lines 60 to 65
navBar.additionalButton.setTitle(UIButton.editButtonTitle, for: .normal)
navBar.additionalButton.setTitleColor(configuration.appearance.colors.primary, for: .normal)
navBar.additionalButton.setTitleColor(configuration.appearance.colors.primary.disabledColor, for: .disabled)
navBar.additionalButton.accessibilityIdentifier = "edit_saved_button"
navBar.additionalButton.titleLabel?.adjustsFontForContentSizeCategory = true
navBar.additionalButton.addTarget(self, action: #selector(didSelectEditSavedPaymentMethodsButton), for: .touchUpInside)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is the 4th place we perform similar configuration to create an Edit button (search for "edit_saved_button"). Feels like an opportunity to DRY.

Comment on lines 150 to 152
private func paymentMethod(from button: PaymentMethodRowButton) -> STPPaymentMethod? {
return paymentMethodRows.first(where: { $0.button === button })?.paymentMethod
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Picking up this convo #3573 (comment)

I understand your point but IMO it's worth making this payment method a property of PaymentMethodRowButton, it lets you get rid of this funny search and removes the possibility that the STPPaymentMethod is nil.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍, refactored out the ViewModel and instead inject a STPPaymentMethod.


// Disable interaction to prevent double selecting since we will be dismissing soon
self.view.isUserInteractionEnabled = false
self.navigationBar.isUserInteractionEnabled = false // Tint buttons in the nav bar to look disabled
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I understand this comment, is it supposed to be a TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, maybe a bad/un-needed comment but the main rational behind disabling the interaction of the nav bar is to give the disabled look to the buttons in the nav bar.

Right after selecting:
CleanShot 2024-05-14 at 14 35 28

Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't the main rationale to disable interaction? You wouldn't want to be able to edit while we are in the middle of transitioning back to the main screen.

@@ -132,16 +132,19 @@ class SheetNavigationBar: UIView {
// MARK: -
enum Style {
case close(showAdditionalButton: Bool)
case back
case back(showAdditionalButton: Bool)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Huh, why is showing the additional button tied to the style? Looks like I wrote this code but I don't recall. Does it make sense? Should showAdditionalButton be a separate bool, independent of the style enum?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't feel too strongly about this, I see this more as a convenience to toggle the additional button when switching styles, instead of switching the style then hiding/showing the additional button if needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

For convenience we could still have a update(style: Style, showAdditionalButton: Bool) method. But it's very minor so I'm fine to leave it alone.

Comment on lines +39 to +40
testWindow.rootViewController = bottomSheet
STPSnapshotVerifyView(bottomSheet.view)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The screenshots are all using the test window's fixed height of 500 points @ 3x = 1500 pixels, we should fix so that it autosizes to the real height.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated this so the window size is the height of the VC + the BottomSheet. For some reason even w/ a content view controller the height of the BottomSheet is always just the height of the nav bar (42). FWIW, the testing framework uses the screen bounds as the VC bounds when generating it's view, but instead we use FBSnapshotVerifyView.

https://github.com/uber/ios-snapshot-test-case/blob/57b023c8bb3df361e2fae01532cd066ec0b65d2e/src/iOSSnapshotTestCase/SwiftSupport.swift#L23

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm weird. We should have one simple way to snapshot test these bottom sheet content VCs, we're doing this many times and shouldn't be re-solving it each time.

Our content VCs are special in that they are not presented full screen like normal VCs so I think it's important to simulate using the height of the VC as it would appear in the bottom sheet. Like if our VC has a bug that causes it to be too tall when presented in the sheet, that would be good to catch in the snapshot test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, I'll look at this closer in a following PR

@porter-stripe porter-stripe merged commit 6f1c87b into master May 15, 2024
5 checks passed
@porter-stripe porter-stripe deleted the porter/MOBILESDK-2026 branch May 15, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants