-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/hosted platform views #67
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/example/lib/main.dart b/example/lib/main.dart index cf7a81b..60e1f30 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -88,11 +88,57 @@ class _MyAppState extends State<MyApp> { MaterialPageRoute( builder: (context) => FirstRoute( repository: _adyenSessionRepository, - )), ); }, - child: const Text("Card component")), + child: const Text("Card component scroll view")), + TextButton( + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + builder: (BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [ + Container(height: 8), + Container( + width: 48, + height: 6, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.grey), + ), + Container(height: 8), + Container( + padding: EdgeInsets.only( + bottom: + MediaQuery.of(context).viewInsets.bottom), + child: FutureBuilder<String>( + future: _adyenSessionRepository + .fetchPaymentMethods(), + builder: (BuildContext context, + AsyncSnapshot<String> snapshot) { + if (snapshot.data == null) { + return const Center( + child: CircularProgressIndicator(), + ); + } else { + return buildCardWidget(snapshot, context, + _adyenSessionRepository); + } + }, + ), + ), + ], + )); + }); + }, + child: const Text("Card component sheet")), ], ), ), diff --git a/example/lib/navigation/routes.dart b/example/lib/navigation/routes.dart index 2f48364..1f7c146 100644 --- a/example/lib/navigation/routes.dart +++ b/example/lib/navigation/routes.dart @@ -29,7 +29,7 @@ class FirstRoute extends StatelessWidget { child: Column( children: [ const FlutterLogo(size: 128), - buildCardWidget(snapshot, context), + buildCardWidget(snapshot, context, repository), Container(height: 50), Container(height: 280, color: Colors.blue), const Text( @@ -43,55 +43,60 @@ class FirstRoute extends StatelessWidget { ), )); } +} - Widget buildCardWidget(AsyncSnapshot<String> snapshot, BuildContext context) { - return AdyenCardWidget( - paymentMethods: snapshot.data!, - clientKey: Config.clientKey, - onSubmit: repository.postPayments, - onResult: (event) async { - _dialogBuilder(context, event); - }, - ); - } - _dialogBuilder(BuildContext context, PaymentResult paymentResult) { - String title = ""; - String message = ""; - switch (paymentResult) { - case PaymentAdvancedFlowFinished(): - title = "Finished"; - message = "Result code: ${paymentResult.resultCode}"; - case PaymentSessionFinished(): - title = "Finished"; - message = "Result code: ${paymentResult.resultCode}"; - case PaymentCancelledByUser(): - title = "Cancelled by user"; - message = "Drop-in cancelled by user"; - case PaymentError(): - title = "Error occurred"; - message = "${paymentResult.reason}"; - } +Widget buildCardWidget( + AsyncSnapshot<String> snapshot, + BuildContext context, + AdyenSessionsRepository repository, +) { + return AdyenCardWidget( + paymentMethods: snapshot.data!, + clientKey: Config.clientKey, + onSubmit: repository.postPayments, + onResult: (event) async { + _dialogBuilder(context, event); + }, + ); +} - return showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text(title), - content: Text(message), - actions: <Widget>[ - TextButton( - style: TextButton.styleFrom( - textStyle: Theme.of(context).textTheme.labelLarge, - ), - child: const Text('Close'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - ); - }, - ); +_dialogBuilder(BuildContext context, PaymentResult paymentResult) { + String title = ""; + String message = ""; + switch (paymentResult) { + case PaymentAdvancedFlowFinished(): + title = "Finished"; + message = "Result code: ${paymentResult.resultCode}"; + case PaymentSessionFinished(): + title = "Finished"; + message = "Result code: ${paymentResult.resultCode}"; + case PaymentCancelledByUser(): + title = "Cancelled by user"; + message = "Drop-in cancelled by user"; + case PaymentError(): + title = "Error occurred"; + message = "${paymentResult.reason}"; } + + return showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(title), + content: Text(message), + actions: <Widget>[ + TextButton( + style: TextButton.styleFrom( + textStyle: Theme.of(context).textTheme.labelLarge, + ), + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); } diff --git a/example/lib/network/models/session_request_network_model.dart b/example/lib/network/models/session_request_network_model.dart index 232e31f..22d6f9f 100644 --- a/example/lib/network/models/session_request_network_model.dart +++ b/example/lib/network/models/session_request_network_model.dart @@ -47,6 +47,29 @@ class SessionRequestNetworkModel { String toRawJson() => json.encode(toJson()); Map<String, dynamic> toJson() { + Map<String, dynamic> installmentOptions = json.decode("""{ + "visa": { + "plans": [ + "regular" + ], + "values": [ + 2, + 4 + ] + }, + "mc": { + "values": [ + 2, + 3, + 5 + ], + "plans": [ + "regular", + "revolving" + ] + } + }"""); + final Map<String, dynamic> data = <String, dynamic>{}; data['merchantAccount'] = merchantAccount; data['amount'] = amount.toJson(); @@ -66,6 +89,7 @@ class SessionRequestNetworkModel { data['deliveryAddress'] = deliveryAddress?.toJson(); data['lineItems'] = lineItems?.map((lineItem) => lineItem.toJson()).toList(); + data['installmentOptions'] = installmentOptions; return data; } } diff --git a/ios/Classes/components/CardComponent.swift b/ios/Classes/components/CardComponent.swift index 9607bd5..703763a 100644 --- a/ios/Classes/components/CardComponent.swift +++ b/ios/Classes/components/CardComponent.swift @@ -79,7 +79,6 @@ class FLNativeView: NSObject, FlutterPlatformView, PaymentComponentDelegate { } func createNativeView(view _view: TestView, args: NSDictionary){ - _view.backgroundColor = UIColor.blue _view.handler = { let height = self.cardComponent?.viewController.preferredContentSize.height @@ -97,6 +96,7 @@ class FLNativeView: NSObject, FlutterPlatformView, PaymentComponentDelegate { self.cardComponent = component let componentViewController = component.viewController + rootViewController = getViewController() rootViewController?.addChild(componentViewController) @@ -104,6 +104,7 @@ class FLNativeView: NSObject, FlutterPlatformView, PaymentComponentDelegate { componentViewController.view.frame = CGRect(x:0.0, y:0.0, width: 0, height:0) (componentViewController.view.subviews[0].subviews[0] as? UIScrollView)?.bounces = false (componentViewController.view.subviews[0].subviews[0] as? UIScrollView)?.isScrollEnabled = false + (componentViewController.view.subviews[0].subviews[0] as? UIScrollView)?.alwaysBounceVertical = false //let formViewController = componentViewController.children[0] @@ -154,8 +155,11 @@ class FLNativeView: NSObject, FlutterPlatformView, PaymentComponentDelegate { throw PlatformError(errorDescription: "error") } + var style = FormComponentStyle() + style.backgroundColor = UIColor.clear let component = CardComponent(paymentMethod: paymentMethod, - context: adyenContext + context: adyenContext, + configuration: .init(style: style) ) component.cardComponentDelegate = self return component diff --git a/ios/Classes/components/TestView.swift b/ios/Classes/components/TestView.swift index 15c5850..f8de610 100644 --- a/ios/Classes/components/TestView.swift +++ b/ios/Classes/components/TestView.swift @@ -25,9 +25,5 @@ class TestView : UIStackView { super.layoutSubviews() handler() - - print("Layout custom view") - print(bounds.height) - print(subviews.first?.systemLayoutSizeFitting(.init(width: bounds.width, height: .greatestFiniteMagnitude))) } } diff --git a/lib/src/components/card_widget.dart b/lib/src/components/card_widget.dart index 65b390a..58c75dc 100644 --- a/lib/src/components/card_widget.dart +++ b/lib/src/components/card_widget.dart @@ -65,15 +65,10 @@ class AdyenCardWidget extends StatelessWidget { builder: (BuildContext context, AsyncSnapshot<double> snapshot) { print("value is: $snapshot"); return SizedBox( - height: snapshot.data ?? 500, + height: (snapshot.data ?? 300) + 40, child: cardView, ); }); - - // return SizedBox( - // height: 500, - // child: cardView, - // ); } Widget buildCardView(String viewType, Map<String, dynamic> creationParams) {
…n for card component
…mViews # Conflicts: # android/src/main/kotlin/com/adyen/adyen_checkout/PlatformApi.kt # ios/Classes/PlatformApi.swift # lib/src/generated/platform_api.g.dart # pigeons/platform_api.dart
… apply correct class naming
Robert-SD
commented
Nov 27, 2023
android/src/main/kotlin/com/adyen/adyen_checkout/PlatformApi.kt
Outdated
Show resolved
Hide resolved
Robert-SD
commented
Nov 27, 2023
Robert-SD
commented
Nov 27, 2023
...Classes/components/card/advancedFlow/delegates/CardAdvancedFlowActionComponentDelegate.swift
Outdated
Show resolved
Hide resolved
Robert-SD
commented
Nov 27, 2023
ios/Classes/components/card/session/delegates/CardSessionFlowDelegate.swift
Outdated
Show resolved
Hide resolved
Robert-SD
commented
Nov 27, 2023
Robert-SD
commented
Nov 27, 2023
descorp
reviewed
Nov 27, 2023
descorp
reviewed
Nov 27, 2023
descorp
reviewed
Nov 27, 2023
jreij
reviewed
Nov 29, 2023
android/src/test/kotlin/com/adyen/adyen_checkout/AdyenCheckoutPluginTest.kt
Outdated
Show resolved
Hide resolved
jreij
reviewed
Nov 29, 2023
...src/main/kotlin/com/adyen/adyen_checkout/components/card/session/CardSessionFlowComponent.kt
Show resolved
Hide resolved
jreij
reviewed
Nov 29, 2023
...in/kotlin/com/adyen/adyen_checkout/components/card/advancedFlow/CardAdvancedFlowComponent.kt
Outdated
Show resolved
Hide resolved
jreij
reviewed
Nov 29, 2023
android/src/main/kotlin/com/adyen/adyen_checkout/components/ComponentMessenger.kt
Outdated
Show resolved
Hide resolved
OscarSpruit
reviewed
Nov 29, 2023
android/src/main/kotlin/com/adyen/adyen_checkout/components/ComponentWrapperView.kt
Show resolved
Hide resolved
android/src/main/kotlin/com/adyen/adyen_checkout/components/card/BaseCardComponent.kt
Outdated
Show resolved
Hide resolved
...in/kotlin/com/adyen/adyen_checkout/components/card/advancedFlow/CardAdvancedFlowComponent.kt
Outdated
Show resolved
Hide resolved
android/src/main/kotlin/com/adyen/adyen_checkout/components/card/BaseCardComponent.kt
Outdated
Show resolved
Hide resolved
...src/main/kotlin/com/adyen/adyen_checkout/components/card/session/CardSessionFlowComponent.kt
Show resolved
Hide resolved
descorp
reviewed
Dec 4, 2023
...Classes/components/card/advancedFlow/delegates/CardAdvancedFlowActionComponentDelegate.swift
Show resolved
Hide resolved
descorp
approved these changes
Dec 4, 2023
OscarSpruit
approved these changes
Dec 5, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Added card component