@stripe/stripe-react-native 0.56.0 → 0.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +76 -118
- package/android/gradle.properties +1 -1
- package/android/settings.gradle +2 -0
- package/android/spotless.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +24 -20
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +20 -17
- package/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +28 -32
- package/android/src/main/java/com/reactnativestripesdk/{CollectBankAccountLauncherFragment.kt → CollectBankAccountLauncherManager.kt} +23 -44
- package/android/src/main/java/com/reactnativestripesdk/CustomPaymentMethodActivity.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +4 -11
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +52 -132
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +0 -8
- package/android/src/main/java/com/reactnativestripesdk/FakeOnrampSdkModule.kt +154 -0
- package/android/src/main/java/com/reactnativestripesdk/{FinancialConnectionsSheetFragment.kt → FinancialConnectionsSheetManager.kt} +43 -92
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +107 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherManager.kt +37 -0
- package/android/src/main/java/com/reactnativestripesdk/GooglePayRequestHelper.kt +7 -5
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarManager.kt +31 -0
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +120 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +228 -0
- package/android/src/main/java/com/reactnativestripesdk/{PaymentLauncherFragment.kt → PaymentLauncherManager.kt} +40 -77
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +11 -20
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +4 -6
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +409 -483
- package/android/src/main/java/com/reactnativestripesdk/{PaymentSheetFragment.kt → PaymentSheetManager.kt} +65 -300
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +53 -17
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +227 -232
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +21 -2
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +78 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +52 -39
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +2 -2
- package/android/src/main/java/com/reactnativestripesdk/customersheet/{CustomerSheetFragment.kt → CustomerSheetManager.kt} +64 -99
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -3
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +5 -10
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonView.kt +90 -77
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/TapAndPayProxy.kt +6 -4
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +13 -3
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +87 -11
- package/android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +178 -185
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeUIManager.kt +62 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +118 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +4 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +922 -0
- package/android/src/test/java/com/facebook/testutils/shadows/ShadowArguments.kt +29 -0
- package/android/src/test/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManagerTest.kt +163 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentElementConfigTest.kt +976 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetAppearanceTest.kt +801 -0
- package/android/src/test/java/com/reactnativestripesdk/PaymentSheetManagerTest.kt +523 -0
- package/android/src/test/java/com/reactnativestripesdk/addresssheet/AddressSheetViewTest.kt +551 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +567 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +456 -0
- package/android/src/test/java/com/reactnativestripesdk/pushprovisioning/PushProvisioningProxyTest.kt +43 -0
- package/android/src/test/resources/robolectric.properties +2 -0
- package/ios/AddressSheet/AddressSheetUtils.swift +3 -3
- package/ios/AddressSheet/AddressSheetView.swift +26 -26
- package/ios/AddressSheet/AddressSheetViewManager.swift +2 -2
- package/ios/ApplePayButtonManager.swift +1 -1
- package/ios/ApplePayButtonView.swift +9 -10
- package/ios/ApplePayUtils.swift +51 -51
- package/ios/ApplePayViewController.swift +25 -29
- package/ios/AuBECSDebitFormManager.swift +1 -1
- package/ios/AuBECSDebitFormView.swift +13 -15
- package/ios/CardFieldManager.swift +4 -4
- package/ios/CardFieldView.swift +9 -9
- package/ios/CardFormManager.swift +3 -3
- package/ios/CardFormView.swift +28 -28
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingView.swift +97 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +133 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.m +16 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewManager.swift +17 -0
- package/ios/CustomerSheet/CustomerSheetUtils.swift +15 -16
- package/ios/CustomerSheet/ReactNativeCustomerAdapter.swift +19 -19
- package/ios/EmbeddedPaymentElementView.swift +2 -2
- package/ios/Errors.swift +22 -23
- package/ios/FinancialConnections.swift +37 -37
- package/ios/Mappers.swift +212 -75
- package/ios/NavigationBarManager.m +13 -0
- package/ios/NavigationBarManager.swift +17 -0
- package/ios/NavigationBarView.swift +65 -0
- package/ios/NewArch/NavigationBarComponentView.h +10 -0
- package/ios/NewArch/NavigationBarComponentView.mm +86 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +7 -1
- package/ios/PaymentMethodFactory.swift +24 -41
- package/ios/PaymentOptionDisplayData+ReactNative.swift +4 -4
- package/ios/PaymentPassFinder.swift +9 -10
- package/ios/PaymentSheetAppearance.swift +137 -138
- package/ios/PushProvisioning/AddToWalletButtonManager.swift +2 -2
- package/ios/PushProvisioning/AddToWalletButtonView.swift +16 -18
- package/ios/PushProvisioning/PushProvisioningUtils.swift +11 -11
- package/ios/StripeContainerManager.swift +1 -1
- package/ios/StripeContainerView.swift +3 -3
- package/ios/StripeOnrampSdk.h +17 -0
- package/ios/StripeOnrampSdk.mm +158 -0
- package/ios/StripeSdk.mm +8 -0
- package/ios/StripeSdkEmitter.swift +4 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +31 -26
- package/ios/StripeSdkImpl+Embedded.swift +11 -9
- package/ios/StripeSdkImpl+PaymentSheet.swift +51 -42
- package/ios/StripeSdkImpl.swift +919 -191
- package/ios/UIColorExtension.swift +72 -0
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/components/StripeProvider.js +1 -1
- package/lib/commonjs/components/StripeProvider.js.map +1 -1
- package/lib/commonjs/connect/Components.js +2 -0
- package/lib/commonjs/connect/Components.js.map +1 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js +2 -0
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/commonjs/connect/EmbeddedComponent.js +19 -0
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -0
- package/lib/commonjs/connect/ModalCloseButton.js +2 -0
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -0
- package/lib/commonjs/connect/NavigationBar.js +2 -0
- package/lib/commonjs/connect/NavigationBar.js.map +1 -0
- package/lib/commonjs/connect/connectTypes.js +2 -0
- package/lib/commonjs/connect/connectTypes.js.map +1 -0
- package/lib/commonjs/events.js +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/helpers.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +2 -0
- package/lib/commonjs/hooks/useOnramp.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugin/withStripe.js +1 -1
- package/lib/commonjs/plugin/withStripe.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js.map +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +2 -0
- package/lib/commonjs/specs/NativeNavigationBar.js.map +1 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/Onramp.js +2 -0
- package/lib/commonjs/types/Onramp.js.map +1 -0
- package/lib/commonjs/types/PaymentIntent.js.map +1 -1
- package/lib/commonjs/types/PaymentSheet.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/components/StripeProvider.js +1 -1
- package/lib/module/components/StripeProvider.js.map +1 -1
- package/lib/module/connect/Components.js +2 -0
- package/lib/module/connect/Components.js.map +1 -0
- package/lib/module/connect/ConnectComponentsProvider.js +2 -0
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -0
- package/lib/module/connect/EmbeddedComponent.js +19 -0
- package/lib/module/connect/EmbeddedComponent.js.map +1 -0
- package/lib/module/connect/ModalCloseButton.js +2 -0
- package/lib/module/connect/ModalCloseButton.js.map +1 -0
- package/lib/module/connect/NavigationBar.js +2 -0
- package/lib/module/connect/NavigationBar.js.map +1 -0
- package/lib/module/connect/connectTypes.js +2 -0
- package/lib/module/connect/connectTypes.js.map +1 -0
- package/lib/module/events.js +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/helpers.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +2 -0
- package/lib/module/hooks/useOnramp.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withStripe.js +1 -1
- package/lib/module/plugin/withStripe.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js.map +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js.map +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js.map +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js.map +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +2 -0
- package/lib/module/specs/NativeConnectAccountOnboardingView.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeGooglePayButton.js.map +1 -1
- package/lib/module/specs/NativeNavigationBar.js +2 -0
- package/lib/module/specs/NativeNavigationBar.js.map +1 -0
- package/lib/module/specs/NativeOnrampSdkModule.js +2 -0
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -0
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/Onramp.js +2 -0
- package/lib/module/types/Onramp.js.map +1 -0
- package/lib/module/types/PaymentIntent.js.map +1 -1
- package/lib/module/types/PaymentSheet.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/StripeProvider.d.ts.map +1 -1
- package/lib/typescript/src/connect/Components.d.ts +23 -0
- package/lib/typescript/src/connect/Components.d.ts.map +1 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts +22 -0
- package/lib/typescript/src/connect/ConnectComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts +18 -0
- package/lib/typescript/src/connect/EmbeddedComponent.d.ts.map +1 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts +7 -0
- package/lib/typescript/src/connect/ModalCloseButton.d.ts.map +1 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts +8 -0
- package/lib/typescript/src/connect/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/connect/connectTypes.d.ts +464 -0
- package/lib/typescript/src/connect/connectTypes.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +3 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/helpers.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +158 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withStripe.d.ts +15 -0
- package/lib/typescript/src/plugin/withStripe.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts +14 -0
- package/lib/typescript/src/specs/NativeConnectAccountOnboardingView.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts +11 -0
- package/lib/typescript/src/specs/NativeNavigationBar.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +28 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Errors.d.ts +5 -0
- package/lib/typescript/src/types/Errors.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +275 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -0
- package/lib/typescript/src/types/PaymentIntent.d.ts +1 -9
- package/lib/typescript/src/types/PaymentIntent.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentMethod.d.ts +2 -8
- package/lib/typescript/src/types/PaymentMethod.d.ts.map +1 -1
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +24 -12
- package/src/components/StripeProvider.tsx +5 -0
- package/src/connect/Components.tsx +279 -0
- package/src/connect/ConnectComponentsProvider.tsx +93 -0
- package/src/connect/EmbeddedComponent.tsx +407 -0
- package/src/connect/ModalCloseButton.tsx +44 -0
- package/src/connect/NavigationBar.tsx +29 -0
- package/src/connect/connectTypes.ts +626 -0
- package/src/events.ts +22 -0
- package/src/hooks/useOnramp.tsx +334 -0
- package/src/index.tsx +13 -0
- package/src/plugin/withStripe.ts +104 -7
- package/src/specs/NativeConnectAccountOnboardingView.ts +19 -0
- package/src/specs/NativeNavigationBar.ts +16 -0
- package/src/specs/NativeOnrampSdkModule.ts +47 -0
- package/src/specs/NativeStripeSdkModule.ts +5 -0
- package/src/types/Errors.ts +6 -0
- package/src/types/Onramp.ts +317 -0
- package/src/types/PaymentIntent.ts +0 -10
- package/src/types/PaymentMethod.ts +0 -9
- package/src/types/PaymentSheet.ts +7 -0
- package/src/types/index.ts +8 -0
- package/stripe-react-native.podspec +21 -8
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -703
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -18
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherFragment.kt +0 -146
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +0 -68
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +0 -102
- package/android/src/main/java/com/reactnativestripesdk/utils/StripeFragment.kt +0 -52
|
@@ -3,487 +3,490 @@ package com.reactnativestripesdk
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.content.res.Configuration
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import androidx.core.graphics.toColorInt
|
|
7
|
+
import com.facebook.react.bridge.Arguments
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import com.facebook.react.bridge.ReadableType
|
|
8
10
|
import com.reactnativestripesdk.utils.PaymentSheetAppearanceException
|
|
11
|
+
import com.reactnativestripesdk.utils.getBooleanOrNull
|
|
12
|
+
import com.reactnativestripesdk.utils.getDoubleOrNull
|
|
13
|
+
import com.reactnativestripesdk.utils.getFloatOr
|
|
14
|
+
import com.reactnativestripesdk.utils.getFloatOrNull
|
|
9
15
|
import com.stripe.android.paymentelement.AppearanceAPIAdditionsPreview
|
|
10
16
|
import com.stripe.android.paymentsheet.PaymentSheet
|
|
11
17
|
import com.stripe.android.uicore.StripeThemeDefaults
|
|
12
18
|
|
|
13
19
|
@SuppressLint("RestrictedApi")
|
|
14
20
|
fun buildPaymentSheetAppearance(
|
|
15
|
-
userParams:
|
|
21
|
+
userParams: ReadableMap?,
|
|
16
22
|
context: Context,
|
|
17
23
|
): PaymentSheet.Appearance {
|
|
18
|
-
val colorParams = userParams?.
|
|
19
|
-
val lightColorParams = colorParams?.
|
|
20
|
-
val darkColorParams = colorParams?.
|
|
21
|
-
val insetParams = userParams?.
|
|
24
|
+
val colorParams = userParams?.getMap(PaymentSheetAppearanceKeys.COLORS)
|
|
25
|
+
val lightColorParams = colorParams?.getMap(PaymentSheetAppearanceKeys.LIGHT) ?: colorParams
|
|
26
|
+
val darkColorParams = colorParams?.getMap(PaymentSheetAppearanceKeys.DARK) ?: colorParams
|
|
27
|
+
val insetParams = userParams?.getMap(PaymentSheetAppearanceKeys.FORM_INSETS)
|
|
22
28
|
|
|
23
29
|
val embeddedAppearance =
|
|
24
30
|
buildEmbeddedAppearance(
|
|
25
|
-
userParams?.
|
|
26
|
-
lightColorParams,
|
|
31
|
+
userParams?.getMap(PaymentSheetAppearanceKeys.EMBEDDED_PAYMENT_ELEMENT),
|
|
27
32
|
context,
|
|
28
33
|
)
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
),
|
|
41
|
-
embeddedAppearance = embeddedAppearance,
|
|
42
|
-
formInsetValues = buildFormInsets(insetParams),
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return PaymentSheet.Appearance(
|
|
47
|
-
typography = buildTypography(userParams?.getBundle(PaymentSheetAppearanceKeys.FONT), context),
|
|
48
|
-
colorsLight = buildColors(lightColorParams, PaymentSheet.Colors.defaultLight),
|
|
49
|
-
colorsDark = buildColors(darkColorParams, PaymentSheet.Colors.defaultDark),
|
|
50
|
-
shapes = buildShapes(userParams?.getBundle(PaymentSheetAppearanceKeys.SHAPES)),
|
|
51
|
-
primaryButton =
|
|
52
|
-
buildPrimaryButton(
|
|
53
|
-
userParams?.getBundle(PaymentSheetAppearanceKeys.PRIMARY_BUTTON),
|
|
54
|
-
context,
|
|
55
|
-
),
|
|
56
|
-
formInsetValues = buildFormInsets(insetParams),
|
|
35
|
+
val builder = PaymentSheet.Appearance.Builder()
|
|
36
|
+
builder.typography(buildTypography(userParams?.getMap(PaymentSheetAppearanceKeys.FONT), context))
|
|
37
|
+
builder.colorsLight(buildColorsBuilder(isLightMode = true, lightColorParams).build())
|
|
38
|
+
builder.colorsDark(buildColorsBuilder(isLightMode = false, darkColorParams).build())
|
|
39
|
+
builder.shapes(buildShapes(userParams?.getMap(PaymentSheetAppearanceKeys.SHAPES)))
|
|
40
|
+
builder.primaryButton(
|
|
41
|
+
buildPrimaryButton(
|
|
42
|
+
userParams?.getMap(PaymentSheetAppearanceKeys.PRIMARY_BUTTON),
|
|
43
|
+
context,
|
|
44
|
+
),
|
|
57
45
|
)
|
|
46
|
+
builder.embeddedAppearance(embeddedAppearance)
|
|
47
|
+
builder.formInsetValues(buildFormInsets(insetParams))
|
|
48
|
+
return builder.build()
|
|
58
49
|
}
|
|
59
50
|
|
|
51
|
+
@SuppressLint("RestrictedApi")
|
|
60
52
|
@OptIn(AppearanceAPIAdditionsPreview::class)
|
|
61
53
|
private fun buildTypography(
|
|
62
|
-
fontParams:
|
|
54
|
+
fontParams: ReadableMap?,
|
|
63
55
|
context: Context,
|
|
64
56
|
): PaymentSheet.Typography {
|
|
65
|
-
val scale = getDoubleOrNull(
|
|
57
|
+
val scale = fontParams.getDoubleOrNull(PaymentSheetAppearanceKeys.SCALE)
|
|
66
58
|
val resId =
|
|
67
59
|
getFontResId(
|
|
68
60
|
fontParams,
|
|
69
61
|
PaymentSheetAppearanceKeys.FAMILY,
|
|
70
|
-
PaymentSheet.Typography.default.fontResId,
|
|
71
62
|
context,
|
|
72
63
|
)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
val builder = PaymentSheet.Typography.Builder()
|
|
65
|
+
scale?.let {
|
|
66
|
+
builder.sizeScaleFactor(it.toFloat())
|
|
67
|
+
}
|
|
68
|
+
resId?.let {
|
|
69
|
+
builder.fontResId(it)
|
|
70
|
+
}
|
|
71
|
+
return builder.build()
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
@Throws(PaymentSheetAppearanceException::class)
|
|
80
|
-
private fun
|
|
81
|
-
hexString
|
|
82
|
-
default: Int,
|
|
83
|
-
): Int {
|
|
84
|
-
return hexString?.trim()?.replace("#", "")?.let {
|
|
75
|
+
private fun colorFromHex(hexString: String?): Int? =
|
|
76
|
+
hexString?.trim()?.replace("#", "")?.let {
|
|
85
77
|
if (it.length == 6 || it.length == 8) {
|
|
86
|
-
|
|
78
|
+
"#$it".toColorInt()
|
|
87
79
|
} else {
|
|
88
80
|
throw PaymentSheetAppearanceException(
|
|
89
81
|
"Failed to set Payment Sheet appearance. Expected hex string of length 6 or 8, but received: $it",
|
|
90
82
|
)
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
|
|
86
|
+
@SuppressLint("RestrictedApi")
|
|
87
|
+
private fun buildColorsBuilder(
|
|
88
|
+
isLightMode: Boolean,
|
|
89
|
+
colorParams: ReadableMap?,
|
|
90
|
+
): PaymentSheet.Colors.Builder {
|
|
91
|
+
val builder =
|
|
92
|
+
if (isLightMode) {
|
|
93
|
+
PaymentSheet.Colors.Builder.light()
|
|
94
|
+
} else {
|
|
95
|
+
PaymentSheet.Colors.Builder.dark()
|
|
95
96
|
}
|
|
96
|
-
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
default: PaymentSheet.Colors,
|
|
101
|
-
): PaymentSheet.Colors {
|
|
102
|
-
if (colorParams == null) {
|
|
103
|
-
return default
|
|
98
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.PRIMARY))?.let {
|
|
99
|
+
builder.primary(it)
|
|
104
100
|
}
|
|
105
101
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
placeholderText =
|
|
148
|
-
colorFromHexOrDefault(
|
|
149
|
-
colorParams.getString(PaymentSheetAppearanceKeys.PLACEHOLDER_TEXT),
|
|
150
|
-
default.placeholderText,
|
|
151
|
-
),
|
|
152
|
-
appBarIcon =
|
|
153
|
-
colorFromHexOrDefault(
|
|
154
|
-
colorParams.getString(PaymentSheetAppearanceKeys.ICON),
|
|
155
|
-
default.appBarIcon,
|
|
156
|
-
),
|
|
157
|
-
error =
|
|
158
|
-
colorFromHexOrDefault(
|
|
159
|
-
colorParams.getString(PaymentSheetAppearanceKeys.ERROR),
|
|
160
|
-
default.error,
|
|
161
|
-
),
|
|
162
|
-
)
|
|
102
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.BACKGROUND))?.let {
|
|
103
|
+
builder.surface(it)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.COMPONENT_BACKGROUND))?.let {
|
|
107
|
+
builder.component(it)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.COMPONENT_BORDER))?.let {
|
|
111
|
+
builder.componentBorder(it)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.COMPONENT_DIVIDER))?.let {
|
|
115
|
+
builder.componentDivider(it)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.COMPONENT_TEXT))?.let {
|
|
119
|
+
builder.onComponent(it)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.PRIMARY_TEXT))?.let {
|
|
123
|
+
builder.onSurface(it)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.SECONDARY_TEXT))?.let {
|
|
127
|
+
builder.subtitle(it)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.PLACEHOLDER_TEXT))?.let {
|
|
131
|
+
builder.placeholderText(it)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.ICON))?.let {
|
|
135
|
+
builder.appBarIcon(it)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
colorFromHex(colorParams?.getString(PaymentSheetAppearanceKeys.ERROR))?.let {
|
|
139
|
+
builder.error(it)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return builder
|
|
163
143
|
}
|
|
164
144
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
PaymentSheetAppearanceKeys.BORDER_WIDTH,
|
|
177
|
-
PaymentSheet.Shapes.default.borderStrokeWidthDp,
|
|
178
|
-
),
|
|
179
|
-
)
|
|
145
|
+
@SuppressLint("RestrictedApi")
|
|
146
|
+
private fun buildShapes(shapeParams: ReadableMap?): PaymentSheet.Shapes {
|
|
147
|
+
val builder = PaymentSheet.Shapes.Builder()
|
|
148
|
+
|
|
149
|
+
shapeParams.getFloatOrNull(PaymentSheetAppearanceKeys.BORDER_RADIUS)?.let {
|
|
150
|
+
builder.cornerRadiusDp(it)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
shapeParams.getFloatOrNull(PaymentSheetAppearanceKeys.BORDER_WIDTH)?.let {
|
|
154
|
+
builder.borderStrokeWidthDp(it)
|
|
155
|
+
}
|
|
180
156
|
|
|
157
|
+
return builder.build()
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@SuppressLint("RestrictedApi")
|
|
181
161
|
private fun buildPrimaryButton(
|
|
182
|
-
params:
|
|
162
|
+
params: ReadableMap?,
|
|
183
163
|
context: Context,
|
|
184
164
|
): PaymentSheet.PrimaryButton {
|
|
185
165
|
if (params == null) {
|
|
186
166
|
return PaymentSheet.PrimaryButton()
|
|
187
167
|
}
|
|
188
168
|
|
|
189
|
-
val fontParams = params.
|
|
190
|
-
val shapeParams = params.
|
|
191
|
-
val colorParams = params.
|
|
192
|
-
val lightColorParams = colorParams.
|
|
193
|
-
val darkColorParams = colorParams.
|
|
169
|
+
val fontParams = params.getMap(PaymentSheetAppearanceKeys.FONT) ?: Arguments.createMap()
|
|
170
|
+
val shapeParams = params.getMap(PaymentSheetAppearanceKeys.SHAPES) ?: Arguments.createMap()
|
|
171
|
+
val colorParams = params.getMap(PaymentSheetAppearanceKeys.COLORS) ?: Arguments.createMap()
|
|
172
|
+
val lightColorParams = colorParams.getMap(PaymentSheetAppearanceKeys.LIGHT) ?: colorParams
|
|
173
|
+
val darkColorParams = colorParams.getMap(PaymentSheetAppearanceKeys.DARK) ?: colorParams
|
|
194
174
|
|
|
195
175
|
return PaymentSheet.PrimaryButton(
|
|
196
176
|
colorsLight =
|
|
197
|
-
buildPrimaryButtonColors(
|
|
177
|
+
buildPrimaryButtonColors(true, lightColorParams, context).build(),
|
|
198
178
|
colorsDark =
|
|
199
|
-
buildPrimaryButtonColors(
|
|
179
|
+
buildPrimaryButtonColors(false, darkColorParams, context).build(),
|
|
200
180
|
shape =
|
|
201
181
|
PaymentSheet.PrimaryButtonShape(
|
|
202
182
|
cornerRadiusDp =
|
|
203
|
-
getFloatOrNull(
|
|
183
|
+
shapeParams.getFloatOrNull(PaymentSheetAppearanceKeys.BORDER_RADIUS),
|
|
204
184
|
borderStrokeWidthDp =
|
|
205
|
-
getFloatOrNull(
|
|
206
|
-
heightDp = getFloatOrNull(
|
|
185
|
+
shapeParams.getFloatOrNull(PaymentSheetAppearanceKeys.BORDER_WIDTH),
|
|
186
|
+
heightDp = shapeParams.getFloatOrNull(PaymentSheetAppearanceKeys.HEIGHT),
|
|
207
187
|
),
|
|
208
188
|
typography =
|
|
209
189
|
PaymentSheet.PrimaryButtonTypography(
|
|
210
190
|
fontResId =
|
|
211
|
-
getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY,
|
|
191
|
+
getFontResId(fontParams, PaymentSheetAppearanceKeys.FAMILY, context),
|
|
212
192
|
),
|
|
213
193
|
)
|
|
214
194
|
}
|
|
215
195
|
|
|
196
|
+
@SuppressLint("RestrictedApi")
|
|
216
197
|
@Throws(PaymentSheetAppearanceException::class)
|
|
217
198
|
private fun buildPrimaryButtonColors(
|
|
218
|
-
|
|
219
|
-
|
|
199
|
+
isLightMode: Boolean,
|
|
200
|
+
colorParams: ReadableMap,
|
|
220
201
|
context: Context,
|
|
221
|
-
): PaymentSheet.PrimaryButtonColors
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
),
|
|
261
|
-
)
|
|
202
|
+
): PaymentSheet.PrimaryButtonColors.Builder {
|
|
203
|
+
val builder =
|
|
204
|
+
if (isLightMode) {
|
|
205
|
+
PaymentSheet.PrimaryButtonColors.Builder.light()
|
|
206
|
+
} else {
|
|
207
|
+
PaymentSheet.PrimaryButtonColors.Builder.dark()
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// TODO: Why is background a string but successBackgroundColor a "dynamic" color?
|
|
211
|
+
// https://stripe.dev/stripe-react-native/api-reference/types/PaymentSheet.PrimaryButtonColorConfig.html
|
|
212
|
+
colorFromHex(colorParams.getString(PaymentSheetAppearanceKeys.BACKGROUND))?.let {
|
|
213
|
+
builder.background(it)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
colorFromHex(colorParams.getString(PaymentSheetAppearanceKeys.TEXT))?.let {
|
|
217
|
+
builder.onBackground(it)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
colorFromHex(colorParams.getString(PaymentSheetAppearanceKeys.BORDER))?.let {
|
|
221
|
+
builder.border(it)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
dynamicColorFromParams(
|
|
225
|
+
context,
|
|
226
|
+
colorParams,
|
|
227
|
+
PaymentSheetAppearanceKeys.SUCCESS_BACKGROUND,
|
|
228
|
+
)?.let {
|
|
229
|
+
builder.successBackgroundColor(it)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
dynamicColorFromParams(
|
|
233
|
+
context,
|
|
234
|
+
colorParams,
|
|
235
|
+
PaymentSheetAppearanceKeys.SUCCESS_TEXT,
|
|
236
|
+
)?.let {
|
|
237
|
+
builder.onSuccessBackgroundColor(it)
|
|
238
|
+
}
|
|
239
|
+
return builder
|
|
240
|
+
}
|
|
262
241
|
|
|
263
242
|
@SuppressLint("RestrictedApi")
|
|
264
243
|
@Throws(PaymentSheetAppearanceException::class)
|
|
265
244
|
private fun buildEmbeddedAppearance(
|
|
266
|
-
embeddedParams:
|
|
267
|
-
defaultColorsBundle: Bundle?,
|
|
245
|
+
embeddedParams: ReadableMap?,
|
|
268
246
|
context: Context,
|
|
269
|
-
): PaymentSheet.Appearance.Embedded
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
247
|
+
): PaymentSheet.Appearance.Embedded {
|
|
248
|
+
val embeddedBuilder = PaymentSheet.Appearance.Embedded.Builder()
|
|
249
|
+
val rowParams = embeddedParams?.getMap(PaymentSheetAppearanceKeys.ROW)
|
|
250
|
+
val styleString = rowParams?.getString(PaymentSheetAppearanceKeys.STYLE)
|
|
251
|
+
when (styleString) {
|
|
252
|
+
"flatWithRadio" -> {
|
|
253
|
+
val flatParams = rowParams.getMap(PaymentSheetAppearanceKeys.FLAT)
|
|
254
|
+
val radioParams = flatParams?.getMap(PaymentSheetAppearanceKeys.RADIO)
|
|
255
|
+
val separatorInsetsParams =
|
|
256
|
+
flatParams?.getMap(PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
257
|
+
|
|
258
|
+
val flatRadioLightColorsBuilder =
|
|
259
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio.Colors
|
|
260
|
+
.Builder
|
|
261
|
+
.light()
|
|
262
|
+
|
|
263
|
+
val flatRadioDarkColorsBuilder =
|
|
264
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio.Colors
|
|
265
|
+
.Builder
|
|
266
|
+
.dark()
|
|
267
|
+
|
|
268
|
+
dynamicColorFromParams(
|
|
269
|
+
context,
|
|
270
|
+
flatParams,
|
|
271
|
+
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
272
|
+
)?.let {
|
|
273
|
+
flatRadioLightColorsBuilder.separatorColor(it)
|
|
274
|
+
flatRadioDarkColorsBuilder.separatorColor(it)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
dynamicColorFromParams(
|
|
278
|
+
context,
|
|
279
|
+
radioParams,
|
|
280
|
+
PaymentSheetAppearanceKeys.SELECTED_COLOR,
|
|
281
|
+
)?.let {
|
|
282
|
+
flatRadioLightColorsBuilder.selectedColor(it)
|
|
283
|
+
flatRadioDarkColorsBuilder.selectedColor(it)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
dynamicColorFromParams(
|
|
287
|
+
context,
|
|
288
|
+
radioParams,
|
|
289
|
+
PaymentSheetAppearanceKeys.UNSELECTED_COLOR,
|
|
290
|
+
)?.let {
|
|
291
|
+
flatRadioLightColorsBuilder.unselectedColor(it)
|
|
292
|
+
flatRadioDarkColorsBuilder.unselectedColor(it)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
val rowStyleBuilder =
|
|
296
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio
|
|
297
|
+
.Builder()
|
|
298
|
+
|
|
299
|
+
flatParams.getFloatOrNull(PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS)?.let {
|
|
300
|
+
rowStyleBuilder.separatorThicknessDp(it)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
separatorInsetsParams.getFloatOrNull(PaymentSheetAppearanceKeys.LEFT)?.let {
|
|
304
|
+
rowStyleBuilder.startSeparatorInsetDp(it)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
separatorInsetsParams.getFloatOrNull(PaymentSheetAppearanceKeys.RIGHT)?.let {
|
|
308
|
+
rowStyleBuilder.endSeparatorInsetDp(it)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
flatParams.getBooleanOrNull(PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED)?.let {
|
|
312
|
+
rowStyleBuilder.topSeparatorEnabled(it)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
flatParams.getBooleanOrNull(PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED)?.let {
|
|
316
|
+
rowStyleBuilder.bottomSeparatorEnabled(it)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
rowParams.getFloatOrNull(PaymentSheetAppearanceKeys.ADDITIONAL_INSETS)?.let {
|
|
320
|
+
rowStyleBuilder.additionalVerticalInsetsDp(it)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
rowStyleBuilder.colorsLight(flatRadioLightColorsBuilder.build())
|
|
324
|
+
rowStyleBuilder.colorsDark(flatRadioDarkColorsBuilder.build())
|
|
325
|
+
|
|
326
|
+
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
"flatWithCheckmark" -> {
|
|
330
|
+
val flatParams = rowParams.getMap(PaymentSheetAppearanceKeys.FLAT)
|
|
331
|
+
val checkmarkParams = flatParams?.getMap(PaymentSheetAppearanceKeys.CHECKMARK)
|
|
332
|
+
val separatorInsetsParams =
|
|
333
|
+
flatParams?.getMap(PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
334
|
+
|
|
335
|
+
val flatCheckmarkLightColorsBuilder =
|
|
336
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark.Colors
|
|
337
|
+
.Builder
|
|
338
|
+
.light()
|
|
339
|
+
val flatCheckmarkDarkColorsBuilder =
|
|
340
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark.Colors
|
|
341
|
+
.Builder
|
|
342
|
+
.dark()
|
|
343
|
+
|
|
344
|
+
dynamicColorFromParams(
|
|
345
|
+
context,
|
|
346
|
+
flatParams,
|
|
347
|
+
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
348
|
+
)?.let {
|
|
349
|
+
flatCheckmarkLightColorsBuilder.separatorColor(it)
|
|
350
|
+
flatCheckmarkDarkColorsBuilder.separatorColor(it)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
dynamicColorFromParams(context, checkmarkParams, PaymentSheetAppearanceKeys.COLOR)?.let {
|
|
354
|
+
flatCheckmarkLightColorsBuilder.checkmarkColor(it)
|
|
355
|
+
flatCheckmarkDarkColorsBuilder.checkmarkColor(it)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
val rowStyleBuilder =
|
|
359
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark
|
|
360
|
+
.Builder()
|
|
361
|
+
|
|
362
|
+
flatParams.getFloatOrNull(PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS)?.let {
|
|
363
|
+
rowStyleBuilder.separatorThicknessDp(it)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
separatorInsetsParams.getFloatOrNull(PaymentSheetAppearanceKeys.LEFT)?.let {
|
|
367
|
+
rowStyleBuilder.startSeparatorInsetDp(it)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
separatorInsetsParams.getFloatOrNull(PaymentSheetAppearanceKeys.RIGHT)?.let {
|
|
371
|
+
rowStyleBuilder.endSeparatorInsetDp(it)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
flatParams.getBooleanOrNull(PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED)?.let {
|
|
375
|
+
rowStyleBuilder.topSeparatorEnabled(it)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
flatParams.getBooleanOrNull(PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED)?.let {
|
|
379
|
+
rowStyleBuilder.bottomSeparatorEnabled(it)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
checkmarkParams.getFloatOrNull(PaymentSheetAppearanceKeys.CHECKMARK_INSET)?.let {
|
|
383
|
+
rowStyleBuilder.checkmarkInsetDp(it)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
rowParams.getFloatOrNull(PaymentSheetAppearanceKeys.ADDITIONAL_INSETS)?.let {
|
|
387
|
+
rowStyleBuilder.additionalVerticalInsetsDp(it)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// TODO: The theme is so crazy long, why does each Color thing has the same redundant Theme...
|
|
391
|
+
rowStyleBuilder.colorsLight(flatCheckmarkLightColorsBuilder.build())
|
|
392
|
+
rowStyleBuilder.colorsDark(flatCheckmarkDarkColorsBuilder.build())
|
|
393
|
+
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
"flatWithDisclosure" -> {
|
|
397
|
+
val flatParams = rowParams.getMap(PaymentSheetAppearanceKeys.FLAT)
|
|
398
|
+
val disclosureParams = flatParams?.getMap(PaymentSheetAppearanceKeys.DISCLOSURE)
|
|
399
|
+
val separatorInsetsParams =
|
|
400
|
+
flatParams?.getMap(PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
401
|
+
|
|
402
|
+
val flatDisclosureLightColorsBuilder =
|
|
403
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure.Colors
|
|
404
|
+
.Builder
|
|
405
|
+
.light()
|
|
406
|
+
val flatDisclosureDarkColorsBuilder =
|
|
407
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure.Colors
|
|
408
|
+
.Builder
|
|
409
|
+
.dark()
|
|
273
410
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
val styleString = rowParams.getString(PaymentSheetAppearanceKeys.STYLE, "flatWithRadio")
|
|
282
|
-
|
|
283
|
-
val defaultAdditionalInsetsDp = 6.0f
|
|
284
|
-
val defaultSeparatorThicknessDp = 1.0f
|
|
285
|
-
val defaultSpacingDp = 12.0f
|
|
286
|
-
val defaultCheckmarkInsetDp = 0f
|
|
287
|
-
|
|
288
|
-
val additionalInsets = getFloatOr(rowParams, PaymentSheetAppearanceKeys.ADDITIONAL_INSETS, defaultAdditionalInsetsDp)
|
|
289
|
-
|
|
290
|
-
val rowStyle: PaymentSheet.Appearance.Embedded.RowStyle =
|
|
291
|
-
when (styleString) {
|
|
292
|
-
"flatWithRadio" -> {
|
|
293
|
-
val flatParams = getBundleOrNull(rowParams, PaymentSheetAppearanceKeys.FLAT)
|
|
294
|
-
val radioParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.RADIO)
|
|
295
|
-
val separatorInsetsParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
296
|
-
|
|
297
|
-
// Default separator insets specific to FlatWithRadio
|
|
298
|
-
val defaultSeparatorStartInsetDp = 30.0f
|
|
299
|
-
val defaultSeparatorEndInsetDp = 0.0f
|
|
300
|
-
|
|
301
|
-
// Parse dimensions as Floats
|
|
302
|
-
val separatorThickness = getFloatOr(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS, defaultSeparatorThicknessDp)
|
|
303
|
-
val startSeparatorInset = getFloatOr(separatorInsetsParams, PaymentSheetAppearanceKeys.LEFT, defaultSeparatorStartInsetDp)
|
|
304
|
-
val endSeparatorInset = getFloatOr(separatorInsetsParams, PaymentSheetAppearanceKeys.RIGHT, defaultSeparatorEndInsetDp)
|
|
305
|
-
|
|
306
|
-
// Parse booleans
|
|
307
|
-
val topEnabled = getBooleanOr(flatParams, PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED, true)
|
|
308
|
-
val bottomEnabled = getBooleanOr(flatParams, PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED, true)
|
|
309
|
-
|
|
310
|
-
// Parse individual colors using default colors
|
|
311
|
-
val parsedSeparatorColor =
|
|
312
|
-
dynamicColorFromParams(
|
|
313
|
-
context,
|
|
314
|
-
flatParams,
|
|
315
|
-
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
316
|
-
defaultColors.componentBorder,
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
val parsedSelectedColor =
|
|
320
|
-
dynamicColorFromParams(
|
|
321
|
-
context,
|
|
322
|
-
radioParams,
|
|
323
|
-
PaymentSheetAppearanceKeys.SELECTED_COLOR,
|
|
324
|
-
defaultColors.primary,
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
val parsedUnselectedColor =
|
|
328
|
-
dynamicColorFromParams(
|
|
329
|
-
context,
|
|
330
|
-
radioParams,
|
|
331
|
-
PaymentSheetAppearanceKeys.UNSELECTED_COLOR,
|
|
332
|
-
defaultColors.componentBorder,
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
val flatRadioColors =
|
|
336
|
-
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio.Colors(
|
|
337
|
-
separatorColor = parsedSeparatorColor,
|
|
338
|
-
unselectedColor = parsedUnselectedColor,
|
|
339
|
-
selectedColor = parsedSelectedColor,
|
|
340
|
-
)
|
|
341
|
-
|
|
342
|
-
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithRadio(
|
|
343
|
-
separatorThicknessDp = separatorThickness,
|
|
344
|
-
startSeparatorInsetDp = startSeparatorInset,
|
|
345
|
-
endSeparatorInsetDp = endSeparatorInset,
|
|
346
|
-
topSeparatorEnabled = topEnabled,
|
|
347
|
-
bottomSeparatorEnabled = bottomEnabled,
|
|
348
|
-
additionalVerticalInsetsDp = additionalInsets,
|
|
349
|
-
horizontalInsetsDp = 0.0F, // We do not have an iOS equal for this API so it's not configurable in React Native
|
|
350
|
-
colorsLight = flatRadioColors,
|
|
351
|
-
colorsDark = flatRadioColors,
|
|
352
|
-
)
|
|
411
|
+
dynamicColorFromParams(
|
|
412
|
+
context,
|
|
413
|
+
flatParams,
|
|
414
|
+
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
415
|
+
)?.let {
|
|
416
|
+
flatDisclosureLightColorsBuilder.separatorColor(it)
|
|
417
|
+
flatDisclosureDarkColorsBuilder.separatorColor(it)
|
|
353
418
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// Default separator insets specific to FlatWithCheckmark and FlatWithDisclosure
|
|
360
|
-
val defaultSeparatorStartInsetDp = 0.0f
|
|
361
|
-
val defaultSeparatorEndInsetDp = 0.0f
|
|
362
|
-
|
|
363
|
-
// Parse dimensions as Floats
|
|
364
|
-
val separatorThickness = getFloatOr(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS, defaultSeparatorThicknessDp)
|
|
365
|
-
val startSeparatorInset = getFloatOr(separatorInsetsParams, PaymentSheetAppearanceKeys.LEFT, defaultSeparatorStartInsetDp)
|
|
366
|
-
val endSeparatorInset = getFloatOr(separatorInsetsParams, PaymentSheetAppearanceKeys.RIGHT, defaultSeparatorEndInsetDp)
|
|
367
|
-
val checkmarkInset = getFloatOr(checkmarkParams, PaymentSheetAppearanceKeys.CHECKMARK_INSET, defaultCheckmarkInsetDp)
|
|
368
|
-
|
|
369
|
-
// Parse booleans
|
|
370
|
-
val topEnabled = getBooleanOr(flatParams, PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED, true)
|
|
371
|
-
val bottomEnabled = getBooleanOr(flatParams, PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED, true)
|
|
372
|
-
|
|
373
|
-
// Parse individual colors using root defaults
|
|
374
|
-
val parsedSeparatorColor =
|
|
375
|
-
dynamicColorFromParams(
|
|
376
|
-
context,
|
|
377
|
-
flatParams,
|
|
378
|
-
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
379
|
-
defaultColors.componentBorder,
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
val parsedCheckmarkColor =
|
|
383
|
-
dynamicColorFromParams(
|
|
384
|
-
context,
|
|
385
|
-
checkmarkParams,
|
|
386
|
-
PaymentSheetAppearanceKeys.COLOR,
|
|
387
|
-
defaultColors.primary,
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
// Create the required Colors object
|
|
391
|
-
val flatCheckmarkColors =
|
|
392
|
-
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark.Colors(
|
|
393
|
-
separatorColor = parsedSeparatorColor,
|
|
394
|
-
checkmarkColor = parsedCheckmarkColor,
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithCheckmark(
|
|
398
|
-
separatorThicknessDp = separatorThickness,
|
|
399
|
-
startSeparatorInsetDp = startSeparatorInset,
|
|
400
|
-
endSeparatorInsetDp = endSeparatorInset,
|
|
401
|
-
topSeparatorEnabled = topEnabled,
|
|
402
|
-
bottomSeparatorEnabled = bottomEnabled,
|
|
403
|
-
checkmarkInsetDp = checkmarkInset,
|
|
404
|
-
additionalVerticalInsetsDp = additionalInsets,
|
|
405
|
-
horizontalInsetsDp = 0.0F, // We do not have an iOS equal for this API so it's not configurable in React Native
|
|
406
|
-
colorsLight = flatCheckmarkColors,
|
|
407
|
-
colorsDark = flatCheckmarkColors,
|
|
408
|
-
)
|
|
419
|
+
|
|
420
|
+
dynamicColorFromParams(context, disclosureParams, PaymentSheetAppearanceKeys.COLOR)?.let {
|
|
421
|
+
flatDisclosureLightColorsBuilder.disclosureColor(it)
|
|
422
|
+
flatDisclosureDarkColorsBuilder.disclosureColor(it)
|
|
409
423
|
}
|
|
410
|
-
"flatWithDisclosure" -> {
|
|
411
|
-
val flatParams = getBundleOrNull(rowParams, PaymentSheetAppearanceKeys.FLAT)
|
|
412
|
-
val disclosureParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.DISCLOSURE)
|
|
413
|
-
val separatorInsetsParams = getBundleOrNull(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_INSETS)
|
|
414
|
-
|
|
415
|
-
// Default separator insets specific to FlatWithCheckmark and FlatWithDisclosure
|
|
416
|
-
val defaultSeparatorStartInsetDp = 0.0f
|
|
417
|
-
val defaultSeparatorEndInsetDp = 0.0f
|
|
418
|
-
|
|
419
|
-
// Parse dimensions as Floats
|
|
420
|
-
val separatorThickness = getFloatOr(flatParams, PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS, defaultSeparatorThicknessDp)
|
|
421
|
-
val startSeparatorInset = getFloatOr(separatorInsetsParams, PaymentSheetAppearanceKeys.LEFT, defaultSeparatorStartInsetDp)
|
|
422
|
-
val endSeparatorInset = getFloatOr(separatorInsetsParams, PaymentSheetAppearanceKeys.RIGHT, defaultSeparatorEndInsetDp)
|
|
423
|
-
|
|
424
|
-
// Parse booleans
|
|
425
|
-
val topEnabled = getBooleanOr(flatParams, PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED, true)
|
|
426
|
-
val bottomEnabled = getBooleanOr(flatParams, PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED, true)
|
|
427
|
-
|
|
428
|
-
val parsedSeparatorColor =
|
|
429
|
-
dynamicColorFromParams(
|
|
430
|
-
context,
|
|
431
|
-
flatParams,
|
|
432
|
-
PaymentSheetAppearanceKeys.SEPARATOR_COLOR,
|
|
433
|
-
Color.GRAY,
|
|
434
|
-
)
|
|
435
|
-
|
|
436
|
-
val parsedDisclosureColor =
|
|
437
|
-
dynamicColorFromParams(
|
|
438
|
-
context,
|
|
439
|
-
disclosureParams,
|
|
440
|
-
PaymentSheetAppearanceKeys.COLOR,
|
|
441
|
-
defaultColors.componentBorder, // Default to component border color like other elements
|
|
442
|
-
)
|
|
443
|
-
|
|
444
|
-
// Create the required Colors object
|
|
445
|
-
val flatDisclosureColors =
|
|
446
|
-
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure.Colors(
|
|
447
|
-
separatorColor = parsedSeparatorColor,
|
|
448
|
-
disclosureColor = parsedDisclosureColor,
|
|
449
|
-
)
|
|
450
424
|
|
|
425
|
+
val rowStyleBuilder =
|
|
451
426
|
PaymentSheet.Appearance.Embedded.RowStyle.FlatWithDisclosure
|
|
452
427
|
.Builder()
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
.topSeparatorEnabled(topEnabled)
|
|
457
|
-
.bottomSeparatorEnabled(bottomEnabled)
|
|
458
|
-
.additionalVerticalInsetsDp(additionalInsets)
|
|
459
|
-
.horizontalInsetsDp(0.0F) // We do not have an iOS equal for this API so it's not configurable in React Native
|
|
460
|
-
.colorsLight(flatDisclosureColors)
|
|
461
|
-
.colorsDark(flatDisclosureColors)
|
|
462
|
-
.build()
|
|
428
|
+
|
|
429
|
+
flatParams.getFloatOrNull(PaymentSheetAppearanceKeys.SEPARATOR_THICKNESS)?.let {
|
|
430
|
+
rowStyleBuilder.separatorThicknessDp(it)
|
|
463
431
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
additionalInsetsDp = additionalInsets,
|
|
468
|
-
spacingDp = getFloatOr(floatingParams, PaymentSheetAppearanceKeys.SPACING, defaultSpacingDp),
|
|
469
|
-
)
|
|
432
|
+
|
|
433
|
+
separatorInsetsParams.getFloatOrNull(PaymentSheetAppearanceKeys.LEFT)?.let {
|
|
434
|
+
rowStyleBuilder.startSeparatorInsetDp(it)
|
|
470
435
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
436
|
+
|
|
437
|
+
separatorInsetsParams.getFloatOrNull(PaymentSheetAppearanceKeys.RIGHT)?.let {
|
|
438
|
+
rowStyleBuilder.endSeparatorInsetDp(it)
|
|
474
439
|
}
|
|
440
|
+
|
|
441
|
+
flatParams.getBooleanOrNull(PaymentSheetAppearanceKeys.TOP_SEPARATOR_ENABLED)?.let {
|
|
442
|
+
rowStyleBuilder.topSeparatorEnabled(it)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
flatParams.getBooleanOrNull(PaymentSheetAppearanceKeys.BOTTOM_SEPARATOR_ENABLED)?.let {
|
|
446
|
+
rowStyleBuilder.bottomSeparatorEnabled(it)
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
rowParams.getFloatOrNull(PaymentSheetAppearanceKeys.ADDITIONAL_INSETS)?.let {
|
|
450
|
+
rowStyleBuilder.additionalVerticalInsetsDp(it)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
rowStyleBuilder.colorsLight(flatDisclosureLightColorsBuilder.build())
|
|
454
|
+
rowStyleBuilder.colorsDark(flatDisclosureDarkColorsBuilder.build())
|
|
455
|
+
|
|
456
|
+
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
"floatingButton" -> {
|
|
460
|
+
val floatingParams = rowParams.getMap(PaymentSheetAppearanceKeys.FLOATING)
|
|
461
|
+
val rowStyleBuilder =
|
|
462
|
+
PaymentSheet.Appearance.Embedded.RowStyle.FloatingButton
|
|
463
|
+
.Builder()
|
|
464
|
+
|
|
465
|
+
rowParams.getFloatOrNull(PaymentSheetAppearanceKeys.ADDITIONAL_INSETS)?.let {
|
|
466
|
+
rowStyleBuilder.additionalInsetsDp(it)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
floatingParams.getFloatOrNull(PaymentSheetAppearanceKeys.SPACING)?.let {
|
|
470
|
+
rowStyleBuilder.spacingDp(it)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
embeddedBuilder.rowStyle(rowStyleBuilder.build())
|
|
475
474
|
}
|
|
476
475
|
|
|
477
|
-
|
|
476
|
+
else -> {
|
|
477
|
+
System.err.println("WARN: Unsupported embedded payment element row style received: $styleString. Falling back to default.")
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return embeddedBuilder.build()
|
|
478
481
|
}
|
|
479
482
|
|
|
480
483
|
@SuppressLint("RestrictedApi")
|
|
481
|
-
private fun buildFormInsets(insetParams:
|
|
484
|
+
private fun buildFormInsets(insetParams: ReadableMap?): PaymentSheet.Insets {
|
|
482
485
|
val defaults = StripeThemeDefaults.formInsets
|
|
483
|
-
val left = getFloatOr(
|
|
484
|
-
val top = getFloatOr(
|
|
485
|
-
val right = getFloatOr(
|
|
486
|
-
val bottom = getFloatOr(
|
|
486
|
+
val left = insetParams.getFloatOr(PaymentSheetAppearanceKeys.LEFT, defaults.start)
|
|
487
|
+
val top = insetParams.getFloatOr(PaymentSheetAppearanceKeys.TOP, defaults.top)
|
|
488
|
+
val right = insetParams.getFloatOr(PaymentSheetAppearanceKeys.RIGHT, defaults.end)
|
|
489
|
+
val bottom = insetParams.getFloatOr(PaymentSheetAppearanceKeys.BOTTOM, defaults.bottom)
|
|
487
490
|
|
|
488
491
|
return PaymentSheet.Insets(
|
|
489
492
|
startDp = left,
|
|
@@ -498,21 +501,20 @@ private fun buildFormInsets(insetParams: Bundle?): PaymentSheet.Insets {
|
|
|
498
501
|
* - Single hex string: "#RRGGBB"
|
|
499
502
|
* - Light/dark object: { "light": "#RRGGBB", "dark": "#RRGGBB" }
|
|
500
503
|
* For light/dark objects, chooses the appropriate color based on current UI mode.
|
|
501
|
-
*
|
|
504
|
+
* Returns null if no color is provided.
|
|
502
505
|
*/
|
|
503
506
|
private fun dynamicColorFromParams(
|
|
504
507
|
context: Context,
|
|
505
|
-
params:
|
|
508
|
+
params: ReadableMap?,
|
|
506
509
|
key: String,
|
|
507
|
-
|
|
508
|
-
): Int {
|
|
510
|
+
): Int? {
|
|
509
511
|
if (params == null) {
|
|
510
|
-
return
|
|
512
|
+
return null
|
|
511
513
|
}
|
|
512
514
|
|
|
513
|
-
// First check if it's a nested
|
|
514
|
-
|
|
515
|
-
|
|
515
|
+
// First check if it's a nested map { "light": "#RRGGBB", "dark": "#RRGGBB" }
|
|
516
|
+
if (params.hasKey(key) && params.getType(key) == ReadableType.Map) {
|
|
517
|
+
val colorMap = params.getMap(key)
|
|
516
518
|
val isDark =
|
|
517
519
|
(
|
|
518
520
|
context.resources.configuration.uiMode
|
|
@@ -522,108 +524,31 @@ private fun dynamicColorFromParams(
|
|
|
522
524
|
// Pick the hex for current mode, or null
|
|
523
525
|
val hex =
|
|
524
526
|
if (isDark) {
|
|
525
|
-
|
|
527
|
+
colorMap?.getString(PaymentSheetAppearanceKeys.DARK)
|
|
526
528
|
} else {
|
|
527
|
-
|
|
529
|
+
colorMap?.getString(PaymentSheetAppearanceKeys.LIGHT)
|
|
528
530
|
}
|
|
529
531
|
|
|
530
|
-
return
|
|
532
|
+
return colorFromHex(hex)
|
|
531
533
|
}
|
|
532
534
|
|
|
533
535
|
// Check if it's a single color string
|
|
534
|
-
params.getString(key)
|
|
535
|
-
return colorFromHexOrDefault(colorString, defaultColor)
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// no override → just use default
|
|
539
|
-
return defaultColor
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
private fun getDoubleOrNull(
|
|
543
|
-
bundle: Bundle?,
|
|
544
|
-
key: String,
|
|
545
|
-
): Double? {
|
|
546
|
-
if (bundle?.containsKey(key) == true) {
|
|
547
|
-
val valueOfUnknownType = bundle.get(key)
|
|
548
|
-
if (valueOfUnknownType is Double) {
|
|
549
|
-
return valueOfUnknownType
|
|
550
|
-
} else if (valueOfUnknownType is Int) {
|
|
551
|
-
return valueOfUnknownType.toDouble()
|
|
552
|
-
} else if (valueOfUnknownType is Float) {
|
|
553
|
-
return valueOfUnknownType.toDouble()
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return null
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
private fun getFloatOr(
|
|
561
|
-
bundle: Bundle?,
|
|
562
|
-
key: String,
|
|
563
|
-
defaultValue: Float,
|
|
564
|
-
): Float {
|
|
565
|
-
if (bundle?.containsKey(key) == true) {
|
|
566
|
-
val valueOfUnknownType = bundle.get(key)
|
|
567
|
-
if (valueOfUnknownType is Float) {
|
|
568
|
-
return valueOfUnknownType
|
|
569
|
-
} else if (valueOfUnknownType is Int) {
|
|
570
|
-
return valueOfUnknownType.toFloat()
|
|
571
|
-
} else if (valueOfUnknownType is Double) {
|
|
572
|
-
return valueOfUnknownType.toFloat()
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return defaultValue
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
private fun getBundleOrNull(
|
|
580
|
-
bundle: Bundle?,
|
|
581
|
-
key: String,
|
|
582
|
-
): Bundle? = bundle?.getBundle(key)
|
|
583
|
-
|
|
584
|
-
private fun getBooleanOr(
|
|
585
|
-
bundle: Bundle?,
|
|
586
|
-
key: String,
|
|
587
|
-
defaultValue: Boolean,
|
|
588
|
-
): Boolean =
|
|
589
|
-
if (bundle?.containsKey(key) == true) {
|
|
590
|
-
bundle.getBoolean(key)
|
|
591
|
-
} else {
|
|
592
|
-
defaultValue
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
private fun getFloatOrNull(
|
|
596
|
-
bundle: Bundle?,
|
|
597
|
-
key: String,
|
|
598
|
-
): Float? {
|
|
599
|
-
if (bundle?.containsKey(key) == true) {
|
|
600
|
-
val valueOfUnknownType = bundle.get(key)
|
|
601
|
-
if (valueOfUnknownType is Float) {
|
|
602
|
-
return valueOfUnknownType
|
|
603
|
-
} else if (valueOfUnknownType is Int) {
|
|
604
|
-
return valueOfUnknownType.toFloat()
|
|
605
|
-
} else if (valueOfUnknownType is Double) {
|
|
606
|
-
return valueOfUnknownType.toFloat()
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
return null
|
|
536
|
+
return colorFromHex(params.getString(key))
|
|
611
537
|
}
|
|
612
538
|
|
|
613
539
|
@Throws(PaymentSheetAppearanceException::class)
|
|
614
540
|
private fun getFontResId(
|
|
615
|
-
|
|
541
|
+
map: ReadableMap?,
|
|
616
542
|
key: String,
|
|
617
|
-
defaultValue: Int?,
|
|
618
543
|
context: Context,
|
|
619
544
|
): Int? {
|
|
620
545
|
val fontErrorPrefix = "Encountered an error when setting a custom font:"
|
|
621
|
-
if (
|
|
622
|
-
return
|
|
546
|
+
if (map?.hasKey(key) != true) {
|
|
547
|
+
return null
|
|
623
548
|
}
|
|
624
549
|
|
|
625
550
|
val fontFileName =
|
|
626
|
-
|
|
551
|
+
map.getString(key)
|
|
627
552
|
?: throw PaymentSheetAppearanceException(
|
|
628
553
|
"$fontErrorPrefix expected String for font.$key, but received null.",
|
|
629
554
|
)
|
|
@@ -633,6 +558,7 @@ private fun getFontResId(
|
|
|
633
558
|
)
|
|
634
559
|
}
|
|
635
560
|
|
|
561
|
+
@SuppressLint("DiscouragedApi")
|
|
636
562
|
val id = context.resources.getIdentifier(fontFileName, "font", context.packageName)
|
|
637
563
|
if (id == 0) {
|
|
638
564
|
throw PaymentSheetAppearanceException("$fontErrorPrefix Failed to find font: $fontFileName")
|