Update: 2026-06-14 04:27:17
This commit is contained in:
@@ -40,21 +40,21 @@ class DeepLinkController extends GetxController {
|
||||
}
|
||||
|
||||
void _processInviteCode(Uri uri) {
|
||||
if (uri.queryParameters.containsKey('inviteCode')) {
|
||||
String? inviteCode = uri.queryParameters['inviteCode'];
|
||||
if (inviteCode != null && inviteCode.isNotEmpty) {
|
||||
// دائماً نخزن الكود حتى لو لم يكن مسجلاً، ليتم استخدامه بعد التسجيل
|
||||
box.write('inviteCode', inviteCode);
|
||||
String? inviteCode = uri.queryParameters['code'] ??
|
||||
uri.queryParameters['inviteCode'] ??
|
||||
uri.queryParameters['ref'];
|
||||
if (inviteCode != null && inviteCode.isNotEmpty) {
|
||||
// دائماً نخزن الكود حتى لو لم يكن مسجلاً، ليتم استخدامه بعد التسجيل
|
||||
box.write('inviteCode', inviteCode);
|
||||
|
||||
// إذا كان المستخدم مسجل دخول (يمتلك JWT)، نربط الدعوة فوراً
|
||||
if (box.read('jwt') != null) {
|
||||
try {
|
||||
var rewardsController = Get.find<InvitesRewardsController>();
|
||||
rewardsController.linkInviteCode(inviteCode);
|
||||
} catch (e) {
|
||||
var rewardsController = Get.put(InvitesRewardsController());
|
||||
rewardsController.linkInviteCode(inviteCode);
|
||||
}
|
||||
// إذا كان المستخدم مسجل دخول (يمتلك JWT)، نربط الدعوة فوراً
|
||||
if (box.read('jwt') != null) {
|
||||
try {
|
||||
var rewardsController = Get.find<InvitesRewardsController>();
|
||||
rewardsController.linkInviteCode(inviteCode);
|
||||
} catch (e) {
|
||||
var rewardsController = Get.put(InvitesRewardsController());
|
||||
rewardsController.linkInviteCode(inviteCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ ${AppLink.inviteRedirectUrl}?code=$couponCode&app=rider
|
||||
"inviterPassengerPhone": formattedPhoneNumber,
|
||||
});
|
||||
|
||||
if (response != 'failure') {
|
||||
if (response != 'failure' && response is Map) {
|
||||
var d = response;
|
||||
Get.snackbar('Success'.tr, 'Invite sent successfully'.tr,
|
||||
backgroundColor: Colors.green, colorText: Colors.white);
|
||||
@@ -252,6 +252,7 @@ ${AppLink.inviteRedirectUrl}?code=$couponCode&app=rider
|
||||
"⏳ ${'Be sure to use it quickly! This code expires at'.tr} *$expirationTime*.\n\n"
|
||||
"🔗 ${'Quick Invite Link:'.tr}\n"
|
||||
"${AppLink.inviteRedirectUrl}?code=$inviteCode&app=rider\n\n"
|
||||
"💡 ${'Note: If the link above is not clickable, please save this contact or reply to this message to activate all links.'.tr}\n\n"
|
||||
"${'See you on the road!'.tr} 🚗";
|
||||
|
||||
launchCommunication('whatsapp', formattedPhoneNumber, message);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/links.dart';
|
||||
@@ -8,6 +10,7 @@ import '../../../constant/style.dart';
|
||||
import '../../../controller/home/profile/invit_controller.dart';
|
||||
import '../../../controller/home/profile/invites_rewards_controller.dart';
|
||||
import '../../../print.dart';
|
||||
import '../../widgets/error_snakbar.dart';
|
||||
|
||||
class ShareAppPage extends StatelessWidget {
|
||||
final InviteController controller = Get.put(InviteController());
|
||||
@@ -53,6 +56,10 @@ class ShareAppPage extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildPermanentCodeCard(context),
|
||||
const SizedBox(height: 10),
|
||||
_buildManualCodeEntry(context),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -680,4 +687,161 @@ class ShareAppPage extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPermanentCodeCard(BuildContext context) {
|
||||
return GetBuilder<InvitesRewardsController>(
|
||||
builder: (rc) {
|
||||
String code = rc.referralCode ?? 'Loading...'.tr;
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
margin: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.grayColor.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColor.cyanBlue.withOpacity(0.2)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Your Permanent Referral Code".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColor.grayColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
code,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.cyanBlue,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
if (rc.referralCode != null) ...[
|
||||
const SizedBox(width: 16),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: rc.referralCode!));
|
||||
mySnackbarSuccess('Code copied!'.tr);
|
||||
},
|
||||
child: Icon(
|
||||
CupertinoIcons.doc_on_doc,
|
||||
color: AppColor.cyanBlue,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (rc.referralCode != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
CupertinoButton(
|
||||
color: AppColor.cyanBlue.withOpacity(0.1),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onPressed: () {
|
||||
final appName = 'Siro';
|
||||
final shareText = 'Get a ride with $appName! Use my referral code: ${rc.referralCode} for a discount.\nDownload: ${AppLink.inviteRedirectUrl}?code=${rc.referralCode}&app=rider\n\n💡 Note: If the link is not clickable, save this number or reply to activate links!';
|
||||
Share.share(shareText);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(CupertinoIcons.share, color: AppColor.cyanBlue, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Share via WhatsApp Groups'.tr,
|
||||
style: TextStyle(
|
||||
color: AppColor.cyanBlue,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildManualCodeEntry(BuildContext context) {
|
||||
final TextEditingController manualCodeController = TextEditingController();
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
margin: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.grayColor.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Enter Inviter's Code".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.writeColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"If someone referred you, enter their code below to link accounts and receive rewards.".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColor.grayColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.secondaryColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.grayColor.withOpacity(0.2)),
|
||||
),
|
||||
child: CupertinoTextField.borderless(
|
||||
controller: manualCodeController,
|
||||
placeholder: 'Enter Code (e.g. AB1234)'.tr,
|
||||
placeholderStyle: TextStyle(color: AppColor.grayColor.withOpacity(0.5)),
|
||||
style: TextStyle(color: AppColor.writeColor),
|
||||
padding: const EdgeInsets.all(10),
|
||||
textCapitalization: TextCapitalization.characters,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
CupertinoButton(
|
||||
color: AppColor.cyanBlue,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onPressed: () {
|
||||
if (manualCodeController.text.trim().isNotEmpty) {
|
||||
rewardsController.linkInviteCode(manualCodeController.text.trim());
|
||||
manualCodeController.clear();
|
||||
} else {
|
||||
mySnackeBarError('Please enter a referral code'.tr);
|
||||
}
|
||||
},
|
||||
child: Text('Link'.tr, style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user