BASE: Update Icons & Name Of The App.

This commit is contained in:
2025-12-04 10:23:59 +05:00
parent b04050384d
commit e602782edd
228 changed files with 34364 additions and 7905 deletions

View File

@@ -39,7 +39,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_paypal/flutter_paypal.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:get/get.dart';
import 'package:get/get.dart' hide Trans;
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:razorpay_flutter/razorpay_flutter.dart';
@@ -72,7 +72,9 @@ class MyCabBookingController extends GetxController {
isLoading.value = true;
if (FirebaseAuth.instance.currentUser != null) {
await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((user) {
await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((
user,
) {
if (user != null) {
userModel.value = user;
}
@@ -88,21 +90,45 @@ class MyCabBookingController extends GetxController {
isLoading.value = false;
}
List<CabOrderModel> get filteredParcelOrders => getOrdersForTab(selectedTab.value);
List<CabOrderModel> get filteredParcelOrders =>
getOrdersForTab(selectedTab.value);
List<CabOrderModel> getOrdersForTab(String tab) {
switch (tab) {
case "New":
return cabOrder.where((order) => ["Order Placed", "Driver Pending"].contains(order.status)).toList();
return cabOrder
.where(
(order) =>
["Order Placed", "Driver Pending"].contains(order.status),
)
.toList();
case "On Going":
return cabOrder.where((order) => ["Driver Accepted", "Order Shipped", "In Transit"].contains(order.status)).toList();
return cabOrder
.where(
(order) => [
"Driver Accepted",
"Order Shipped",
"In Transit",
].contains(order.status),
)
.toList();
case "Completed":
return cabOrder.where((order) => ["Order Completed"].contains(order.status)).toList();
return cabOrder
.where((order) => ["Order Completed"].contains(order.status))
.toList();
case "Cancelled":
return cabOrder.where((order) => ["Order Rejected", "Order Cancelled", "Driver Rejected"].contains(order.status)).toList();
return cabOrder
.where(
(order) => [
"Order Rejected",
"Order Cancelled",
"Driver Rejected",
].contains(order.status),
)
.toList();
default:
return [];
@@ -164,15 +190,22 @@ class MyCabBookingController extends GetxController {
selectedOrder.value = order;
try {
subTotal.value = double.tryParse(selectedOrder.value.subTotal?.toString() ?? "0") ?? 0.0;
discount.value = double.tryParse(selectedOrder.value.discount?.toString() ?? "0") ?? 0.0;
subTotal.value =
double.tryParse(selectedOrder.value.subTotal?.toString() ?? "0") ??
0.0;
discount.value =
double.tryParse(selectedOrder.value.discount?.toString() ?? "0") ??
0.0;
taxAmount.value = 0.0;
subTotal.value = subTotal.value;
if (selectedOrder.value.taxSetting != null) {
for (var element in selectedOrder.value.taxSetting!) {
taxAmount.value += Constant.calculateTax(amount: (subTotal.value - discount.value).toString(), taxModel: element);
taxAmount.value += Constant.calculateTax(
amount: (subTotal.value - discount.value).toString(),
taxModel: element,
);
}
}
@@ -209,8 +242,13 @@ class MyCabBookingController extends GetxController {
serviceType: Constant.parcelServiceType,
);
await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async {
await FireStoreUtils.updateUserWallet(amount: "-${totalAmount.value.toString()}", userId: FireStoreUtils.getCurrentUid());
await FireStoreUtils.setWalletTransaction(transactionModel).then((
value,
) async {
await FireStoreUtils.updateUserWallet(
amount: "-${totalAmount.value.toString()}",
userId: FireStoreUtils.getCurrentUid(),
);
});
}
selectedOrder.value.paymentStatus = true;
@@ -223,19 +261,45 @@ class MyCabBookingController extends GetxController {
Future<void> getPaymentSettings() async {
await FireStoreUtils.getPaymentSettingsData().then((value) {
stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings)));
payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings)));
payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack)));
mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago)));
flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave)));
paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings)));
payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings)));
razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings)));
midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings)));
orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)));
xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings)));
walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings)));
cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings)));
stripeModel.value = StripeModel.fromJson(
jsonDecode(Preferences.getString(Preferences.stripeSettings)),
);
payPalModel.value = PayPalModel.fromJson(
jsonDecode(Preferences.getString(Preferences.paypalSettings)),
);
payStackModel.value = PayStackModel.fromJson(
jsonDecode(Preferences.getString(Preferences.payStack)),
);
mercadoPagoModel.value = MercadoPagoModel.fromJson(
jsonDecode(Preferences.getString(Preferences.mercadoPago)),
);
flutterWaveModel.value = FlutterWaveModel.fromJson(
jsonDecode(Preferences.getString(Preferences.flutterWave)),
);
paytmModel.value = PaytmModel.fromJson(
jsonDecode(Preferences.getString(Preferences.paytmSettings)),
);
payFastModel.value = PayFastModel.fromJson(
jsonDecode(Preferences.getString(Preferences.payFastSettings)),
);
razorPayModel.value = RazorPayModel.fromJson(
jsonDecode(Preferences.getString(Preferences.razorpaySettings)),
);
midTransModel.value = MidTrans.fromJson(
jsonDecode(Preferences.getString(Preferences.midTransSettings)),
);
orangeMoneyModel.value = OrangeMoney.fromJson(
jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)),
);
xenditModel.value = Xendit.fromJson(
jsonDecode(Preferences.getString(Preferences.xenditSettings)),
);
walletSettingModel.value = WalletSettingModel.fromJson(
jsonDecode(Preferences.getString(Preferences.walletSettings)),
);
cashOnDeliverySettingModel.value = CodSettingModel.fromJson(
jsonDecode(Preferences.getString(Preferences.codSettings)),
);
if (walletSettingModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.wallet.name;
@@ -277,20 +341,32 @@ class MyCabBookingController extends GetxController {
Future<void> stripeMakePayment({required String amount}) async {
log(double.parse(amount).toStringAsFixed(0));
try {
Map<String, dynamic>? paymentIntentData = await createStripeIntent(amount: amount);
Map<String, dynamic>? paymentIntentData = await createStripeIntent(
amount: amount,
);
log("stripe Responce====>$paymentIntentData");
if (paymentIntentData!.containsKey("error")) {
Get.back();
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
} else {
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: paymentIntentData['client_secret'],
allowsDelayedPaymentMethods: false,
googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'US', testEnv: true, currencyCode: "USD"),
googlePay: const PaymentSheetGooglePay(
merchantCountryCode: 'US',
testEnv: true,
currencyCode: "USD",
),
customFlow: true,
style: ThemeMode.system,
appearance: PaymentSheetAppearance(colors: PaymentSheetAppearanceColors(primary: AppThemeData.primary300)),
appearance: PaymentSheetAppearance(
colors: PaymentSheetAppearanceColors(
primary: AppThemeData.primary300,
),
),
merchantDisplayName: 'GoRide',
),
);
@@ -336,7 +412,10 @@ class MyCabBookingController extends GetxController {
var response = await http.post(
Uri.parse('https://api.stripe.com/v1/payment_intents'),
body: body,
headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'},
headers: {
'Authorization': 'Bearer $stripeSecret',
'Content-Type': 'application/x-www-form-urlencoded',
},
);
return jsonDecode(response.body);
@@ -346,8 +425,14 @@ class MyCabBookingController extends GetxController {
}
//mercadoo
Future<Null> mercadoPagoMakePayment({required BuildContext context, required String amount}) async {
final headers = {'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}', 'Content-Type': 'application/json'};
Future<Null> mercadoPagoMakePayment({
required BuildContext context,
required String amount,
}) async {
final headers = {
'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}',
'Content-Type': 'application/json',
};
final body = jsonEncode({
"items": [
@@ -369,7 +454,11 @@ class MyCabBookingController extends GetxController {
// Automatically return after payment is approved
});
final response = await http.post(Uri.parse("https://api.mercadopago.com/checkout/preferences"), headers: headers, body: body);
final response = await http.post(
Uri.parse("https://api.mercadopago.com/checkout/preferences"),
headers: headers,
body: body,
);
if (response.statusCode == 200 || response.statusCode == 201) {
final data = jsonDecode(response.body);
@@ -452,15 +541,23 @@ class MyCabBookingController extends GetxController {
}
});
} else {
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
}
});
}
//flutter wave Payment Method
Future<Null> flutterWaveInitiatePayment({required BuildContext context, required String amount}) async {
Future<Null> flutterWaveInitiatePayment({
required BuildContext context,
required String amount,
}) async {
final url = Uri.parse('https://api.flutterwave.com/v3/payments');
final headers = {'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}', 'Content-Type': 'application/json'};
final headers = {
'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}',
'Content-Type': 'application/json',
};
final body = jsonEncode({
"tx_ref": _ref,
@@ -470,17 +567,23 @@ class MyCabBookingController extends GetxController {
"payment_options": "ussd, card, barter, payattitude",
"customer": {
"email": Constant.userModel!.email.toString(),
"phonenumber": Constant.userModel!.phoneNumber, // Add a real phone number
"phonenumber":
Constant.userModel!.phoneNumber, // Add a real phone number
"name": Constant.userModel!.fullName(), // Add a real customer name
},
"customizations": {"title": "Payment for Services", "description": "Payment for XYZ services"},
"customizations": {
"title": "Payment for Services",
"description": "Payment for XYZ services",
},
});
final response = await http.post(url, headers: headers, body: body);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) {
Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((
value,
) {
if (value) {
ShowToastDialog.showToast("Payment Successful!!".tr());
completeOrder();
@@ -509,10 +612,14 @@ class MyCabBookingController extends GetxController {
// payFast
void payFastPayment({required BuildContext context, required String amount}) {
PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: Constant.userModel!).then((
String? value,
) async {
bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value));
PayStackURLGen.getPayHTML(
payFastSettingData: payFastModel.value,
amount: amount.toString(),
userModel: Constant.userModel!,
).then((String? value) async {
bool isDone = await Get.to(
PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value),
);
if (isDone) {
Get.back();
ShowToastDialog.showToast("Payment successfully".tr());
@@ -594,7 +701,11 @@ class MyCabBookingController extends GetxController {
// }
}
Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async {
Future verifyCheckSum({
required String checkSum,
required double amount,
required orderId,
}) async {
String getChecksum = "${Constant.globalUrl}payments/validatechecksum";
final response = await http.post(
Uri.parse(getChecksum),
@@ -610,13 +721,18 @@ class MyCabBookingController extends GetxController {
return data['status'];
}
Future<GetPaymentTxtTokenModel> initiatePayment({required double amount, required orderId}) async {
Future<GetPaymentTxtTokenModel> initiatePayment({
required double amount,
required orderId,
}) async {
String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment";
String callback = "";
if (paytmModel.value.isSandboxEnabled == true) {
callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
callback =
"${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
} else {
callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
callback =
"${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
}
final response = await http.post(
Uri.parse(initiateURL),
@@ -634,9 +750,12 @@ class MyCabBookingController extends GetxController {
);
log(response.body);
final data = jsonDecode(response.body);
if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) {
if (data["body"]["txnToken"] == null ||
data["body"]["txnToken"].toString().isEmpty) {
Get.back();
ShowToastDialog.showToast("something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"something went wrong, please contact admin.".tr(),
);
}
return GetPaymentTxtTokenModel.fromJson(data);
}
@@ -654,7 +773,10 @@ class MyCabBookingController extends GetxController {
'description': 'wallet Topup',
'retry': {'enabled': true, 'max_count': 1},
'send_sms_hash': true,
'prefill': {'contact': Constant.userModel!.phoneNumber, 'email': Constant.userModel!.email},
'prefill': {
'contact': Constant.userModel!.phoneNumber,
'email': Constant.userModel!.email,
},
'external': {
'wallets': ['paytm'],
},
@@ -689,7 +811,10 @@ class MyCabBookingController extends GetxController {
}
//Midtrans payment
Future<void> midtransMakePayment({required String amount, required BuildContext context}) async {
Future<void> midtransMakePayment({
required String amount,
required BuildContext context,
}) async {
await createPaymentLink(amount: amount).then((url) {
ShowToastDialog.closeLoader();
if (url != '') {
@@ -708,7 +833,9 @@ class MyCabBookingController extends GetxController {
Future<String> createPaymentLink({required var amount}) async {
var ordersId = const Uuid().v1();
final url = Uri.parse(
midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links',
midTransModel.value.isSandbox!
? 'https://api.sandbox.midtrans.com/v1/payment-links'
: 'https://api.midtrans.com/v1/payment-links',
);
final response = await http.post(
@@ -716,12 +843,19 @@ class MyCabBookingController extends GetxController {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!),
'Authorization': generateBasicAuthHeader(
midTransModel.value.serverKey!,
),
},
body: jsonEncode({
'transaction_details': {'order_id': ordersId, 'gross_amount': double.parse(amount.toString()).toInt()},
'transaction_details': {
'order_id': ordersId,
'gross_amount': double.parse(amount.toString()).toInt(),
},
'usage_limit': 2,
"callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"},
"callbacks": {
"finish": "https://www.google.com?merchant_order_id=$ordersId",
},
}),
);
@@ -729,7 +863,9 @@ class MyCabBookingController extends GetxController {
final responseData = jsonDecode(response.body);
return responseData['payment_url'];
} else {
ShowToastDialog.showToast("something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"something went wrong, please contact admin.".tr(),
);
return '';
}
}
@@ -746,10 +882,18 @@ class MyCabBookingController extends GetxController {
static String orderId = '';
static String amount = '';
Future<void> orangeMakePayment({required String amount, required BuildContext context}) async {
Future<void> orangeMakePayment({
required String amount,
required BuildContext context,
}) async {
reset();
var id = const Uuid().v4();
var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD');
var paymentURL = await fetchToken(
context: context,
orderId: id,
amount: amount,
currency: 'USD',
);
ShowToastDialog.closeLoader();
if (paymentURL.toString() != '') {
Get.to(
@@ -773,7 +917,12 @@ class MyCabBookingController extends GetxController {
}
}
Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async {
Future fetchToken({
required String orderId,
required String currency,
required BuildContext context,
required String amount,
}) async {
String apiUrl = 'https://api.orange.com/oauth/v3/token';
Map<String, String> requestBody = {'grant_type': 'client_credentials'};
@@ -794,9 +943,16 @@ class MyCabBookingController extends GetxController {
accessToken = responseData['access_token'];
// ignore: use_build_context_synchronously
return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId);
return await webpayment(
context: context,
amountData: amount,
currency: currency,
orderIdData: orderId,
);
} else {
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
return '';
}
}
@@ -827,7 +983,11 @@ class MyCabBookingController extends GetxController {
var response = await http.post(
Uri.parse(apiUrl),
headers: <String, String>{'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'},
headers: <String, String>{
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: json.encode(requestBody),
);
@@ -841,7 +1001,9 @@ class MyCabBookingController extends GetxController {
return '';
}
} else {
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
return '';
}
}
@@ -859,7 +1021,11 @@ class MyCabBookingController extends GetxController {
ShowToastDialog.closeLoader();
if (model.id != null) {
Get.to(
() => XenditScreen(initialURl: model.invoiceUrl ?? '', transId: model.id ?? '', apiKey: xenditModel.value.apiKey!.toString()),
() => XenditScreen(
initialURl: model.invoiceUrl ?? '',
transId: model.id ?? '',
apiKey: xenditModel.value.apiKey!.toString(),
),
)!.then((value) {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr());
@@ -877,7 +1043,9 @@ class MyCabBookingController extends GetxController {
const url = 'https://api.xendit.co/v2/invoices';
var headers = {
'Content-Type': 'application/json',
'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()),
'Authorization': generateBasicAuthHeader(
xenditModel.value.apiKey!.toString(),
),
// 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ',
};
@@ -890,7 +1058,11 @@ class MyCabBookingController extends GetxController {
});
try {
final response = await http.post(Uri.parse(url), headers: headers, body: body);
final response = await http.post(
Uri.parse(url),
headers: headers,
body: body,
);
if (response.statusCode == 200 || response.statusCode == 201) {
XenditModel model = XenditModel.fromJson(jsonDecode(response.body));