Update: 2026-05-08 02:25:00

This commit is contained in:
Hamza-Ayed
2026-05-08 02:25:00 +03:00
parent 189382e065
commit 4721ca83da
6 changed files with 89 additions and 64 deletions

View File

@@ -160,7 +160,7 @@ class ReferralView extends StatelessWidget {
}
void _shareViaWhatsApp(String code, String link) async {
final message = Uri.encodeComponent(
final rawMessage =
'مرحباً 👋\n\n'
'أدعوك لتجربة تطبيق *مُصادَق* — أذكى نظام فوترة إلكتروني في الأردن 🇯🇴\n\n'
'✅ استخراج الفواتير بالذكاء الاصطناعي\n'
@@ -168,23 +168,28 @@ class ReferralView extends StatelessWidget {
'✅ تقارير ضريبية جاهزة\n\n'
'🎁 استخدم رمز الدعوة: *$code*\n'
'واحصل على شهر مجاني!\n\n'
'🔗 $link'
);
'🔗 $link';
final whatsappUrl = Uri.parse('https://wa.me/?text=$message');
final encodedMessage = Uri.encodeComponent(rawMessage);
try {
if (await canLaunchUrl(whatsappUrl)) {
await launchUrl(whatsappUrl, mode: LaunchMode.externalApplication);
} else {
// Fallback — copy to clipboard
Clipboard.setData(ClipboardData(text: Uri.decodeComponent(message)));
AppSnackbar.showInfo('واتساب غير متوفر', 'تم نسخ الرسالة — ألصقها يدوياً');
// Try multiple approaches for WhatsApp
final urls = [
Uri.parse('whatsapp://send?text=$encodedMessage'),
Uri.parse('https://wa.me/?text=$encodedMessage'),
];
for (final url in urls) {
try {
final launched = await launchUrl(url, mode: LaunchMode.externalApplication);
if (launched) return; // Success!
} catch (_) {
continue; // Try next URL
}
} catch (e) {
Clipboard.setData(ClipboardData(text: Uri.decodeComponent(message)));
AppSnackbar.showInfo('واتساب غير متوفر', 'تم نسخ الرسالة — ألصقها يدوياً');
}
// All failed — copy to clipboard
Clipboard.setData(ClipboardData(text: rawMessage));
AppSnackbar.showSuccess('تم نسخ الرسالة', 'ألصقها في واتساب أو أي تطبيق مراسلة');
}
Widget _buildStatsRow(Map<String, dynamic> stats, bool isDark) {