From 31af7fab389e89d218fbca4d2e878987c50e0974 Mon Sep 17 00:00:00 2001 From: Jigar-f Date: Tue, 3 Oct 2023 13:26:53 +0530 Subject: [PATCH] Make Freekassa the default payment in iran --- lib/plans/checkout.dart | 278 +++++++++++++++++++++------------------- pubspec.lock | 46 +++---- 2 files changed, 165 insertions(+), 159 deletions(-) diff --git a/lib/plans/checkout.dart b/lib/plans/checkout.dart index 30b581df2..562a6f3c0 100644 --- a/lib/plans/checkout.dart +++ b/lib/plans/checkout.dart @@ -154,7 +154,7 @@ class _CheckoutState extends State case 'freekassa': widgets.add( PaymentProvider( - logoPaths: [ + logoPaths: const [ ImagePaths.mnp, ImagePaths.qiwi, ImagePaths.visa, @@ -238,150 +238,164 @@ class _CheckoutState extends State @override Widget build(BuildContext context) { return BaseScreen( - resizeToAvoidBottomInset: false, - title: 'lantern_pro_checkout'.i18n, - body: sessionModel.paymentMethods( - builder: ( - context, - Iterable> paymentMethods, - Widget? child, - ) { - return sessionModel.emailAddress(( - BuildContext context, - String emailAddress, - Widget? child, - ) { - return Container( - padding: const EdgeInsetsDirectional.only( - start: 16, - end: 16, - top: 24, - bottom: 32, - ), - child: Column( - children: [ - // * Step 2 - PlanStep( - stepNum: '2', - description: 'enter_email'.i18n, + resizeToAvoidBottomInset: false, + title: 'lantern_pro_checkout'.i18n, + body: sessionModel.countryCode((context, countryCode, child) { + changePaymentCountryWise(countryCode); + return sessionModel.paymentMethods( + builder: ( + context, + Iterable> paymentMethods, + Widget? child, + ) { + return sessionModel.emailAddress(( + BuildContext context, + String emailAddress, + Widget? child, + ) { + return Container( + padding: const EdgeInsetsDirectional.only( + start: 16, + end: 16, + top: 24, + bottom: 32, ), - // * Email field - Container( - padding: const EdgeInsetsDirectional.only( - top: 8, - bottom: 8, - ), - child: Form( - key: emailFieldKey, - child: CTextField( - initialValue: widget.isPro ? emailAddress : '', - controller: emailController, - autovalidateMode: widget.isPro - ? AutovalidateMode.always - : AutovalidateMode.disabled, - label: 'email'.i18n, - keyboardType: TextInputType.emailAddress, - prefixIcon: const CAssetImage(path: ImagePaths.email), + child: Column( + children: [ + // * Step 2 + PlanStep( + stepNum: '2', + description: 'enter_email'.i18n, ), - ), - ), - // * Referral Code field - initially hidden - Visibility( - visible: isRefCodeFieldShowing, - child: Container( - padding: const EdgeInsetsDirectional.only( - top: 8, - bottom: 16, + // * Email field + Container( + padding: const EdgeInsetsDirectional.only( + top: 8, + bottom: 8, + ), + child: Form( + key: emailFieldKey, + child: CTextField( + initialValue: widget.isPro ? emailAddress : '', + controller: emailController, + autovalidateMode: widget.isPro + ? AutovalidateMode.always + : AutovalidateMode.disabled, + label: 'email'.i18n, + keyboardType: TextInputType.emailAddress, + prefixIcon: + const CAssetImage(path: ImagePaths.email), + ), + ), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Flexible( - flex: 2, - child: Form( - key: refCodeFieldKey, - child: CTextField( - controller: refCodeController, - autovalidateMode: AutovalidateMode.disabled, - textCapitalization: - TextCapitalization.characters, - label: 'referral_code'.i18n, - keyboardType: TextInputType.text, - prefixIcon: - const CAssetImage(path: ImagePaths.star), + // * Referral Code field - initially hidden + Visibility( + visible: isRefCodeFieldShowing, + child: Container( + padding: const EdgeInsetsDirectional.only( + top: 8, + bottom: 16, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Flexible( + flex: 2, + child: Form( + key: refCodeFieldKey, + child: CTextField( + controller: refCodeController, + autovalidateMode: AutovalidateMode.disabled, + textCapitalization: + TextCapitalization.characters, + label: 'referral_code'.i18n, + keyboardType: TextInputType.text, + prefixIcon: const CAssetImage( + path: ImagePaths.star), + ), + ), ), + ], + ), + ), + ), + // * Add Referral code + Visibility( + visible: !isRefCodeFieldShowing, + child: GestureDetector( + onTap: () async => + setState(() => isRefCodeFieldShowing = true), + child: Container( + width: MediaQuery.of(context).size.width, + padding: const EdgeInsetsDirectional.only( + top: 8, + bottom: 16, + ), + child: Row( + children: [ + const CAssetImage(path: ImagePaths.add), + Padding( + padding: const EdgeInsetsDirectional.only( + start: 8.0, + ), + child: CText( + 'add_referral_code'.i18n, + style: tsBody1, + ), + ), + ], ), ), - ], + ), ), - ), - ), - // * Add Referral code - Visibility( - visible: !isRefCodeFieldShowing, - child: GestureDetector( - onTap: () async => - setState(() => isRefCodeFieldShowing = true), - child: Container( - width: MediaQuery.of(context).size.width, + // * Step 3 + PlanStep( + stepNum: '3', + description: 'choose_payment_method'.i18n, + ), + //* Payment options + Container( padding: const EdgeInsetsDirectional.only( - top: 8, - bottom: 16, - ), - child: Row( - children: [ - const CAssetImage(path: ImagePaths.add), - Padding( - padding: const EdgeInsetsDirectional.only( - start: 8.0, - ), - child: CText( - 'add_referral_code'.i18n, - style: tsBody1, - ), - ), - ], + top: 16, bottom: 16), + width: MediaQuery.of(context).size.width, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: paymentOptions(paymentMethods), ), ), - ), - ), - // * Step 3 - PlanStep( - stepNum: '3', - description: 'choose_payment_method'.i18n, - ), - //* Payment options - Container( - padding: - const EdgeInsetsDirectional.only(top: 16, bottom: 16), - width: MediaQuery.of(context).size.width, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: paymentOptions(paymentMethods), - ), - ), - // * Price summary, unused pro time disclaimer, Continue button + // * Price summary, unused pro time disclaimer, Continue button - Center( - child: Tooltip( - message: AppKeys.continueCheckout, - child: Button( - text: 'continue'.i18n, - disabled: emailController.value.text.isEmpty || - emailFieldKey.currentState?.validate() == false || - refCodeFieldKey.currentState?.validate() == false, - onPressed: onContinueTapped, + Center( + child: Tooltip( + message: AppKeys.continueCheckout, + child: Button( + text: 'continue'.i18n, + disabled: emailController.value.text.isEmpty || + emailFieldKey.currentState?.validate() == + false || + refCodeFieldKey.currentState?.validate() == + false, + onPressed: onContinueTapped, + ), + ), ), - ), + ], ), - ], - ), - ); - }); - }, - ), - ); + ); + }); + }, + ); + })); + } + + void changePaymentCountryWise(String countryCode){ + if(countryCode == ""){ + return; + } + if(countryCode.toLowerCase()=='ir'){ + selectedPaymentProvider = Providers.freekassa; + } } void onContinueTapped() { diff --git a/pubspec.lock b/pubspec.lock index 3cf74f15a..fb56a78dc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -261,10 +261,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.17.1" convert: dependency: transitive description: @@ -784,10 +784,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.18.0" io: dependency: transitive description: @@ -856,18 +856,18 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.2.0" meta: dependency: transitive description: @@ -1325,10 +1325,10 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.9.1" sprintf: dependency: transitive description: @@ -1429,26 +1429,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "13b41f318e2a5751c3169137103b60c584297353d4b1761b66029bae6411fe46" + sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4" url: "https://pub.dev" source: hosted - version: "1.24.3" + version: "1.24.1" test_api: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.5.1" test_core: dependency: transitive description: name: test_core - sha256: "99806e9e6d95c7b059b7a0fc08f07fc53fabe54a829497f0d9676299f1e8637e" + sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93" url: "https://pub.dev" source: hosted - version: "0.5.3" + version: "0.5.1" timezone: dependency: transitive description: @@ -1637,10 +1637,10 @@ packages: dependency: transitive description: name: vm_service - sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f + sha256: f6deed8ed625c52864792459709183da231ebf66ff0cf09e69b573227c377efe url: "https://pub.dev" source: hosted - version: "11.7.1" + version: "11.3.0" wakelock: dependency: "direct main" description: @@ -1689,14 +1689,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" - web: - dependency: transitive - description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 - url: "https://pub.dev" - source: hosted - version: "0.1.4-beta" web_socket_channel: dependency: transitive description: @@ -1802,5 +1794,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.0.3 <4.0.0" flutter: ">=3.10.0"