Skip to content

Commit

Permalink
Make Freekassa the default payment in iran
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Oct 3, 2023
1 parent 58d04a8 commit 31af7fa
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 159 deletions.
278 changes: 146 additions & 132 deletions lib/plans/checkout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class _CheckoutState extends State<Checkout>
case 'freekassa':
widgets.add(
PaymentProvider(
logoPaths: [
logoPaths: const [
ImagePaths.mnp,
ImagePaths.qiwi,
ImagePaths.visa,
Expand Down Expand Up @@ -238,150 +238,164 @@ class _CheckoutState extends State<Checkout>
@override
Widget build(BuildContext context) {
return BaseScreen(
resizeToAvoidBottomInset: false,
title: 'lantern_pro_checkout'.i18n,
body: sessionModel.paymentMethods(
builder: (
context,
Iterable<PathAndValue<PaymentMethod>> 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<PathAndValue<PaymentMethod>> 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() {
Expand Down
Loading

0 comments on commit 31af7fa

Please sign in to comment.