Skip to content

Commit

Permalink
sync dart side with version 0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
Remon committed Jul 8, 2023
1 parent 9270bb4 commit 5791de5
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 21 deletions.
1 change: 1 addition & 0 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe/lib/src/stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> resetPaymentSheetCustomer() async {
await _awaitForSettings();
Expand Down
10 changes: 10 additions & 0 deletions packages/stripe/lib/src/widgets/card_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -178,6 +184,7 @@ class _CardFieldState extends State<CardField> {
delegate: const _NegativeMarginLayout(margin: platformMargin),
child: _MethodChannelCardField(
controller: controller,
disabled: widget.disabled,
height: platformCardHeight,
androidPlatformViewRenderType:
widget.androidPlatformViewRenderType,
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -395,6 +404,7 @@ class _MethodChannelCardFieldState extends State<_MethodChannelCardField>
controller.initalDetails != null)
'cardDetails': controller.initalDetails?.toJson(),
'autofocus': widget.autofocus,
'disabled': widget.disabled,
};

Widget platform;
Expand Down
34 changes: 22 additions & 12 deletions packages/stripe/lib/src/widgets/card_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -187,6 +193,7 @@ class _CardFormFieldState extends State<CardFormField> {
enablePostalCode: widget.enablePostalCode,
onCardChanged: widget.onCardChanged,
autofocus: widget.autofocus,
disabled: widget.disabled,
onFocus: widget.onFocus,
countryCode: widget.countryCode,
);
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -299,6 +308,7 @@ class _MethodChannelCardFormFieldState
controller._initalDetails != null)
'cardDetails': controller._initalDetails?.toJson(),
'autofocus': widget.autofocus,
'disabled': widget.disabled,
'defaultValues': {
'countryCode': widget.countryCode,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,7 +56,7 @@ class StripeSdkCardPlatformView(
val value = ReadableMap(creationParams["cardDetails"] as Map<String, Any>)
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")
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any?> = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 5791de5

Please sign in to comment.