braintree-ios-drop-in icon indicating copy to clipboard operation
braintree-ios-drop-in copied to clipboard

SwiftUI layout is still broken on a presentation sheet.

Open carlosdelamora opened this issue 4 years ago • 5 comments

Integration Details (please complete the following information):

  • SDK/Library Version: 8.1.2
  • Environment: Sandbox
  • iOS Version: 14.3
  • Device iPhone 12
  • Integration type & version CocoaPods

Describe the bug The presentation of a BTDropInController using the sheet SwiftUI property has a jumpy presentation. This bug is related to #202

To Reproduce Steps to reproduce the behavior: This is the code for UIViewControllerRepresentable

struct DropInRepresentable: UIViewControllerRepresentable {
    
    var authorization: String
    var handler: BTDropInControllerHandler
    
    init(authorization: String, handler: @escaping BTDropInControllerHandler) {
           self.authorization = authorization
           self.handler = handler
    }
    
    func makeUIViewController(context: Context) -> BTDropInController {
        let request = BTDropInRequest()
        //request.payPalRequest = payPalRequest
        request.applePayDisabled = true
        let dropInController = BTDropInController(authorization: authorization, request: request, handler: handler)!
        return dropInController
    }
        
    func updateUIViewController(_ uiViewController: BTDropInController, context: UIViewControllerRepresentableContext<DropInRepresentable>) {
    }
}

This is the code to present the view controller

.sheet(isPresented: $isShowingPaymentFlow)  {
            DropInRepresentable(authorization: braintreeToken.token) { controller, result, error in
                print("result \(result)")
            }
        }

Expected behavior Expected to show the DropInRespresentable view with a correct layout.

Actual behavior The DropInRespresentable view shows full screen then abruptly shrinks to the correct size.

Screenshots

https://user-images.githubusercontent.com/16446741/105643099-8b761400-5e53-11eb-8291-4b70b601ff5d.MP4

carlosdelamora avatar Jan 24 '21 20:01 carlosdelamora

Hi @carlosdelamora, thanks for reporting this! We'll take a look and post any updates here.

sestevens avatar Jan 25 '21 15:01 sestevens

Any update on this?

RamblinWreck77 avatar Mar 19 '21 18:03 RamblinWreck77

@RamblinWreck77 We don't have any updates at the moment. We're currently focused on a couple other things (namely, Swift Package Manager support and accessibility improvements). If this is something you're interested in working on, we'd be happy to review a PR for it.

sestevens avatar Mar 22 '21 14:03 sestevens

Is there any guide for Drop-in in Swift UI? I have already done the client side and a simple server but I don't know how to send the nonce to my server and test it

JavierMazarioPicazo avatar May 05 '21 09:05 JavierMazarioPicazo

Hi @JavierMazarioPicazo - no we don't officially offer SwiftUI support yet (nor have a guide) though it is something we are looking into.

If you already have the client-side UI set up and your server set up, then you should send your nonce to your server the same way you would with a UIKit integration. You can see our docs for an example of that here.

scannillo avatar May 05 '21 14:05 scannillo