From f01e4d57797eef38e414cb86de81bfe31dd87e82 Mon Sep 17 00:00:00 2001 From: Remon <> Date: Sat, 8 Jul 2023 20:30:05 +0200 Subject: [PATCH] sync dart side with version 0.28 --- example/ios/Runner.xcodeproj/project.pbxproj | 1 + .../no_webhook_payment_cardform_screen.dart | 1 + .../no_webhook_payment_screen.dart | 1 + packages/stripe/lib/src/stripe.dart | 2 +- .../stripe/lib/src/widgets/card_field.dart | 10 ++++++ .../lib/src/widgets/card_form_field.dart | 34 ++++++++++++------- packages/stripe_android/android/build.gradle | 2 +- .../stripe/StripeSdkCardFormPlatformView.kt | 4 +-- .../stripe/StripeSdkCardPlatformView.kt | 6 ++-- .../com/reactnativestripesdk/CardFieldView.kt | 2 +- .../pushprovisioning/AddToWalletButtonView.kt | 2 +- 11 files changed, 44 insertions(+), 21 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 729c8c8e8..d402467cc 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -299,6 +299,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/example/lib/screens/card_payments/no_webhook_payment_cardform_screen.dart b/example/lib/screens/card_payments/no_webhook_payment_cardform_screen.dart index a4bb24e66..35240891f 100644 --- a/example/lib/screens/card_payments/no_webhook_payment_cardform_screen.dart +++ b/example/lib/screens/card_payments/no_webhook_payment_cardform_screen.dart @@ -41,6 +41,7 @@ class _NoWebhookPaymentCardFormScreenState padding: EdgeInsets.symmetric(horizontal: 16), children: [ CardFormField( + disabled: false, controller: controller, countryCode: 'US', style: CardFormStyle( diff --git a/example/lib/screens/card_payments/no_webhook_payment_screen.dart b/example/lib/screens/card_payments/no_webhook_payment_screen.dart index 23f0b9cd2..625e53eb6 100644 --- a/example/lib/screens/card_payments/no_webhook_payment_screen.dart +++ b/example/lib/screens/card_payments/no_webhook_payment_screen.dart @@ -40,6 +40,7 @@ class _NoWebhookPaymentScreenState extends State { children: [ CardField( controller: controller, + disabled: true, ), SizedBox(height: 20), LoadingButton( diff --git a/packages/stripe/lib/src/stripe.dart b/packages/stripe/lib/src/stripe.dart index 65ade184f..bb2ca9cdc 100644 --- a/packages/stripe/lib/src/stripe.dart +++ b/packages/stripe/lib/src/stripe.dart @@ -506,7 +506,7 @@ class Stripe { /// Call this method when the user logs out from your app. /// - /// This will ensur ethat any persisted authentication state in the + /// This will ensure that any persisted authentication state in the /// paymentsheet, such as authentication cookies are cleared during logout. Future resetPaymentSheetCustomer() async { await _awaitForSettings(); diff --git a/packages/stripe/lib/src/widgets/card_field.dart b/packages/stripe/lib/src/widgets/card_field.dart index b0419c5a4..82e9d7562 100644 --- a/packages/stripe/lib/src/widgets/card_field.dart +++ b/packages/stripe/lib/src/widgets/card_field.dart @@ -21,6 +21,7 @@ class CardField extends StatefulWidget { this.countryCode, this.style, this.autofocus = false, + this.disabled = false, this.dangerouslyGetFullCardDetails = false, this.dangerouslyUpdateFullCardDetails = false, this.cursorColor, @@ -77,6 +78,11 @@ class CardField extends StatefulWidget { /// Default is `false`. final bool autofocus; + /// When true it applies a state that does not allow the user to interact with + /// the card form field. + /// Default is `false`. + final bool disabled; + /// Controller that can be use to execute several operations on the cardfield /// e.g (clear). final CardEditController? controller; @@ -178,6 +184,7 @@ class _CardFieldState extends State { delegate: const _NegativeMarginLayout(margin: platformMargin), child: _MethodChannelCardField( controller: controller, + disabled: widget.disabled, height: platformCardHeight, androidPlatformViewRenderType: widget.androidPlatformViewRenderType, @@ -274,6 +281,7 @@ class _MethodChannelCardField extends StatefulWidget { this.style, this.placeholder, this.enablePostalCode = false, + this.disabled = false, this.countryCode, double? width, double? height = kCardFieldDefaultHeight, @@ -298,6 +306,7 @@ class _MethodChannelCardField extends StatefulWidget { final String? countryCode; final FocusNode focusNode; final bool autofocus; + final bool disabled; final CardEditController controller; final bool dangerouslyGetFullCardDetails; final bool dangerouslyUpdateFullCardDetails; @@ -395,6 +404,7 @@ class _MethodChannelCardFieldState extends State<_MethodChannelCardField> controller.initalDetails != null) 'cardDetails': controller.initalDetails?.toJson(), 'autofocus': widget.autofocus, + 'disabled': widget.disabled, }; Widget platform; diff --git a/packages/stripe/lib/src/widgets/card_form_field.dart b/packages/stripe/lib/src/widgets/card_form_field.dart index 4797e0642..7ab7de580 100644 --- a/packages/stripe/lib/src/widgets/card_form_field.dart +++ b/packages/stripe/lib/src/widgets/card_form_field.dart @@ -18,18 +18,19 @@ import 'keep_visible_on_focus.dart'; /// ![Sripe Card Form] /// (https://github.com/flutter-stripe/flutter_stripe/tree/main/docs/assets/card_form.png) class CardFormField extends StatefulWidget { - const CardFormField( - {this.onCardChanged, - Key? key, - this.onFocus, - this.enablePostalCode = true, - this.countryCode, - this.style, - this.autofocus = false, - this.dangerouslyGetFullCardDetails = false, - this.dangerouslyUpdateFullCardDetails = false, - this.controller}) - : super(key: key); + const CardFormField({ + this.onCardChanged, + Key? key, + this.onFocus, + this.enablePostalCode = true, + this.countryCode, + this.style, + this.autofocus = false, + this.dangerouslyGetFullCardDetails = false, + this.dangerouslyUpdateFullCardDetails = false, + this.disabled = false, + this.controller, + }) : super(key: key); /// Callback that will be executed when a specific field gets focus. final CardFocusCallback? onFocus; @@ -80,6 +81,11 @@ class CardFormField extends StatefulWidget { /// Default is `false`. final bool dangerouslyUpdateFullCardDetails; + /// When true it applies a state that does not allow the user to interact with + /// the card form field. + /// Default is `false`. + final bool disabled; + @override // ignore: library_private_types_in_public_api _CardFormFieldState createState() => _CardFormFieldState(); @@ -187,6 +193,7 @@ class _CardFormFieldState extends State { enablePostalCode: widget.enablePostalCode, onCardChanged: widget.onCardChanged, autofocus: widget.autofocus, + disabled: widget.disabled, onFocus: widget.onFocus, countryCode: widget.countryCode, ); @@ -212,6 +219,7 @@ class _MethodChannelCardFormField extends StatefulWidget { this.dangerouslyGetFullCardDetails = false, this.dangerouslyUpdateFullCardDetails = false, this.autofocus = false, + this.disabled = false, this.countryCode, }) : assert(constraints == null || constraints.debugAssertIsValid()), constraints = (width != null || height != null) @@ -227,6 +235,7 @@ class _MethodChannelCardFormField extends StatefulWidget { final bool enablePostalCode; final FocusNode focusNode; final bool autofocus; + final bool disabled; final CardFormEditController controller; final bool dangerouslyGetFullCardDetails; final bool dangerouslyUpdateFullCardDetails; @@ -299,6 +308,7 @@ class _MethodChannelCardFormFieldState controller._initalDetails != null) 'cardDetails': controller._initalDetails?.toJson(), 'autofocus': widget.autofocus, + 'disabled': widget.disabled, 'defaultValues': { 'countryCode': widget.countryCode, } diff --git a/packages/stripe_android/android/build.gradle b/packages/stripe_android/android/build.gradle index a1221b8ab..c7e2e2ff1 100644 --- a/packages/stripe_android/android/build.gradle +++ b/packages/stripe_android/android/build.gradle @@ -3,7 +3,7 @@ version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.8.0' - ext.stripe_version = '20.23.+' + ext.stripe_version = '20.25.+' repositories { google() diff --git a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardFormPlatformView.kt b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardFormPlatformView.kt index 8416e5deb..c7a16a116 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardFormPlatformView.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardFormPlatformView.kt @@ -11,7 +11,7 @@ import com.facebook.react.uimanager.ThemedReactContext import com.reactnativestripesdk.* import com.reactnativestripesdk.utils.getIntOrNull import com.reactnativestripesdk.utils.getValOr -import com.stripe.android.databinding.CardMultilineWidgetBinding +import com.stripe.android.databinding.StripeCardMultilineWidgetBinding import com.stripe.android.databinding.StripeCardFormViewBinding import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel @@ -110,7 +110,7 @@ class StripeSdkCardFormPlatformView( result.success(null) } "requestFocus" -> { - val binding = CardMultilineWidgetBinding.bind(cardView.cardForm) + val binding = StripeCardMultilineWidgetBinding.bind(cardView.cardForm) binding.etCardNumber.requestFocus() val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); diff --git a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardPlatformView.kt b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardPlatformView.kt index 1facb6fc1..ba4e9adad 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardPlatformView.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardPlatformView.kt @@ -9,7 +9,7 @@ import com.facebook.react.uimanager.ThemedReactContext import com.reactnativestripesdk.* import com.reactnativestripesdk.utils.getIntOrNull import com.reactnativestripesdk.utils.getValOr -import com.stripe.android.databinding.CardInputWidgetBinding +import com.stripe.android.databinding.StripeCardInputWidgetBinding import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.platform.PlatformView @@ -56,7 +56,7 @@ class StripeSdkCardPlatformView( val value = ReadableMap(creationParams["cardDetails"] as Map) stripeSdkCardViewManager.setCardDetails(value, themedContext) - val binding = CardInputWidgetBinding.bind(cardView.mCardWidget) + val binding = StripeCardInputWidgetBinding.bind(cardView.mCardWidget) val number = getValOr(value, "number", null) val expirationYear = getIntOrNull(value, "expiryYear") val expirationMonth = getIntOrNull(value, "expiryMonth") @@ -127,7 +127,7 @@ class StripeSdkCardPlatformView( result.success(null) } "requestFocus" -> { - val binding = CardInputWidgetBinding.bind(cardView.mCardWidget) + val binding = StripeCardInputWidgetBinding.bind(cardView.mCardWidget) binding.cardNumberEditText.requestFocus() val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CardFieldView.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CardFieldView.kt index f032b13bb..4475bd170 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CardFieldView.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/CardFieldView.kt @@ -33,7 +33,7 @@ import java.lang.Exception class CardFieldView(context: ThemedReactContext) : FrameLayout(context) { internal var mCardWidget: CardInputWidget = CardInputWidget(context) - private val cardInputWidgetBinding = CardInputWidgetBinding.bind(mCardWidget) + private val cardInputWidgetBinding = StripeCardInputWidgetBinding.bind(mCardWidget) val cardDetails: MutableMap = mutableMapOf("brand" to "", "last4" to "", "expiryMonth" to null, "expiryYear" to null, "postalCode" to "", "validNumber" to "Unknown", "validCVC" to "Unknown", "validExpiryDate" to "Unknown") var cardParams: PaymentMethodCreateParams.Card? = null var cardAddress: Address? = null diff --git a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt index 653c29f3a..6a69c2e30 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt @@ -95,7 +95,7 @@ class AddToWalletButtonView(private val context: ThemedReactContext, private val } }) .centerCrop() - .override((widthOverride * scale).toInt(), (heightOverride * scale).toInt()) + .override((widthOverride * scale.toInt()), (heightOverride * scale.toInt())) .into(this) } }