INFRA: Set Up Project.
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
import 'package:customer/constant/constant.dart';
|
||||
import 'package:customer/controllers/wallet_controller.dart';
|
||||
import 'package:customer/payment/createRazorPayOrderModel.dart';
|
||||
import 'package:customer/payment/rozorpayConroller.dart';
|
||||
import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart';
|
||||
import 'package:customer/themes/app_them_data.dart';
|
||||
import 'package:customer/themes/round_button_fill.dart';
|
||||
import 'package:customer/themes/text_field_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../controllers/theme_controller.dart';
|
||||
import '../../../themes/show_toast_dialog.dart';
|
||||
|
||||
class PaymentListScreen extends StatelessWidget {
|
||||
const PaymentListScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
final isDark = themeController.isDark.value;
|
||||
return GetX(
|
||||
init: WalletController(),
|
||||
builder: (controller) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface,
|
||||
centerTitle: false,
|
||||
titleSpacing: 0,
|
||||
title: Text("Top up Wallet".tr, style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500)),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TextFieldWidget(
|
||||
title: 'Amount'.tr,
|
||||
hintText: 'Enter Amount'.tr,
|
||||
controller: controller.topUpAmountController.value,
|
||||
textInputType: const TextInputType.numberWithOptions(decimal: true, signed: true),
|
||||
prefix: Padding(padding: const EdgeInsets.all(12.0), child: Text(Constant.currencyModel!.symbol.toString(), style: const TextStyle(fontSize: 20, color: AppThemeData.grey800))),
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]'))],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Text(
|
||||
"Select Top up Options".tr,
|
||||
style: TextStyle(fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(borderRadius: const BorderRadius.all(Radius.circular(20)), color: isDark ? AppThemeData.grey900 : AppThemeData.grey50),
|
||||
child: Column(
|
||||
children: [
|
||||
Visibility(visible: controller.stripeModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.stripe, isDark, "assets/images/stripe.png")),
|
||||
Visibility(visible: controller.payPalModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.paypal, isDark, "assets/images/paypal.png")),
|
||||
Visibility(visible: controller.payStackModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payStack, isDark, "assets/images/paystack.png")),
|
||||
Visibility(
|
||||
visible: controller.mercadoPagoModel.value.isEnabled == true,
|
||||
child: cardDecoration(controller, PaymentGateway.mercadoPago, isDark, "assets/images/mercado-pago.png"),
|
||||
),
|
||||
Visibility(
|
||||
visible: controller.flutterWaveModel.value.isEnable == true,
|
||||
child: cardDecoration(controller, PaymentGateway.flutterWave, isDark, "assets/images/flutterwave_logo.png"),
|
||||
),
|
||||
Visibility(visible: controller.payFastModel.value.isEnable == true, child: cardDecoration(controller, PaymentGateway.payFast, isDark, "assets/images/payfast.png")),
|
||||
Visibility(visible: controller.razorPayModel.value.isEnabled == true, child: cardDecoration(controller, PaymentGateway.razorpay, isDark, "assets/images/razorpay.png")),
|
||||
Visibility(visible: controller.midTransModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.midTrans, isDark, "assets/images/midtrans.png")),
|
||||
Visibility(visible: controller.orangeMoneyModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.orangeMoney, isDark, "assets/images/orange_money.png")),
|
||||
Visibility(visible: controller.xenditModel.value.enable == true, child: cardDecoration(controller, PaymentGateway.xendit, isDark, "assets/images/xendit.png")),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
color: isDark ? AppThemeData.grey900 : AppThemeData.grey50,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: RoundedButtonFill(
|
||||
title: "Top-up".tr,
|
||||
height: 5.5,
|
||||
color: AppThemeData.primary300,
|
||||
textColor: AppThemeData.grey50,
|
||||
fontSizes: 16,
|
||||
onPress: () async {
|
||||
if (controller.topUpAmountController.value.text.isEmpty) {
|
||||
ShowToastDialog.showToast("Please Enter Amount".tr);
|
||||
} else {
|
||||
if (double.parse(controller.topUpAmountController.value.text) >= double.parse(Constant.minimumAmountToDeposit.toString())) {
|
||||
if (controller.selectedPaymentMethod.value == PaymentGateway.stripe.name) {
|
||||
controller.stripeMakePayment(amount: controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.paypal.name) {
|
||||
controller.paypalPaymentSheet(controller.topUpAmountController.value.text, context);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.payStack.name) {
|
||||
controller.payStackPayment(controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.mercadoPago.name) {
|
||||
controller.mercadoPagoMakePayment(context: context, amount: controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.flutterWave.name) {
|
||||
controller.flutterWaveInitiatePayment(context: context, amount: controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.payFast.name) {
|
||||
controller.payFastPayment(context: context, amount: controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.midTrans.name) {
|
||||
controller.midtransMakePayment(context: context, amount: controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.orangeMoney.name) {
|
||||
controller.orangeMakePayment(context: context, amount: controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.xendit.name) {
|
||||
controller.xenditPayment(context, controller.topUpAmountController.value.text);
|
||||
} else if (controller.selectedPaymentMethod.value == PaymentGateway.razorpay.name) {
|
||||
RazorPayController().createOrderRazorPay(amount: double.parse(controller.topUpAmountController.value.text), razorpayModel: controller.razorPayModel.value).then((value) {
|
||||
if (value == null) {
|
||||
Get.back();
|
||||
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr);
|
||||
} else {
|
||||
CreateRazorPayOrderModel result = value;
|
||||
controller.openCheckout(amount: controller.topUpAmountController.value.text, orderId: result.id);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ShowToastDialog.showToast("Please select payment method".tr);
|
||||
}
|
||||
} else {
|
||||
ShowToastDialog.showToast("${'Please Enter minimum amount of'.tr} ${Constant.amountShow(amount: Constant.minimumAmountToDeposit)}");
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Obx cardDecoration(WalletController controller, PaymentGateway value, isDark, String image) {
|
||||
return Obx(
|
||||
() => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
controller.selectedPaymentMethod.value = value.name;
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: ShapeDecoration(shape: RoundedRectangleBorder(side: const BorderSide(width: 1, color: Color(0xFFE5E7EB)), borderRadius: BorderRadius.circular(8))),
|
||||
child: Padding(padding: EdgeInsets.all(value.name == "payFast" ? 0 : 8.0), child: Image.asset(image)),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value.name.capitalizeString(),
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900),
|
||||
),
|
||||
),
|
||||
const Expanded(child: SizedBox()),
|
||||
Radio(
|
||||
value: value.name,
|
||||
groupValue: controller.selectedPaymentMethod.value,
|
||||
activeColor: isDark ? AppThemeData.primary300 : AppThemeData.primary300,
|
||||
onChanged: (value) {
|
||||
controller.selectedPaymentMethod.value = value.toString();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
import 'package:customer/constant/constant.dart';
|
||||
import 'package:customer/controllers/wallet_controller.dart';
|
||||
import 'package:customer/models/wallet_transaction_model.dart';
|
||||
import 'package:customer/screen_ui/multi_vendor_service/wallet_screen/payment_list_screen.dart';
|
||||
import 'package:customer/themes/app_them_data.dart';
|
||||
import 'package:customer/themes/round_button_fill.dart';
|
||||
import '../../../constant/collection_name.dart';
|
||||
import '../../../controllers/theme_controller.dart';
|
||||
import '../../../models/cab_order_model.dart';
|
||||
import '../../../models/onprovider_order_model.dart';
|
||||
import '../../../models/order_model.dart';
|
||||
import '../../../models/parcel_order_model.dart';
|
||||
import '../../../models/rental_order_model.dart';
|
||||
import '../../../service/fire_store_utils.dart';
|
||||
import '../../../themes/show_toast_dialog.dart';
|
||||
import '../../../widget/my_separator.dart';
|
||||
import '../../auth_screens/login_screen.dart';
|
||||
import '../../cab_service_screens/cab_order_details.dart';
|
||||
import '../../on_demand_service/on_demand_order_details_screen.dart';
|
||||
import '../../parcel_service/parcel_order_details.dart';
|
||||
import '../../rental_service/rental_order_details_screen.dart';
|
||||
import '../order_list_screen/order_details_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class WalletScreen extends StatelessWidget {
|
||||
const WalletScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
final isDark = themeController.isDark.value;
|
||||
return GetX(
|
||||
init: WalletController(),
|
||||
builder: (controller) {
|
||||
return Scaffold(
|
||||
backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface,
|
||||
body:
|
||||
controller.isLoading.value
|
||||
? Constant.loader()
|
||||
: Constant.userModel == null
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset("assets/images/login.gif", height: 120),
|
||||
const SizedBox(height: 12),
|
||||
Text("Please Log In to Continue".tr, style: TextStyle(color: isDark ? AppThemeData.grey100 : AppThemeData.grey800, fontSize: 22, fontFamily: AppThemeData.semiBold)),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
"You’re not logged in. Please sign in to access your account and explore all features.".tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey500, fontSize: 16, fontFamily: AppThemeData.bold),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
RoundedButtonFill(
|
||||
title: "Log in".tr,
|
||||
width: 55,
|
||||
height: 5.5,
|
||||
color: AppThemeData.primary300,
|
||||
textColor: AppThemeData.grey50,
|
||||
onPress: () async {
|
||||
Get.offAll(const LoginScreen());
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.only(top: MediaQuery.of(context).viewPadding.top),
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"My Wallet".tr,
|
||||
style: TextStyle(fontSize: 24, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w500),
|
||||
),
|
||||
Text(
|
||||
"Keep track of your balance, transactions, and payment methods all in one place.".tr,
|
||||
style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey900, fontFamily: AppThemeData.regular, fontWeight: FontWeight.w400),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
image: DecorationImage(image: AssetImage("assets/images/wallet.png"), fit: BoxFit.fill),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"My Wallet".tr,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
color: isDark ? AppThemeData.primary100 : AppThemeData.primary100,
|
||||
fontSize: 16,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
fontFamily: AppThemeData.regular,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
Constant.amountShow(amount: controller.userModel.value.walletAmount.toString()),
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: isDark ? AppThemeData.grey50 : AppThemeData.grey50, fontSize: 40, overflow: TextOverflow.ellipsis, fontFamily: AppThemeData.bold),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 80),
|
||||
child: RoundedButtonFill(
|
||||
title: "Top up".tr,
|
||||
color: AppThemeData.warning300,
|
||||
textColor: AppThemeData.grey900,
|
||||
onPress: () {
|
||||
Get.to(const PaymentListScreen());
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child:
|
||||
controller.walletTransactionList.isEmpty
|
||||
? Constant.showEmptyView(message: "Transaction not found".tr)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: controller.walletTransactionList.length,
|
||||
itemBuilder: (context, index) {
|
||||
WalletTransactionModel walletTractionModel = controller.walletTransactionList[index];
|
||||
return transactionCard(controller, isDark, walletTractionModel);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Column transactionCard(WalletController controller, isDark, WalletTransactionModel transactionModel) {
|
||||
return Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final orderId = transactionModel.orderId.toString();
|
||||
final orderData = await FireStoreUtils.getOrderByIdFromAllCollections(orderId);
|
||||
|
||||
if (orderData != null) {
|
||||
final collection = orderData['collection_name'];
|
||||
|
||||
switch (collection) {
|
||||
case CollectionName.parcelOrders:
|
||||
Get.to(const ParcelOrderDetails(), arguments: ParcelOrderModel.fromJson(orderData));
|
||||
break;
|
||||
case CollectionName.providerOrders:
|
||||
Get.to(const OnDemandOrderDetailsScreen(), arguments: OnProviderOrderModel.fromJson(orderData));
|
||||
break;
|
||||
case CollectionName.rentalOrders:
|
||||
Get.to(() => RentalOrderDetailsScreen(), arguments: RentalOrderModel.fromJson(orderData));
|
||||
break;
|
||||
case CollectionName.rides:
|
||||
Get.to(const CabOrderDetails(), arguments: {"cabOrderModel": CabOrderModel.fromJson(orderData)});
|
||||
break;
|
||||
case CollectionName.vendorOrders:
|
||||
Get.to(const OrderDetailsScreen(), arguments: {"orderModel": OrderModel.fromJson(orderData)});
|
||||
break;
|
||||
default:
|
||||
ShowToastDialog.showToast("Order details not available".tr);
|
||||
}
|
||||
}
|
||||
},
|
||||
// onTap: () async {
|
||||
// await FireStoreUtils
|
||||
// .getOrderByOrderId(transactionModel.orderId.toString())
|
||||
// .then((value) {
|
||||
// if (value != null) {
|
||||
// Get.to(
|
||||
// const OrderDetailsScreen(),
|
||||
// arguments: {"orderModel": value},
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(side: BorderSide(width: 1, color: isDark ? AppThemeData.grey800 : AppThemeData.grey100), borderRadius: BorderRadius.circular(8)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child:
|
||||
transactionModel.isTopup == false
|
||||
? SvgPicture.asset("assets/icons/ic_debit.svg", height: 16, width: 16)
|
||||
: SvgPicture.asset("assets/icons/ic_credit.svg", height: 16, width: 16),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
transactionModel.note.toString(),
|
||||
style: TextStyle(fontSize: 16, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600, color: isDark ? AppThemeData.grey100 : AppThemeData.grey800),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
Constant.amountShow(amount: transactionModel.amount.toString()),
|
||||
style: TextStyle(fontSize: 16, fontFamily: AppThemeData.medium, color: transactionModel.isTopup == true ? AppThemeData.success400 : AppThemeData.danger300),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
Constant.timestampToDateTime(transactionModel.date!),
|
||||
style: TextStyle(fontSize: 12, fontFamily: AppThemeData.medium, fontWeight: FontWeight.w500, color: isDark ? AppThemeData.grey200 : AppThemeData.grey700),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(padding: const EdgeInsets.symmetric(vertical: 5), child: MySeparator(color: isDark ? AppThemeData.grey700 : AppThemeData.grey200)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum PaymentGateway { payFast, mercadoPago, paypal, stripe, flutterWave, payStack, razorpay, cod, wallet, midTrans, orangeMoney, xendit }
|
||||
Reference in New Issue
Block a user