Update: 2026-06-14 04:27:17
This commit is contained in:
@@ -490,8 +490,8 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
|
||||
"inviterDriverPhone": formattedPhoneNumber,
|
||||
});
|
||||
|
||||
if (response != 'failure') {
|
||||
var d = (response);
|
||||
if (response != 'failure' && response is Map) {
|
||||
var d = response;
|
||||
mySnackbarSuccess('Invite sent successfully'.tr);
|
||||
String inviteCode = d['message']['inviteCode'].toString();
|
||||
String message = '${'*Siro DRIVER CODE*'.tr}\n\n'
|
||||
@@ -499,9 +499,10 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
|
||||
'${"To get a gift for both".tr}\n\n'
|
||||
'${"The period of this code is 24 hours".tr}\n\n'
|
||||
'${'before'.tr} *${d['message']['expirationTime'].toString()}*\n\n'
|
||||
'_*${inviteCode}*_\n\n'
|
||||
'${"Code:".tr} *${inviteCode}*\n\n'
|
||||
'${"Quick Invite Link:".tr}\n'
|
||||
'${AppLink.inviteRedirectUrl}?code=$inviteCode&app=driver';
|
||||
'${AppLink.inviteRedirectUrl}?code=$inviteCode&app=driver\n\n'
|
||||
'${"💡 Note: If the link above is not clickable, please save this contact or reply to this message to activate all links.".tr}';
|
||||
|
||||
launchCommunication('whatsapp', formattedPhoneNumber, message);
|
||||
invitePhoneController.clear();
|
||||
@@ -533,7 +534,7 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
|
||||
},
|
||||
);
|
||||
|
||||
if (response != 'failure') {
|
||||
if (response != 'failure' && response is Map) {
|
||||
var d = response;
|
||||
mySnackbarSuccess('Invite sent successfully'.tr);
|
||||
String inviteCode = d['message']['inviteCode'].toString();
|
||||
@@ -543,9 +544,10 @@ https://siromove.com/invite.php?code=$couponCode&app=rider
|
||||
'${"To get a gift for both".tr}\n\n'
|
||||
'${"The period of this code is 24 hours".tr}\n\n'
|
||||
'${'before'.tr} *${d['message']['expirationTime'].toString()}*\n\n'
|
||||
'_*${inviteCode}*_\n\n'
|
||||
'${"Code:".tr} *${inviteCode}*\n\n'
|
||||
'${"Quick Invite Link:".tr}\n'
|
||||
'${AppLink.inviteRedirectUrl}?code=$inviteCode&app=rider';
|
||||
'${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}';
|
||||
|
||||
launchCommunication('whatsapp', formattedPhoneNumber, message);
|
||||
invitePhoneController.clear();
|
||||
|
||||
@@ -5,6 +5,8 @@ import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
import 'package:siro_driver/views/widgets/error_snakbar.dart';
|
||||
|
||||
import '../../views/widgets/mycircular.dart';
|
||||
|
||||
class InvitesRewardsController extends GetxController {
|
||||
bool isLoading = false;
|
||||
String? referralCode;
|
||||
@@ -23,7 +25,7 @@ class InvitesRewardsController extends GetxController {
|
||||
update();
|
||||
|
||||
var res = await CRUD().get(link: AppLink.getDriverReferrals);
|
||||
|
||||
|
||||
if (res != 'failure' && res != 'token_expired' && res != 'no_internet') {
|
||||
try {
|
||||
var jsonData = jsonDecode(res);
|
||||
@@ -44,8 +46,9 @@ class InvitesRewardsController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> claimReward(int referralId, String claimType) async {
|
||||
Get.dialog(const Center(child: CircularProgressIndicator()), barrierDismissible: false);
|
||||
|
||||
Get.dialog(const Center(child: CircularProgressIndicator()),
|
||||
barrierDismissible: false);
|
||||
|
||||
var res = await CRUD().post(
|
||||
link: AppLink.claimDriverReward,
|
||||
payload: {
|
||||
@@ -76,28 +79,58 @@ class InvitesRewardsController extends GetxController {
|
||||
Future<void> claimUnifiedReward(int referralId) async {
|
||||
// Show dialog to choose wallet or cash
|
||||
Get.defaultDialog(
|
||||
title: "Choose Claim Method".tr,
|
||||
content: Text("How would you like to receive your reward?".tr),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
claimReward(referralId, 'wallet');
|
||||
},
|
||||
child: Text("Wallet".tr),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
claimReward(referralId, 'cash');
|
||||
},
|
||||
child: Text("Cash".tr),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text("Cancel".tr, style: TextStyle(color: Colors.red)),
|
||||
)
|
||||
]
|
||||
);
|
||||
title: "Choose Claim Method".tr,
|
||||
content: Text("How would you like to receive your reward?".tr),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
claimReward(referralId, 'wallet');
|
||||
},
|
||||
child: Text("Wallet".tr),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
claimReward(referralId, 'cash');
|
||||
},
|
||||
child: Text("Cash".tr),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Get.back(),
|
||||
child: Text("Cancel".tr, style: TextStyle(color: Colors.red)),
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> linkInviteCode(String inviteCode) async {
|
||||
Get.dialog(const Center(child: MyCircularProgressIndicator()),
|
||||
barrierDismissible: false);
|
||||
|
||||
try {
|
||||
var response =
|
||||
await CRUD().post(link: AppLink.addUnifiedInvite, payload: {
|
||||
"inviter_code": inviteCode,
|
||||
});
|
||||
|
||||
Get.back(); // close loading
|
||||
|
||||
if (response != 'failure') {
|
||||
var data = response is String ? jsonDecode(response) : response;
|
||||
if (data['status'] == 'success') {
|
||||
Get.snackbar("Success".tr, "You have been successfully referred!".tr,
|
||||
backgroundColor: Colors.green, colorText: Colors.white);
|
||||
await getReferralStats(); // Refresh stats
|
||||
} else {
|
||||
Get.snackbar(
|
||||
"Notice".tr, data['message'] ?? "Could not add invite".tr);
|
||||
}
|
||||
} else {
|
||||
Get.snackbar("Error".tr, "Network error occurred".tr);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.back(); // close loading
|
||||
Get.snackbar("Error".tr, "Network error occurred".tr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../constant/box_name.dart';
|
||||
import '../../../constant/colors.dart';
|
||||
import '../../../constant/links.dart';
|
||||
import '../../../controller/auth/captin/invit_controller.dart';
|
||||
import '../../../controller/functions/encrypt_decrypt.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../controller/home/invites_rewards_controller.dart';
|
||||
import '../../widgets/error_snakbar.dart';
|
||||
|
||||
class InviteScreen extends StatelessWidget {
|
||||
final InviteController controller = Get.put(InviteController());
|
||||
@@ -97,6 +101,9 @@ class InviteScreen extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildPermanentCodeCard(context),
|
||||
const SizedBox(height: 10),
|
||||
_buildManualCodeEntry(context),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
"Invite another driver and both get a gift after he completes 100 trips!"
|
||||
@@ -123,6 +130,10 @@ class InviteScreen 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(
|
||||
@@ -156,6 +167,164 @@ class InviteScreen 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: CupertinoColors.systemGrey6,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColor.blueColor.withOpacity(0.2)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Your Permanent Referral Code".tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: CupertinoColors.secondaryLabel,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
code,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.blueColor,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
if (rc.referralCode != null) ...[
|
||||
const SizedBox(width: 16),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(text: rc.referralCode!));
|
||||
mySnackbarSuccess('Code copied!'.tr);
|
||||
},
|
||||
child: const Icon(
|
||||
CupertinoIcons.doc_on_doc,
|
||||
color: AppColor.blueColor,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (rc.referralCode != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
CupertinoButton(
|
||||
color: AppColor.blueColor.withOpacity(0.1),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onPressed: () {
|
||||
final appName = 'Siro';
|
||||
final isDriver = controller.selectedTab == 0;
|
||||
final shareText = isDriver
|
||||
? 'Join $appName as a driver! Use my referral code: ${rc.referralCode}\nDownload: ${AppLink.inviteRedirectUrl}?code=${rc.referralCode}&app=driver\n\n💡 Note: If the link is not clickable, save this number or reply to activate links!'
|
||||
: '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: [
|
||||
const Icon(CupertinoIcons.share, color: AppColor.blueColor, size: 18),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Share via WhatsApp Groups'.tr,
|
||||
style: const TextStyle(
|
||||
color: AppColor.blueColor,
|
||||
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: CupertinoColors.systemGrey6,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Enter Inviter's Code".tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: CupertinoColors.label,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"If someone referred you, enter their code below to link accounts and receive rewards.".tr,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: CupertinoColors.secondaryLabel,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: CupertinoColors.systemGrey4),
|
||||
),
|
||||
child: CupertinoTextField.borderless(
|
||||
controller: manualCodeController,
|
||||
placeholder: 'Enter Code (e.g. AB1234)'.tr,
|
||||
padding: const EdgeInsets.all(10),
|
||||
textCapitalization: TextCapitalization.characters,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
CupertinoButton(
|
||||
color: AppColor.blueColor,
|
||||
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)),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPhoneInput() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -497,6 +666,7 @@ class InviteScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Widget _buildPassengerStats(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -559,6 +729,7 @@ class InviteScreen extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
void _showContactsDialog(BuildContext context) {
|
||||
showCupertinoModalPopup(
|
||||
|
||||
Reference in New Issue
Block a user