BASE: Update Icons & Name Of The App.
This commit is contained in:
@@ -19,7 +19,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:geolocator/geolocator.dart' as geolocator;
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mailer/mailer.dart';
|
||||
@@ -172,7 +172,10 @@ class Constant {
|
||||
static bool checkZoneCheck(double latitude, double longLatitude) {
|
||||
bool isZoneAvailable = false;
|
||||
for (var element in Constant.zoneList) {
|
||||
if (Constant.isPointInPolygon(LatLng(latitude, longLatitude), element.area!)) {
|
||||
if (Constant.isPointInPolygon(
|
||||
LatLng(latitude, longLatitude),
|
||||
element.area!,
|
||||
)) {
|
||||
isZoneAvailable = true;
|
||||
break;
|
||||
} else {
|
||||
@@ -185,7 +188,10 @@ class Constant {
|
||||
static String? getZoneId(double latitude, double longLatitude) {
|
||||
String? zoneId;
|
||||
for (var element in Constant.zoneList) {
|
||||
if (Constant.isPointInPolygon(LatLng(latitude, longLatitude), element.area!)) {
|
||||
if (Constant.isPointInPolygon(
|
||||
LatLng(latitude, longLatitude),
|
||||
element.area!,
|
||||
)) {
|
||||
zoneId = element.id;
|
||||
break;
|
||||
}
|
||||
@@ -198,13 +204,18 @@ class Constant {
|
||||
return (rng.nextInt(900000) + 100000).toString(); // 6 digit
|
||||
}
|
||||
|
||||
static Future<void> checkPermission({required BuildContext context, required Function() onTap}) async {
|
||||
static Future<void> checkPermission({
|
||||
required BuildContext context,
|
||||
required Function() onTap,
|
||||
}) async {
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
}
|
||||
if (permission == LocationPermission.denied) {
|
||||
ShowToastDialog.showToast("You have to allow location permission to use your location");
|
||||
ShowToastDialog.showToast(
|
||||
"You have to allow location permission to use your location",
|
||||
);
|
||||
} else if (permission == LocationPermission.deniedForever) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -241,7 +252,10 @@ class Constant {
|
||||
return isPlanExpire;
|
||||
}
|
||||
|
||||
static bool isExpireDate({required bool expiryDay, Timestamp? subscriptionExpiryDate}) {
|
||||
static bool isExpireDate({
|
||||
required bool expiryDay,
|
||||
Timestamp? subscriptionExpiryDate,
|
||||
}) {
|
||||
bool isPlanExpire = false;
|
||||
if (expiryDay == true) {
|
||||
isPlanExpire = false;
|
||||
@@ -301,17 +315,49 @@ class Constant {
|
||||
String commission = "0";
|
||||
if (sectionConstantModel!.adminCommision!.isEnabled == true) {
|
||||
if (vendorModel.adminCommission == null) {
|
||||
if (sectionConstantModel!.adminCommision!.commissionType!.toLowerCase() == "Percent".toLowerCase() ||
|
||||
sectionConstantModel!.adminCommision!.commissionType?.toLowerCase() == "Percentage".toLowerCase()) {
|
||||
commission = (double.parse(price) + (double.parse(price) * double.parse(sectionConstantModel!.adminCommision!.amount.toString()) / 100)).toString();
|
||||
if (sectionConstantModel!.adminCommision!.commissionType!
|
||||
.toLowerCase() ==
|
||||
"Percent".toLowerCase() ||
|
||||
sectionConstantModel!.adminCommision!.commissionType
|
||||
?.toLowerCase() ==
|
||||
"Percentage".toLowerCase()) {
|
||||
commission =
|
||||
(double.parse(price) +
|
||||
(double.parse(price) *
|
||||
double.parse(
|
||||
sectionConstantModel!.adminCommision!.amount
|
||||
.toString(),
|
||||
) /
|
||||
100))
|
||||
.toString();
|
||||
} else {
|
||||
commission = (double.parse(price) + double.parse(sectionConstantModel!.adminCommision!.amount.toString())).toString();
|
||||
commission =
|
||||
(double.parse(price) +
|
||||
double.parse(
|
||||
sectionConstantModel!.adminCommision!.amount.toString(),
|
||||
))
|
||||
.toString();
|
||||
}
|
||||
} else {
|
||||
if (vendorModel.adminCommission!.commissionType!.toLowerCase() == "Percent".toLowerCase() || vendorModel.adminCommission!.commissionType?.toLowerCase() == "Percentage".toLowerCase()) {
|
||||
commission = (double.parse(price) + (double.parse(price) * double.parse(vendorModel.adminCommission!.amount.toString()) / 100)).toString();
|
||||
if (vendorModel.adminCommission!.commissionType!.toLowerCase() ==
|
||||
"Percent".toLowerCase() ||
|
||||
vendorModel.adminCommission!.commissionType?.toLowerCase() ==
|
||||
"Percentage".toLowerCase()) {
|
||||
commission =
|
||||
(double.parse(price) +
|
||||
(double.parse(price) *
|
||||
double.parse(
|
||||
vendorModel.adminCommission!.amount.toString(),
|
||||
) /
|
||||
100))
|
||||
.toString();
|
||||
} else {
|
||||
commission = (double.parse(price) + double.parse(vendorModel.adminCommission!.amount.toString())).toString();
|
||||
commission =
|
||||
(double.parse(price) +
|
||||
double.parse(
|
||||
vendorModel.adminCommission!.amount.toString(),
|
||||
))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -327,7 +373,10 @@ class Constant {
|
||||
if (taxModel.type == "fix") {
|
||||
taxAmount = double.parse(taxModel.tax.toString());
|
||||
} else {
|
||||
taxAmount = (double.parse(amount.toString()) * double.parse(taxModel.tax!.toString())) / 100;
|
||||
taxAmount =
|
||||
(double.parse(amount.toString()) *
|
||||
double.parse(taxModel.tax!.toString())) /
|
||||
100;
|
||||
}
|
||||
}
|
||||
return taxAmount;
|
||||
@@ -336,8 +385,12 @@ class Constant {
|
||||
static double calculateDiscount({String? amount, CouponModel? offerModel}) {
|
||||
double taxAmount = 0.0;
|
||||
if (offerModel != null) {
|
||||
if (offerModel.discountType == "Percentage" || offerModel.discountType == "percentage") {
|
||||
taxAmount = (double.parse(amount.toString()) * double.parse(offerModel.discount.toString())) / 100;
|
||||
if (offerModel.discountType == "Percentage" ||
|
||||
offerModel.discountType == "percentage") {
|
||||
taxAmount =
|
||||
(double.parse(amount.toString()) *
|
||||
double.parse(offerModel.discount.toString())) /
|
||||
100;
|
||||
} else {
|
||||
taxAmount = double.parse(offerModel.discount.toString());
|
||||
}
|
||||
@@ -345,11 +398,17 @@ class Constant {
|
||||
return taxAmount;
|
||||
}
|
||||
|
||||
static String calculateReview({required String? reviewCount, required String? reviewSum}) {
|
||||
if (0 == double.parse(reviewSum.toString()) && 0 == double.parse(reviewSum.toString())) {
|
||||
static String calculateReview({
|
||||
required String? reviewCount,
|
||||
required String? reviewSum,
|
||||
}) {
|
||||
if (0 == double.parse(reviewSum.toString()) &&
|
||||
0 == double.parse(reviewSum.toString())) {
|
||||
return "0";
|
||||
}
|
||||
return (double.parse(reviewSum.toString()) / double.parse(reviewCount.toString())).toStringAsFixed(1);
|
||||
return (double.parse(reviewSum.toString()) /
|
||||
double.parse(reviewCount.toString()))
|
||||
.toStringAsFixed(1);
|
||||
}
|
||||
|
||||
static String getUuid() {
|
||||
@@ -357,13 +416,24 @@ class Constant {
|
||||
}
|
||||
|
||||
static Widget loader() {
|
||||
return Center(child: CircularProgressIndicator(color: AppThemeData.primary300));
|
||||
return Center(
|
||||
child: CircularProgressIndicator(color: AppThemeData.primary300),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget showEmptyView({required String message}) {
|
||||
final themeController = Get.find<ThemeController>();
|
||||
final isDark = themeController.isDark.value;
|
||||
return Center(child: Text(message, style: TextStyle(fontFamily: AppThemeData.fontFamily, fontSize: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)));
|
||||
return Center(
|
||||
child: Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
fontFamily: AppThemeData.fontFamily,
|
||||
fontSize: 18,
|
||||
color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String maskingString(String documentId, int maskingDigit) {
|
||||
@@ -382,7 +452,8 @@ class Constant {
|
||||
}
|
||||
|
||||
String? validateEmail(String? value) {
|
||||
String pattern = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
||||
String pattern =
|
||||
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
||||
RegExp regExp = RegExp(pattern);
|
||||
if (value == null || value.isEmpty) {
|
||||
return "Email is Required";
|
||||
@@ -393,9 +464,19 @@ class Constant {
|
||||
}
|
||||
}
|
||||
|
||||
static String getDistance({required String lat1, required String lng1, required String lat2, required String lng2}) {
|
||||
static String getDistance({
|
||||
required String lat1,
|
||||
required String lng1,
|
||||
required String lat2,
|
||||
required String lng2,
|
||||
}) {
|
||||
double distance;
|
||||
double distanceInMeters = Geolocator.distanceBetween(double.parse(lat1), double.parse(lng1), double.parse(lat2), double.parse(lng2));
|
||||
double distanceInMeters = Geolocator.distanceBetween(
|
||||
double.parse(lat1),
|
||||
double.parse(lng1),
|
||||
double.parse(lat2),
|
||||
double.parse(lng2),
|
||||
);
|
||||
if (distanceType == "miles") {
|
||||
distance = distanceInMeters / 1609;
|
||||
} else {
|
||||
@@ -405,7 +486,8 @@ class Constant {
|
||||
}
|
||||
|
||||
bool hasValidUrl(String? value) {
|
||||
String pattern = r'(http|https)://[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?';
|
||||
String pattern =
|
||||
r'(http|https)://[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?';
|
||||
RegExp regExp = RegExp(pattern);
|
||||
if (value == null || value.isEmpty) {
|
||||
return false;
|
||||
@@ -415,10 +497,17 @@ class Constant {
|
||||
return true;
|
||||
}
|
||||
|
||||
static Future<String> uploadUserImageToFireStorage(File image, String filePath, String fileName) async {
|
||||
Reference upload = FirebaseStorage.instance.ref().child('$filePath/$fileName');
|
||||
static Future<String> uploadUserImageToFireStorage(
|
||||
File image,
|
||||
String filePath,
|
||||
String fileName,
|
||||
) async {
|
||||
Reference upload = FirebaseStorage.instance.ref().child(
|
||||
'$filePath/$fileName',
|
||||
);
|
||||
UploadTask uploadTask = upload.putFile(image);
|
||||
var downloadUrl = await (await uploadTask.whenComplete(() {})).ref.getDownloadURL();
|
||||
var downloadUrl =
|
||||
await (await uploadTask.whenComplete(() {})).ref.getDownloadURL();
|
||||
return downloadUrl.toString();
|
||||
}
|
||||
|
||||
@@ -435,14 +524,22 @@ class Constant {
|
||||
|
||||
Future<Uint8List> getBytesFromAsset(String path, int width) async {
|
||||
ByteData data = await rootBundle.load(path);
|
||||
ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width);
|
||||
ui.Codec codec = await ui.instantiateImageCodec(
|
||||
data.buffer.asUint8List(),
|
||||
targetWidth: width,
|
||||
);
|
||||
ui.FrameInfo fi = await codec.getNextFrame();
|
||||
return (await fi.image.toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List();
|
||||
return (await fi.image.toByteData(
|
||||
format: ui.ImageByteFormat.png,
|
||||
))!.buffer.asUint8List();
|
||||
}
|
||||
|
||||
static Future<TimeOfDay?> selectTime(context) async {
|
||||
FocusScope.of(context).requestFocus(FocusNode()); //remove focus
|
||||
TimeOfDay? newTime = await showTimePicker(context: context, initialTime: TimeOfDay.now());
|
||||
TimeOfDay? newTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
);
|
||||
if (newTime != null) {
|
||||
return newTime;
|
||||
}
|
||||
@@ -480,7 +577,11 @@ class Constant {
|
||||
|
||||
static int calculateDifference(DateTime date) {
|
||||
DateTime now = DateTime.now();
|
||||
return DateTime(date.year, date.month, date.day).difference(DateTime(now.year, now.month, now.day)).inDays;
|
||||
return DateTime(
|
||||
date.year,
|
||||
date.month,
|
||||
date.day,
|
||||
).difference(DateTime(now.year, now.month, now.day)).inDays;
|
||||
}
|
||||
|
||||
static String timestampToDate(Timestamp timestamp) {
|
||||
@@ -509,7 +610,15 @@ class Constant {
|
||||
}
|
||||
|
||||
static DateTime stringToDate(String openDineTime) {
|
||||
return DateFormat('HH:mm').parse(DateFormat('HH:mm').format(DateFormat("hh:mm a").parse((Intl.getCurrentLocale() == "en_US") ? openDineTime : openDineTime.toLowerCase())));
|
||||
return DateFormat('HH:mm').parse(
|
||||
DateFormat('HH:mm').format(
|
||||
DateFormat("hh:mm a").parse(
|
||||
(Intl.getCurrentLocale() == "en_US")
|
||||
? openDineTime
|
||||
: openDineTime.toLowerCase(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static LanguageModel getLanguage() {
|
||||
@@ -527,7 +636,10 @@ class Constant {
|
||||
int crossings = 0;
|
||||
for (int i = 0; i < polygon.length; i++) {
|
||||
int next = (i + 1) % polygon.length;
|
||||
if (polygon[i].latitude <= point.latitude && polygon[next].latitude > point.latitude || polygon[i].latitude > point.latitude && polygon[next].latitude <= point.latitude) {
|
||||
if (polygon[i].latitude <= point.latitude &&
|
||||
polygon[next].latitude > point.latitude ||
|
||||
polygon[i].latitude > point.latitude &&
|
||||
polygon[next].latitude <= point.latitude) {
|
||||
double edgeLong = polygon[next].longitude - polygon[i].longitude;
|
||||
double edgeLat = polygon[next].latitude - polygon[i].latitude;
|
||||
double interpol = (point.latitude - polygon[i].latitude) / edgeLat;
|
||||
@@ -549,7 +661,12 @@ class Constant {
|
||||
allowInsecure: true,
|
||||
);
|
||||
|
||||
static Future<void> sendMail({String? subject, String? body, bool? isAdmin = false, List<dynamic>? recipients}) async {
|
||||
static Future<void> sendMail({
|
||||
String? subject,
|
||||
String? body,
|
||||
bool? isAdmin = false,
|
||||
List<dynamic>? recipients,
|
||||
}) async {
|
||||
// Create our message.
|
||||
if (mailSettings != null) {
|
||||
if (isAdmin == true) {
|
||||
@@ -557,7 +674,10 @@ class Constant {
|
||||
}
|
||||
final message =
|
||||
Message()
|
||||
..from = Address(mailSettings!.userName.toString(), mailSettings!.fromName.toString())
|
||||
..from = Address(
|
||||
mailSettings!.userName.toString(),
|
||||
mailSettings!.fromName.toString(),
|
||||
)
|
||||
..recipients = recipients!
|
||||
..subject = subject
|
||||
..text = body
|
||||
@@ -581,10 +701,17 @@ class Constant {
|
||||
// await connection.send(message);
|
||||
}
|
||||
|
||||
static Uri createCoordinatesUrl(double latitude, double longitude, [String? label]) {
|
||||
static Uri createCoordinatesUrl(
|
||||
double latitude,
|
||||
double longitude, [
|
||||
String? label,
|
||||
]) {
|
||||
Uri uri;
|
||||
if (kIsWeb) {
|
||||
uri = Uri.https('www.google.com', '/maps/search/', {'api': '1', 'query': '$latitude,$longitude'});
|
||||
uri = Uri.https('www.google.com', '/maps/search/', {
|
||||
'api': '1',
|
||||
'query': '$latitude,$longitude',
|
||||
});
|
||||
} else if (Platform.isAndroid) {
|
||||
var query = '$latitude,$longitude';
|
||||
if (label != null) query += '($label)';
|
||||
@@ -594,14 +721,18 @@ class Constant {
|
||||
if (label != null) params['q'] = label;
|
||||
uri = Uri.https('maps.apple.com', '/', params);
|
||||
} else {
|
||||
uri = Uri.https('www.google.com', '/maps/search/', {'api': '1', 'query': '$latitude,$longitude'});
|
||||
uri = Uri.https('www.google.com', '/maps/search/', {
|
||||
'api': '1',
|
||||
'query': '$latitude,$longitude',
|
||||
});
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
static Future<void> sendOrderEmail({required OrderModel orderModel}) async {
|
||||
EmailTemplateModel? emailTemplateModel = await FireStoreUtils.getEmailTemplates(newOrderPlaced);
|
||||
EmailTemplateModel? emailTemplateModel =
|
||||
await FireStoreUtils.getEmailTemplates(newOrderPlaced);
|
||||
if (emailTemplateModel != null) {
|
||||
String firstHTML = """
|
||||
<table style="width: 100%; border-collapse: collapse; border: 1px solid rgb(0, 0, 0);">
|
||||
@@ -618,11 +749,23 @@ class Constant {
|
||||
""";
|
||||
|
||||
String newString = emailTemplateModel.message.toString();
|
||||
newString = newString.replaceAll("{username}", "${Constant.userModel!.firstName} ${Constant.userModel!.lastName}");
|
||||
newString = newString.replaceAll(
|
||||
"{username}",
|
||||
"${Constant.userModel!.firstName} ${Constant.userModel!.lastName}",
|
||||
);
|
||||
newString = newString.replaceAll("{orderid}", orderModel.id.toString());
|
||||
newString = newString.replaceAll("{date}", DateFormat('yyyy-MM-dd').format(orderModel.createdAt!.toDate()));
|
||||
newString = newString.replaceAll("{address}", orderModel.address!.getFullAddress());
|
||||
newString = newString.replaceAll("{paymentmethod}", orderModel.paymentMethod.toString());
|
||||
newString = newString.replaceAll(
|
||||
"{date}",
|
||||
DateFormat('yyyy-MM-dd').format(orderModel.createdAt!.toDate()),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{address}",
|
||||
orderModel.address!.getFullAddress(),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{paymentmethod}",
|
||||
orderModel.paymentMethod.toString(),
|
||||
);
|
||||
|
||||
double deliveryCharge = 0.0;
|
||||
double total = 0.0;
|
||||
@@ -630,7 +773,8 @@ class Constant {
|
||||
double discount = 0.0;
|
||||
double taxAmount = 0.0;
|
||||
double tipValue = 0.0;
|
||||
String specialLabel = '(${orderModel.specialDiscount!['special_discount_label']}${orderModel.specialDiscount!['specialType'] == "amount" ? currencyModel!.symbol : "%"})';
|
||||
String specialLabel =
|
||||
'(${orderModel.specialDiscount!['special_discount_label']}${orderModel.specialDiscount!['specialType'] == "amount" ? currencyModel!.symbol : "%"})';
|
||||
List<String> htmlList = [];
|
||||
|
||||
if (orderModel.deliveryCharge != null) {
|
||||
@@ -640,15 +784,22 @@ class Constant {
|
||||
tipValue = double.parse(orderModel.tipAmount.toString());
|
||||
}
|
||||
for (var element in orderModel.products!) {
|
||||
if (element.extrasPrice != null && element.extrasPrice!.isNotEmpty && double.parse(element.extrasPrice!) != 0.0) {
|
||||
total += double.parse(element.quantity.toString()) * double.parse(element.extrasPrice!);
|
||||
if (element.extrasPrice != null &&
|
||||
element.extrasPrice!.isNotEmpty &&
|
||||
double.parse(element.extrasPrice!) != 0.0) {
|
||||
total +=
|
||||
double.parse(element.quantity.toString()) *
|
||||
double.parse(element.extrasPrice!);
|
||||
}
|
||||
total += double.parse(element.quantity.toString()) * double.parse(element.price.toString());
|
||||
total +=
|
||||
double.parse(element.quantity.toString()) *
|
||||
double.parse(element.price.toString());
|
||||
|
||||
List<dynamic>? addon = element.extras;
|
||||
String extrasDisVal = '';
|
||||
for (int i = 0; i < addon!.length; i++) {
|
||||
extrasDisVal += '${addon[i].toString().replaceAll("\"", "")} ${(i == addon.length - 1) ? "" : ","}';
|
||||
extrasDisVal +=
|
||||
'${addon[i].toString().replaceAll("\"", "")} ${(i == addon.length - 1) ? "" : ","}';
|
||||
}
|
||||
String product = """
|
||||
<tr>
|
||||
@@ -666,7 +817,9 @@ class Constant {
|
||||
}
|
||||
|
||||
if (orderModel.specialDiscount!.isNotEmpty) {
|
||||
specialDiscount = double.parse(orderModel.specialDiscount!['special_discount'].toString());
|
||||
specialDiscount = double.parse(
|
||||
orderModel.specialDiscount!['special_discount'].toString(),
|
||||
);
|
||||
}
|
||||
|
||||
if (orderModel.couponId != null && orderModel.couponId!.isNotEmpty) {
|
||||
@@ -675,35 +828,81 @@ class Constant {
|
||||
|
||||
List<String> taxHtmlList = [];
|
||||
for (var element in taxList) {
|
||||
taxAmount = taxAmount + calculateTax(amount: (total - discount - specialDiscount).toString(), taxModel: element);
|
||||
taxAmount =
|
||||
taxAmount +
|
||||
calculateTax(
|
||||
amount: (total - discount - specialDiscount).toString(),
|
||||
taxModel: element,
|
||||
);
|
||||
String taxHtml =
|
||||
"""<span style="font-size: 1rem;">${element.title}: ${amountShow(amount: calculateTax(amount: (total - discount - specialDiscount).toString(), taxModel: element).toString())}${taxList.indexOf(element) == taxList.length - 1 ? "</span>" : "<br></span>"}""";
|
||||
taxHtmlList.add(taxHtml);
|
||||
}
|
||||
|
||||
var totalamount =
|
||||
orderModel.deliveryCharge == null || orderModel.deliveryCharge!.isEmpty
|
||||
orderModel.deliveryCharge == null ||
|
||||
orderModel.deliveryCharge!.isEmpty
|
||||
? total + taxAmount - discount - specialDiscount
|
||||
: total + taxAmount + double.parse(orderModel.deliveryCharge!) + double.parse(orderModel.tipAmount!) - discount - specialDiscount;
|
||||
: total +
|
||||
taxAmount +
|
||||
double.parse(orderModel.deliveryCharge!) +
|
||||
double.parse(orderModel.tipAmount!) -
|
||||
discount -
|
||||
specialDiscount;
|
||||
|
||||
newString = newString.replaceAll("{subtotal}", amountShow(amount: total.toString()));
|
||||
newString = newString.replaceAll("{coupon}", orderModel.couponId.toString());
|
||||
newString = newString.replaceAll("{discountamount}", amountShow(amount: orderModel.discount.toString()));
|
||||
newString = newString.replaceAll(
|
||||
"{subtotal}",
|
||||
amountShow(amount: total.toString()),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{coupon}",
|
||||
orderModel.couponId.toString(),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{discountamount}",
|
||||
amountShow(amount: orderModel.discount.toString()),
|
||||
);
|
||||
newString = newString.replaceAll("{specialcoupon}", specialLabel);
|
||||
newString = newString.replaceAll("{specialdiscountamount}", amountShow(amount: specialDiscount.toString()));
|
||||
newString = newString.replaceAll("{shippingcharge}", amountShow(amount: deliveryCharge.toString()));
|
||||
newString = newString.replaceAll("{tipamount}", amountShow(amount: tipValue.toString()));
|
||||
newString = newString.replaceAll("{totalAmount}", amountShow(amount: totalamount.toString()));
|
||||
newString = newString.replaceAll(
|
||||
"{specialdiscountamount}",
|
||||
amountShow(amount: specialDiscount.toString()),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{shippingcharge}",
|
||||
amountShow(amount: deliveryCharge.toString()),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{tipamount}",
|
||||
amountShow(amount: tipValue.toString()),
|
||||
);
|
||||
newString = newString.replaceAll(
|
||||
"{totalAmount}",
|
||||
amountShow(amount: totalamount.toString()),
|
||||
);
|
||||
|
||||
String tableHTML = htmlList.join();
|
||||
String lastHTML = "</tbody></table>";
|
||||
newString = newString.replaceAll("{productdetails}", firstHTML + tableHTML + lastHTML);
|
||||
newString = newString.replaceAll(
|
||||
"{productdetails}",
|
||||
firstHTML + tableHTML + lastHTML,
|
||||
);
|
||||
newString = newString.replaceAll("{taxdetails}", taxHtmlList.join());
|
||||
newString = newString.replaceAll("{newwalletbalance}.", amountShow(amount: Constant.userModel!.walletAmount.toString()));
|
||||
newString = newString.replaceAll(
|
||||
"{newwalletbalance}.",
|
||||
amountShow(amount: Constant.userModel!.walletAmount.toString()),
|
||||
);
|
||||
|
||||
String subjectNewString = emailTemplateModel.subject.toString();
|
||||
subjectNewString = subjectNewString.replaceAll("{orderid}", orderModel.id.toString());
|
||||
await sendMail(subject: subjectNewString, isAdmin: emailTemplateModel.isSendToAdmin, body: newString, recipients: [Constant.userModel!.email]);
|
||||
subjectNewString = subjectNewString.replaceAll(
|
||||
"{orderid}",
|
||||
orderModel.id.toString(),
|
||||
);
|
||||
await sendMail(
|
||||
subject: subjectNewString,
|
||||
isAdmin: emailTemplateModel.isSendToAdmin,
|
||||
body: newString,
|
||||
recipients: [Constant.userModel!.email],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,7 +910,12 @@ class Constant {
|
||||
const R = 6371; // Earth's radius in km
|
||||
final dLat = _degToRad(lat2 - lat1);
|
||||
final dLon = _degToRad(lon2 - lon1);
|
||||
final a = sin(dLat / 2) * sin(dLat / 2) + cos(_degToRad(lat1)) * cos(_degToRad(lat2)) * sin(dLon / 2) * sin(dLon / 2);
|
||||
final a =
|
||||
sin(dLat / 2) * sin(dLat / 2) +
|
||||
cos(_degToRad(lat1)) *
|
||||
cos(_degToRad(lat2)) *
|
||||
sin(dLon / 2) *
|
||||
sin(dLon / 2);
|
||||
final c = 2 * atan2(sqrt(a), sqrt(1 - a));
|
||||
return R * c;
|
||||
}
|
||||
@@ -725,13 +929,19 @@ class Constant {
|
||||
}
|
||||
|
||||
/// Calculate tax amount for a single tax model
|
||||
static double getTaxValue({required String amount, required TaxModel taxModel}) {
|
||||
static double getTaxValue({
|
||||
required String amount,
|
||||
required TaxModel taxModel,
|
||||
}) {
|
||||
double taxVal = 0.0;
|
||||
if (taxModel.enable == true) {
|
||||
if (taxModel.type == "fix") {
|
||||
taxVal = double.tryParse(taxModel.tax.toString()) ?? 0.0;
|
||||
} else {
|
||||
taxVal = (double.tryParse(amount) ?? 0.0) * (double.tryParse(taxModel.tax.toString()) ?? 0.0) / 100;
|
||||
taxVal =
|
||||
(double.tryParse(amount) ?? 0.0) *
|
||||
(double.tryParse(taxModel.tax.toString()) ?? 0.0) /
|
||||
100;
|
||||
}
|
||||
}
|
||||
return taxVal;
|
||||
@@ -743,10 +953,15 @@ class Constant {
|
||||
if (response.statusCode != 200) throw Exception("Failed to load image");
|
||||
|
||||
final Uint8List bytes = response.bodyBytes;
|
||||
final ui.Codec codec = await ui.instantiateImageCodec(bytes, targetWidth: width);
|
||||
final ui.Codec codec = await ui.instantiateImageCodec(
|
||||
bytes,
|
||||
targetWidth: width,
|
||||
);
|
||||
final ui.FrameInfo frameInfo = await codec.getNextFrame();
|
||||
|
||||
final ByteData? byteData = await frameInfo.image.toByteData(format: ui.ImageByteFormat.png);
|
||||
final ByteData? byteData = await frameInfo.image.toByteData(
|
||||
format: ui.ImageByteFormat.png,
|
||||
);
|
||||
return byteData!.buffer.asUint8List();
|
||||
} catch (e) {
|
||||
print("⚠️ getBytesFromUrl error: $e — using default cab icon");
|
||||
|
||||
Reference in New Issue
Block a user