flutter-plugin icon indicating copy to clipboard operation
flutter-plugin copied to clipboard

[PR] Add cornerRadius to ApplePayButtonView

Open AymenFarrah opened this issue 2 years ago • 4 comments

Hello,

We can customize the Apple Pay Button with a cornerRadius (by default set to 4.0)

So to do this we need to add when create the button :

let buttonType = arguments["type"] as! String
let buttonStyle = arguments["style"] as! String
let cornerRadius = arguments["cornerRadius"] as! CGFloat

then create the button with this method :

createApplePayView(type: buttonType, style: buttonStyle, cornerRadius: cornerRadius)

and finally customize it only when available iOS 12 minimum :

// Create the PK objects
    let paymentButtonType = PKPaymentButtonType.fromString(buttonTypeString) ?? .plain
    let paymentButtonStyle = PKPaymentButtonStyle.fromString(buttonStyleString) ?? .black
    let applePayButton = PKPaymentButton(paymentButtonType: paymentButtonType, paymentButtonStyle: paymentButtonStyle)

    if #available(iOS 12.0, *) {
        applePayButton.cornerRadius = cornerRadius
    }

AymenFarrah avatar Apr 27 '22 07:04 AymenFarrah

Hi @AymenFarrah, thank you for the suggestion. Feel free to suggest a PR with the changes and we'll take a look. If you are not able to do so, let us know too.

JlUgia avatar Jun 01 '22 10:06 JlUgia

Related to https://github.com/google-pay/flutter-plugin/issues/32

JlUgia avatar Jun 01 '22 12:06 JlUgia

Hi @AymenFarrah, thank you for the suggestion. Feel free to suggest a PR with the changes and we'll take a look. If you are not able to do so, let us know too.

Hi @JlUgia ! I'm trying to open a new pull request based from main but Create pull request button is disabled.

AymenFarrah avatar Jun 01 '22 12:06 AymenFarrah

Hello @AymenFarrah, PRs are accepted from external forks. Please take a look at the contribution guide before proposing any changes.

JlUgia avatar Aug 17 '22 11:08 JlUgia

Published under 1.2.0-beta02.

JlUgia avatar Jan 21 '24 12:01 JlUgia