You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
5.1 KiB
Dart
128 lines
5.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
import 'package:mc_common_app/utils/utils.dart';
|
|
import 'package:mc_common_app/view_models/payment_view_model.dart';
|
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class PaymentMethodsView extends StatelessWidget {
|
|
const PaymentMethodsView({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: "Payment Method",
|
|
profileImageUrl: MyAssets.bnCar,
|
|
isRemoveBackButton: false,
|
|
isDrawerEnabled: false,
|
|
),
|
|
body: Container(
|
|
padding: const EdgeInsets.only(bottom: 10, left: 21, right: 21),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
20.height,
|
|
"Select Payment Method".toText(fontSize: 18, isBold: true),
|
|
15.height,
|
|
Consumer(
|
|
builder: (BuildContext context, PaymentVM paymentVm, Widget? child) {
|
|
return Expanded(
|
|
child: ListView(
|
|
shrinkWrap: true,
|
|
children: [
|
|
PaymentMethodContainer(
|
|
isSelected: paymentVm.selectedPaymentMethod == PaymentMethodsEnum.mada,
|
|
onTap: () => paymentVm.updateSelectedPaymentMethod(PaymentMethodsEnum.mada),
|
|
cardAsset: MyAssets.madaPng),
|
|
PaymentMethodContainer(
|
|
isSelected: paymentVm.selectedPaymentMethod == PaymentMethodsEnum.visa,
|
|
onTap: () => paymentVm.updateSelectedPaymentMethod(PaymentMethodsEnum.visa),
|
|
cardAsset: MyAssets.visaPng),
|
|
PaymentMethodContainer(
|
|
isSelected: paymentVm.selectedPaymentMethod == PaymentMethodsEnum.applePay,
|
|
onTap: () => paymentVm.updateSelectedPaymentMethod(PaymentMethodsEnum.applePay),
|
|
cardAsset: MyAssets.applePayPng),
|
|
PaymentMethodContainer(
|
|
isSelected: paymentVm.selectedPaymentMethod == PaymentMethodsEnum.masterCard,
|
|
onTap: () => paymentVm.updateSelectedPaymentMethod(PaymentMethodsEnum.masterCard),
|
|
cardAsset: MyAssets.mastercardPng),
|
|
PaymentMethodContainer(
|
|
isSelected: paymentVm.selectedPaymentMethod == PaymentMethodsEnum.tamara,
|
|
onTap: () => paymentVm.updateSelectedPaymentMethod(PaymentMethodsEnum.tamara),
|
|
cardAsset: MyAssets.tamaraEngPng),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ShowFillButton(
|
|
maxHeight: 55,
|
|
title: "Continue",
|
|
onPressed: () {
|
|
context.read<PaymentVM>().onContinuePressed(context);
|
|
},
|
|
backgroundColor: MyColors.darkPrimaryColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class PaymentMethodContainer extends StatelessWidget {
|
|
final bool isSelected;
|
|
final String cardAsset;
|
|
final Function() onTap;
|
|
|
|
const PaymentMethodContainer({Key? key, required this.isSelected, required this.cardAsset, required this.onTap}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Container(
|
|
margin: EdgeInsets.symmetric(vertical: 10),
|
|
width: double.infinity,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
color: MyColors.white,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: isSelected ? Colors.green : Colors.transparent, width: isSelected ? 2.0 : 0.0),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: 24,
|
|
height: 24,
|
|
decoration: Utils.containerColorRadiusBorderWidth(isSelected ? MyColors.primaryColor : Colors.transparent, 100, Colors.grey, 0.5),
|
|
),
|
|
12.width,
|
|
Container(
|
|
height: 80.0,
|
|
width: 80.0,
|
|
padding: EdgeInsets.all(7.0),
|
|
child: Image.asset(cardAsset),
|
|
),
|
|
Utils.mFlex(1),
|
|
isSelected ? Utils.statusContainerChip(text: "Selected", padding: EdgeInsets.symmetric(vertical: 6, horizontal: 10)) : SizedBox(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|