Update: 2026-05-08 02:22:45
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../controllers/referral_controller.dart';
|
||||
import '../../../core/utils/app_snackbar.dart';
|
||||
|
||||
@@ -29,23 +30,14 @@ class ReferralView extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
// Hero Banner
|
||||
_buildHeroBanner(controller, isDark),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Stats Cards
|
||||
_buildStatsRow(controller.stats, isDark),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Rewards Info
|
||||
_buildRewardsCard(controller.rewardRules, isDark),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// How it works
|
||||
_buildHowItWorks(isDark),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Recent referrals
|
||||
if (controller.recent.isNotEmpty) ...[
|
||||
_buildRecentReferrals(controller.recent, isDark),
|
||||
],
|
||||
@@ -92,53 +84,109 @@ class ReferralView extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
controller.code,
|
||||
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 3, fontFamily: 'monospace'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: controller.code));
|
||||
AppSnackbar.showSuccess('تم النسخ', 'تم نسخ رمز الإحالة');
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFD4AF37),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Icon(Icons.copy, size: 18, color: Colors.white),
|
||||
Expanded(
|
||||
child: Text(
|
||||
controller.code,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 26, fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 4, fontFamily: 'monospace'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Share link button
|
||||
// WhatsApp Share Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: controller.link));
|
||||
AppSnackbar.showSuccess('تم النسخ', 'تم نسخ رابط الإحالة');
|
||||
},
|
||||
icon: const Icon(Icons.share, size: 18),
|
||||
label: const Text('نسخ رابط الدعوة', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
onPressed: () => _shareViaWhatsApp(controller.code, controller.link),
|
||||
icon: const Icon(Icons.chat, size: 20),
|
||||
label: const Text('أرسل عبر واتساب', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15)),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFD4AF37),
|
||||
backgroundColor: const Color(0xFF25D366),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
elevation: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Copy Code + Copy Link Row
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: controller.code));
|
||||
AppSnackbar.showSuccess('تم النسخ', 'تم نسخ رمز الإحالة: ${controller.code}');
|
||||
},
|
||||
icon: const Icon(Icons.copy, size: 16),
|
||||
label: const Text('نسخ الرمز', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13)),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white.withValues(alpha: 0.2),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: controller.link));
|
||||
AppSnackbar.showSuccess('تم النسخ', 'تم نسخ رابط الدعوة');
|
||||
},
|
||||
icon: const Icon(Icons.link, size: 16),
|
||||
label: const Text('نسخ الرابط', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13)),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFD4AF37),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _shareViaWhatsApp(String code, String link) async {
|
||||
final message = Uri.encodeComponent(
|
||||
'مرحباً 👋\n\n'
|
||||
'أدعوك لتجربة تطبيق *مُصادَق* — أذكى نظام فوترة إلكتروني في الأردن 🇯🇴\n\n'
|
||||
'✅ استخراج الفواتير بالذكاء الاصطناعي\n'
|
||||
'✅ ربط مباشر مع جوفوترة\n'
|
||||
'✅ تقارير ضريبية جاهزة\n\n'
|
||||
'🎁 استخدم رمز الدعوة: *$code*\n'
|
||||
'واحصل على شهر مجاني!\n\n'
|
||||
'🔗 $link'
|
||||
);
|
||||
|
||||
final whatsappUrl = Uri.parse('https://wa.me/?text=$message');
|
||||
|
||||
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('واتساب غير متوفر', 'تم نسخ الرسالة — ألصقها يدوياً');
|
||||
}
|
||||
} catch (e) {
|
||||
Clipboard.setData(ClipboardData(text: Uri.decodeComponent(message)));
|
||||
AppSnackbar.showInfo('واتساب غير متوفر', 'تم نسخ الرسالة — ألصقها يدوياً');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildStatsRow(Map<String, dynamic> stats, bool isDark) {
|
||||
return Row(
|
||||
children: [
|
||||
@@ -236,7 +284,7 @@ class ReferralView extends StatelessWidget {
|
||||
children: [
|
||||
Text('كيف يعمل؟', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: isDark ? Colors.white : Colors.black87)),
|
||||
const SizedBox(height: 14),
|
||||
_stepItem('1', 'شارك رمز الإحالة مع زميلك', Icons.share, const Color(0xFF3B82F6), isDark),
|
||||
_stepItem('1', 'أرسل الرمز لصديقك عبر واتساب', Icons.chat, const Color(0xFF25D366), isDark),
|
||||
const SizedBox(height: 10),
|
||||
_stepItem('2', 'يسجّل في مُصادَق بالرمز', Icons.person_add, const Color(0xFF6366F1), isDark),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Reference in New Issue
Block a user