Update: 2026-06-14 04:27:17
This commit is contained in:
@@ -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