Shopify / checkout-sheet-kit-swift

Shopify’s Checkout Sheet Kit makes it simple to perform a checkout inside your Swift native app.
MIT License
38 stars 16 forks source link

Prevent webview from scrolling past the bottom 0 limit #60

Closed leandrooriente closed 1 year ago

leandrooriente commented 1 year ago

What are you trying to accomplish?

Fix the error that happens if fixing the Pay Button to the bottom of the page. IOS allows the user to scroll past the bottom 0, which breaks the fixed position of the button.

Bug:

https://github.com/Shopify/mobile-checkout-sdk-ios/assets/1781007/e6a9c08f-d28b-4584-bf4e-328b5830dd00

checkoutView.scrollView.contentInsetAdjustmentBehavior = .never Removing the inset auto adjustment from the view helps, but breaks the header.

https://github.com/Shopify/mobile-checkout-sdk-ios/assets/1781007/7e169a62-d896-4ae6-b5e0-967d60b89b6b

Anchoring the top of the webview to the safe area solves this issue checkoutView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor)

https://github.com/Shopify/mobile-checkout-sdk-ios/assets/1781007/717286d5-40e1-44bd-becb-c3435aab2f70

No negative effects if the sticky button is disabled:

https://github.com/Shopify/mobile-checkout-sdk-ios/assets/1781007/aca13a9c-4533-4efd-ab57-e8a3ef324fcd

Before you deploy