Skip to content
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 50 commits into from
Dec 5, 2023
Merged

Commits on Oct 23, 2023

  1. Configuration menu
    Copy the full SHA
    a3685af View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9b623ba View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e915c52 View commit details
    Browse the repository at this point in the history
  4. Added bottom sheet example and made ios card component transparent

    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) {
    Robert-SD committed Oct 23, 2023
    Configuration menu
    Copy the full SHA
    7c076c7 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0fa9b2d View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2023

  1. Configuration menu
    Copy the full SHA
    7e7001b View commit details
    Browse the repository at this point in the history
  2. Cleaned redundant code

    Robert-SD committed Oct 24, 2023
    Configuration menu
    Copy the full SHA
    0d35ba1 View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2023

  1. Configuration menu
    Copy the full SHA
    347a7c8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9397d23 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2023

  1. Configuration menu
    Copy the full SHA
    925edb4 View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2023

  1. Improvements for nullsafety

    Robert-SD committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    d5b6015 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d50296a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9f7f741 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9ded7ec View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3f63efa View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    964f819 View commit details
    Browse the repository at this point in the history
  7. Merge branch 'feature/renameDropInOutcome' into feature/hostedPlatfor…

    …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
    Robert-SD committed Oct 30, 2023
    Configuration menu
    Copy the full SHA
    2bc3e3d View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    8839ecd View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2023

  1. Configuration menu
    Copy the full SHA
    425ea7f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cd17cb5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e7e49ad View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    45e2ed9 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Configuration menu
    Copy the full SHA
    1ecae68 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2023

  1. Configuration menu
    Copy the full SHA
    28e36dd View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2023

  1. Configuration menu
    Copy the full SHA
    b426015 View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2023

  1. Configuration menu
    Copy the full SHA
    71e0eeb View commit details
    Browse the repository at this point in the history
  2. Applied code format

    Robert-SD committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    c8afa17 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    af2bd02 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2023

  1. Configuration menu
    Copy the full SHA
    124e868 View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2023

  1. Added base factory

    Robert-SD committed Nov 9, 2023
    Configuration menu
    Copy the full SHA
    4d2c375 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fef8051 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a4bdbdc View commit details
    Browse the repository at this point in the history
  4. Improved code readability

    Robert-SD committed Nov 9, 2023
    Configuration menu
    Copy the full SHA
    f594a16 View commit details
    Browse the repository at this point in the history

Commits on Nov 10, 2023

  1. Configuration menu
    Copy the full SHA
    e8f8b9d View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2023

  1. Improved gesture detection

    Updated to Android SDK 5.0.1
    Added language support for example app
    Robert-SD committed Nov 14, 2023
    Configuration menu
    Copy the full SHA
    234417a View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2023

  1. Improved native view rendering within flutter tree

    Extracted redundant code into a separate widget
    Robert-SD committed Nov 16, 2023
    Configuration menu
    Copy the full SHA
    713c841 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0f08d2a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7774c78 View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2023

  1. Configuration menu
    Copy the full SHA
    4e4d97b View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2023

  1. Configuration menu
    Copy the full SHA
    7fd21fe View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2023

  1. Configuration menu
    Copy the full SHA
    51a0506 View commit details
    Browse the repository at this point in the history
  2. Improved code readability

    Robert-SD committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    f14aa25 View commit details
    Browse the repository at this point in the history
  3. Changed ComponentFlutterAPI to ComponentFlutterInterface in pigeon to…

    … apply correct class naming
    Robert-SD committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    cb276de View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    ca9d11d View commit details
    Browse the repository at this point in the history
  5. Removed dead code

    Robert-SD committed Nov 27, 2023
    Configuration menu
    Copy the full SHA
    185a99a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f11d5d1 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    83f1158 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    287d338 View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2023

  1. Configuration menu
    Copy the full SHA
    863360c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    58af2e9 View commit details
    Browse the repository at this point in the history