This commit is contained in:
Hamza-Ayed
2023-12-03 10:35:27 +03:00
parent e095cf564a
commit 2501292424
50 changed files with 1841 additions and 730 deletions

View File

@@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:ride/constant/box_name.dart';
import 'package:ride/controller/functions/secure_storage.dart';
import 'package:ride/controller/home/payment/credit_card_controller.dart';
import 'package:ride/main.dart';
import 'package:ride/views/widgets/elevated_btn.dart';
import '../../../constant/colors.dart';
@@ -76,7 +77,7 @@ class PaymentMethodPage extends StatelessWidget {
const SizedBox(
height: 10,
),
const CreditCardWidget(),
const MyCreditCardWidget(),
const Spacer(),
GetBuilder<CreditCardController>(
builder: (controller) => Row(
@@ -115,8 +116,8 @@ class PaymentMethodPage extends StatelessWidget {
}
}
class CreditCardWidget extends StatelessWidget {
const CreditCardWidget({
class MyCreditCardWidget extends StatelessWidget {
const MyCreditCardWidget({
super.key,
});
@@ -125,11 +126,20 @@ class CreditCardWidget extends StatelessWidget {
Get.put(CreditCardController());
return GetBuilder<CreditCardController>(
builder: (controller) => Container(
height: Get.height * .3,
height: Get.height * .35,
width: Get.width * .9,
decoration: const BoxDecoration(
color: AppColor.secondaryColor,
borderRadius: BorderRadius.all(Radius.circular(15)),
gradient: LinearGradient(colors: [
AppColor.secondaryColor,
// AppColor.blueColor,
// AppColor.greenColor,
AppColor.accentColor,
// AppColor.primaryColor,
// AppColor.redColor,
// AppColor.yellowColor
]),
boxShadow: [
BoxShadow(
spreadRadius: 3,
@@ -148,7 +158,7 @@ class CreditCardWidget extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
child: Row(
@@ -156,22 +166,33 @@ class CreditCardWidget extends StatelessWidget {
getCardIcon(controller.cardNumberController
.text), // Dynamic credit card icon
SizedBox(
width: Get.width * .1,
width: Get.width * .03,
),
SizedBox(
width: Get.width * .6,
width: Get.width * .25,
child: Text(
'Card Number',
style: AppStyle.title,
),
),
SizedBox(
width: Get.width * .03,
),
SizedBox(
width: Get.width * .4,
height: 70,
child: TextFormField(
maxLength: 16,
keyboardType: TextInputType.number,
controller: controller.cardNumberController,
style: const TextStyle(
color: AppColor.blueColor,
fontFamily: 'digital-counter-7',
fontWeight: FontWeight.bold),
decoration: const InputDecoration(
helperStyle: TextStyle(
fontFamily: 'digital-counter-7'),
labelText: 'Card Number',
// labelText: 'Card Number',
),
inputFormatters: [DigitObscuringFormatter()],
validator: (value) {
@@ -190,19 +211,30 @@ class CreditCardWidget extends StatelessWidget {
children: [
const Icon(Icons.person),
SizedBox(
width: Get.width * .1,
width: Get.width * .03,
),
SizedBox(
width: Get.width * .6,
width: Get.width * .25,
child: Text(
'Holder Name',
style: AppStyle.title,
),
),
SizedBox(
width: Get.width * .03,
),
SizedBox(
width: Get.width * .3,
child: SizedBox(
height: 50,
// height: 50,
child: TextFormField(
style: AppStyle.title,
keyboardType: TextInputType.text,
// maxLength: 16,
controller: controller.cardHolderNameController,
decoration: const InputDecoration(
labelText: 'Cardholder Name'),
// labelText: 'Cardholder Name',
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter the cardholder name'
@@ -224,28 +256,40 @@ class CreditCardWidget extends StatelessWidget {
children: [
const Icon(Icons.date_range_outlined),
SizedBox(
width: Get.width * .1,
width: Get.width * .03,
),
SizedBox(
width: Get.width * .2,
child: SizedBox(
height: 60,
child: TextFormField(
keyboardType: TextInputType.datetime,
controller:
controller.expiryDateController,
decoration: const InputDecoration(
labelText: 'Expiry Date'),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter the expiry date'
.tr;
}
return null;
},
Column(
children: [
SizedBox(
width: Get.width * .2,
child: Text(
'Expiry Date',
style: AppStyle.subtitle,
),
),
),
)
SizedBox(
width: Get.width * .1,
child: SizedBox(
height: 60,
child: TextFormField(
maxLength: 4,
keyboardType: TextInputType.datetime,
controller:
controller.expiryDateController,
style: AppStyle.title,
decoration: const InputDecoration(),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter the expiry date'
.tr;
}
return null;
},
),
),
)
],
),
],
),
),
@@ -257,50 +301,76 @@ class CreditCardWidget extends StatelessWidget {
SizedBox(
width: Get.width * .021,
),
SizedBox(
width: Get.width * .2,
child: SizedBox(
height: 60,
child: TextFormField(
obscureText: true,
keyboardType: TextInputType.number,
style: const TextStyle(
fontFamily: 'digital-counter-7'),
maxLength: 3,
controller: controller.cvvCodeController,
decoration: const InputDecoration(
labelText: 'CVV Code'),
validator: (value) {
if (value!.isEmpty &&
value.length != 3) {
return 'Please enter the CVV code'.tr;
}
return null;
},
Column(
children: [
SizedBox(
width: Get.width * .2,
child: Text(
'CVV Code',
style: AppStyle.subtitle,
),
),
),
SizedBox(
width: Get.width * .2,
child: SizedBox(
height: 60,
child: TextFormField(
obscureText: true,
keyboardType: TextInputType.number,
style: const TextStyle(
color: AppColor.primaryColor,
fontFamily: 'digital-counter-7'),
maxLength: 3,
controller:
controller.cvvCodeController,
decoration: const InputDecoration(
// labelText: 'CVV Code',
),
validator: (value) {
if (value!.isEmpty &&
value.length != 3) {
return 'Please enter the CVV code'
.tr;
}
return null;
},
),
),
),
],
)
],
),
),
],
),
// MyElevatedButton(
// title: 'Save'.tr,
// onPressed: () {
// if (controller.formKey.currentState!.validate()) {
// final creditCard = CreditCardModel(
// cardNumber: controller.cardNumberController.text,
// cardHolderName:
// controller.cardHolderNameController.text,
// expiryDate: controller.expiryDateController.text,
// cvvCode: controller.cvvCodeController.text,
// );
// // Process the credit card details
// // You can use GetX to handle the logic here
// }
// },
// ),
MyElevatedButton(
title: 'Save'.tr,
onPressed: () {
if (controller.formKey.currentState!.validate()) {
// final creditCard = CreditCardModel(
// cardNumber: controller.cardNumberController.text,
// cardHolderName:
// controller.cardHolderNameController.text,
// expiryDate: controller.expiryDateController.text,
// cvvCode: controller.cvvCodeController.text,
// );
// Process the credit card details
// You can use GetX to handle the logic here
if (controller.formKey.currentState!.validate()) {
SecureStorage().saveData(BoxName.cardNumber,
controller.cardNumberController.text);
SecureStorage().saveData(BoxName.cardHolderName,
controller.cardHolderNameController.text);
SecureStorage().saveData(BoxName.cvvCode,
controller.cvvCodeController.text);
SecureStorage().saveData(BoxName.expiryDate,
controller.expiryDateController.text);
}
}
},
),
],
),
))));