|
|
|
|
@ -24,10 +24,10 @@ import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
|
|
|
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/loading_dialog.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/app_toast.dart';
|
|
|
|
|
import 'package:share_plus/share_plus.dart';
|
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
|
import 'package:toastification/toastification.dart';
|
|
|
|
|
|
|
|
|
|
class Utils {
|
|
|
|
|
static bool _isLoadingVisible = false;
|
|
|
|
|
@ -44,18 +44,20 @@ class Utils {
|
|
|
|
|
return 'https://ms.hmg.com/ad/${adDetails.id}?app=$appParam';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void showToast(String message) {
|
|
|
|
|
toastification.show(
|
|
|
|
|
type: ToastificationType.info,
|
|
|
|
|
style: ToastificationStyle.minimal,
|
|
|
|
|
title: Text(
|
|
|
|
|
message,
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
autoCloseDuration: const Duration(seconds: 3),
|
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
|
showProgressBar: false,
|
|
|
|
|
// Neutral styling for now -- existing call sites across the app were never written
|
|
|
|
|
// with a success/error distinction in mind (confirmed: plenty of messageStatus == 1
|
|
|
|
|
// success branches call this same function as the error branches), so defaulting to
|
|
|
|
|
// red/green here would mislabel most of them until those ~340 call sites are reviewed
|
|
|
|
|
// and updated individually to pass isSuccess explicitly.
|
|
|
|
|
static void showToast(String message, {bool isSuccess = false, VoidCallback? onComplete}) {
|
|
|
|
|
AppToast.show(
|
|
|
|
|
message,
|
|
|
|
|
seconds: onComplete != null ? AppToast.actionSeconds : AppToast.plainSeconds,
|
|
|
|
|
showIcon: onComplete != null,
|
|
|
|
|
showCountdownText: true,
|
|
|
|
|
bgColor: isSuccess ? AppToast.successBgColor : null,
|
|
|
|
|
textColor: isSuccess ? AppToast.successTextColor : null,
|
|
|
|
|
onComplete: onComplete,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -114,7 +116,11 @@ class Utils {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ("${timeOfDay.hour.toString().length == 1 ? "0" : ""}${timeOfDay.hour}:${timeOfDay.minute.toString().length == 1 ? "0" : ""}${timeOfDay.minute}").toString();
|
|
|
|
|
return ("${timeOfDay.hour
|
|
|
|
|
.toString()
|
|
|
|
|
.length == 1 ? "0" : ""}${timeOfDay.hour}:${timeOfDay.minute
|
|
|
|
|
.toString()
|
|
|
|
|
.length == 1 ? "0" : ""}${timeOfDay.minute}").toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dynamic getNotNullValue(List<dynamic> list, int index) {
|
|
|
|
|
@ -689,7 +695,7 @@ class Utils {
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: w, //
|
|
|
|
|
color: color // <--- border width here
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(radius),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -712,7 +718,7 @@ class Utils {
|
|
|
|
|
border: Border.all(
|
|
|
|
|
width: 1, //
|
|
|
|
|
color: color // <--- border width here
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(radius),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -730,7 +736,8 @@ class Utils {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String getAdsPaymentBrowserForm({required int paymentId, required int adId}) {
|
|
|
|
|
return '<html> <head></head><body><form id="paymentForm" action="${ApiConsts.paymentWebViewUrl}" method="post"><input type="hidden" name="PaymentType" value="$paymentId"><input type="hidden" name="AdsID" value="$adId"></form><script type="text/javascript"> document.getElementById("paymentForm").submit(); </script></body></html>';
|
|
|
|
|
return '<html> <head></head><body><form id="paymentForm" action="${ApiConsts
|
|
|
|
|
.paymentWebViewUrl}" method="post"><input type="hidden" name="PaymentType" value="$paymentId"><input type="hidden" name="AdsID" value="$adId"></form><script type="text/javascript"> document.getElementById("paymentForm").submit(); </script></body></html>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BOTTOM SHEETS
|
|
|
|
|
@ -791,18 +798,18 @@ class Utils {
|
|
|
|
|
|
|
|
|
|
switch (inviteTypeEnum) {
|
|
|
|
|
case InviteTypeEnum.whatsapp:
|
|
|
|
|
// WhatsApp requires a phone number and message, format like this:
|
|
|
|
|
// WhatsApp requires a phone number and message, format like this:
|
|
|
|
|
url = 'https://wa.me/?text=${Uri.encodeComponent(message)}';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InviteTypeEnum.sms:
|
|
|
|
|
// SMS: 'sms:<phone_number>?body=<message>'
|
|
|
|
|
// You can add a phone number, or keep it empty to allow the user to input one.
|
|
|
|
|
// SMS: 'sms:<phone_number>?body=<message>'
|
|
|
|
|
// You can add a phone number, or keep it empty to allow the user to input one.
|
|
|
|
|
url = 'sms:?body=${Uri.encodeComponent(message)}';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case InviteTypeEnum.email:
|
|
|
|
|
// Email: 'mailto:<email>?subject=<subject>&body=<message>'
|
|
|
|
|
// Email: 'mailto:<email>?subject=<subject>&body=<message>'
|
|
|
|
|
url = 'mailto:?subject=MowaterInvitation&body=${Uri.encodeComponent(message)}';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|