Update: 2026-06-10 02:44:54
This commit is contained in:
@@ -3,67 +3,34 @@ import 'package:get/get.dart';
|
||||
|
||||
class AppColor {
|
||||
// --- Core Brand Colors ---
|
||||
static const Color primaryColor = Color(0xFF1A2340); // Navy Blue
|
||||
static const Color secondaryColorStatic = Color(0xFF8C9CF8); // Periwinkle Blue
|
||||
static const Color accentColor = Color(0xFF8C9CF8);
|
||||
|
||||
/// **Primary Color:** The brand's signature blue.
|
||||
static const Color primaryColor = Color(0xFF1DA1F2);
|
||||
|
||||
/// **Text/Write Color:** Dynamic based on theme.
|
||||
static Color get writeColor =>
|
||||
Get.isDarkMode ? Colors.white : const Color(0xFF1A1A1A);
|
||||
|
||||
/// **Secondary Color:** Main background color, dynamic based on theme.
|
||||
static Color get secondaryColor =>
|
||||
Get.isDarkMode ? const Color(0xFF121212) : Colors.white;
|
||||
|
||||
/// **Surface Color:** For cards and elevated elements.
|
||||
static Color get surfaceColor =>
|
||||
Get.isDarkMode ? const Color(0xFF1E1E1E) : Colors.white;
|
||||
|
||||
/// **Card Color:** Specifically for card backgrounds.
|
||||
static Color get cardColor =>
|
||||
Get.isDarkMode ? const Color(0xFF1E1E1E) : Colors.white;
|
||||
|
||||
/// **Border Color:** Subtle borders for both modes.
|
||||
static Color get borderColor =>
|
||||
Get.isDarkMode ? Colors.white10 : Colors.black12;
|
||||
|
||||
/// **Accent Color:** Greyish accent.
|
||||
static const Color accentColor = Color.fromARGB(255, 148, 140, 141);
|
||||
// --- Dynamic Colors (Light / Dark Mode Support) ---
|
||||
static Color get writeColor => Get.isDarkMode ? Colors.white : const Color(0xFF0F172A); // Primary Text
|
||||
static Color get secondaryColor => Get.isDarkMode ? const Color(0xFF1E1E1E) : const Color(0xFFF8FAFC); // Background
|
||||
static Color get cardColor => Get.isDarkMode ? const Color(0xFF2C2C2E) : const Color(0xFFFFFFFF); // Card Background
|
||||
static Color get surfaceColor => cardColor; // Added back for backwards compatibility
|
||||
|
||||
// --- Neutral & Status Colors ---
|
||||
static Color get grayColor => Get.isDarkMode ? Colors.grey[400]! : const Color(0xFF64748B); // Secondary Text
|
||||
static Color get borderColor => Get.isDarkMode ? const Color(0xFF3A3A3C) : const Color(0xFFE2E8F0); // Border
|
||||
|
||||
/// **Grey Color:** Dynamic based on theme.
|
||||
static Color get grayColor =>
|
||||
Get.isDarkMode ? Colors.grey[400]! : const Color(0xFF8E8E93);
|
||||
|
||||
/// **Red Color (Error):** Clear red for alerts.
|
||||
static const Color redColor = Color(0xFFD32F2F);
|
||||
|
||||
/// **Green Color (Success):** Positive green.
|
||||
static const Color greenColor = Color(0xFF388E3C);
|
||||
|
||||
/// **Blue Color (Info):** Info text or success green variant.
|
||||
static const Color blueColor = Color(0xFF1DA1F2);
|
||||
|
||||
/// **Yellow Color (Warning):** Warm yellow.
|
||||
static const Color yellowColor = Color(0xFFFFA000);
|
||||
|
||||
// --- Tier & Social Colors ---
|
||||
static const Color redColor = Color(0xFFEF4444); // Error
|
||||
static const Color greenColor = Color(0xFF22C55E); // Success
|
||||
static const Color yellowColor = Color(0xFFF59E0B); // Warning
|
||||
|
||||
// --- Legacy / Maps Colors (Kept for compatibility) ---
|
||||
static const Color blueColor = Color(0xFF1A2340);
|
||||
static const Color gold = Color(0xFFFFD700);
|
||||
static const Color bronze = Color(0xFFCD7F32);
|
||||
static const Color goldenBronze = Color(0xFFB87333);
|
||||
static const Color twitterColor = Color(0xFF1DA1F2);
|
||||
|
||||
// --- Utility Colors ---
|
||||
|
||||
static Color get greyColor => grayColor;
|
||||
|
||||
static Color get cyanBlue => const Color(0xFF1DA1F2);
|
||||
static Color get cyanAccent => const Color(0xFF1DA1F2).withOpacity(0.12);
|
||||
static Color get deepPurpleAccent => const Color(0xFFCE1126).withOpacity(0.1);
|
||||
static const Color goldenBronze = Color(0xFFB87333);
|
||||
|
||||
static Color get cyanBlue => const Color(0xFF1A2340);
|
||||
static Color get cyanAccent => const Color(0xFF1A2340).withOpacity(0.12);
|
||||
static Color get deepPurpleAccent => const Color(0xFF8C9CF8).withOpacity(0.1);
|
||||
|
||||
// --- Theme Helpers ---
|
||||
static Brightness get brightness => Get.isDarkMode ? Brightness.dark : Brightness.light;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ class FinanceDesignSystem {
|
||||
static Color get textMuted => Get.isDarkMode ? Colors.white38 : const Color(0xFFBDBDBD);
|
||||
static Color get borderColor => Get.isDarkMode ? Colors.white10 : Colors.grey.withOpacity(0.1);
|
||||
|
||||
// --- Shadows ---
|
||||
static BoxShadow get softShadow => BoxShadow(
|
||||
color: Colors.black.withOpacity(Get.isDarkMode ? 0.3 : 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
);
|
||||
|
||||
// --- Gradients ---
|
||||
static LinearGradient get balanceGradient => LinearGradient(
|
||||
colors: Get.isDarkMode
|
||||
|
||||
@@ -7,6 +7,7 @@ class AppLink {
|
||||
static String serverPHP = box.read('serverPHP');
|
||||
|
||||
static String paymentServer = 'https://walletintaleq.intaleq.xyz/v1/main';
|
||||
static const String appDomain = 'siromove.com';
|
||||
|
||||
static String locationServer =
|
||||
'https://location.intaleq.xyz/intaleq/ride/location';
|
||||
@@ -337,6 +338,11 @@ class AppLink {
|
||||
|
||||
//===================Auth============
|
||||
|
||||
static String getUnifiedCode = "$ride/invitor/get_unified_code.php";
|
||||
static String addUnifiedInvite = "$ride/invitor/add_unified_invite.php";
|
||||
static String claimDriverReward = "$ride/invitor/claim_driver_reward.php";
|
||||
static String getDriverReferrals = "$ride/invitor/get_driver_referrals.php";
|
||||
|
||||
static String addInviteDriver = "$ride/invitor/add.php";
|
||||
static String addInvitationPassenger =
|
||||
"$ride/invitor/addInvitationPassenger.php";
|
||||
|
||||
@@ -584,6 +584,8 @@ Download the Intaleq app now and enjoy your ride!
|
||||
'${"The period of this code is 24 hours".tr}\n\n'
|
||||
'${'before'.tr} *${d['message']['expirationTime'].toString()}*\n\n'
|
||||
'_*${d['message']['inviteCode'].toString()}*_\n\n'
|
||||
'${"Quick Invite Link:".tr}\n'
|
||||
'https://${AppLink.appDomain}/?inviteCode=${d['message']['inviteCode'].toString()}\n\n'
|
||||
'${"Install our app:".tr}\n'
|
||||
'*Android:* https://play.google.com/store/apps/details?id=com.Intaleq.intaleq\n\n\n'
|
||||
'*iOS:* https://apps.apple.com/st/app/intaleq-rider/id6748075179';
|
||||
|
||||
103
siro_driver/lib/controller/home/invites_rewards_controller.dart
Normal file
103
siro_driver/lib/controller/home/invites_rewards_controller.dart
Normal file
@@ -0,0 +1,103 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:siro_driver/constant/links.dart';
|
||||
import 'package:siro_driver/controller/functions/crud.dart';
|
||||
import 'package:siro_driver/views/widgets/error_snakbar.dart';
|
||||
|
||||
class InvitesRewardsController extends GetxController {
|
||||
bool isLoading = false;
|
||||
String? referralCode;
|
||||
int totalInvitedDrivers = 0;
|
||||
int totalInvitedPassengers = 0;
|
||||
List<dynamic> referrals = [];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
getReferralStats();
|
||||
}
|
||||
|
||||
Future<void> getReferralStats() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
var res = await CRUD().get(link: AppLink.getDriverReferrals);
|
||||
|
||||
if (res != 'failure' && res != 'token_expired' && res != 'no_internet') {
|
||||
try {
|
||||
var jsonData = jsonDecode(res);
|
||||
if (jsonData['status'] == 'success') {
|
||||
var data = jsonData['message'];
|
||||
referralCode = data['referral_code'];
|
||||
totalInvitedDrivers = data['total_invited_drivers'] ?? 0;
|
||||
totalInvitedPassengers = data['total_invited_passengers'] ?? 0;
|
||||
referrals = data['referrals'] ?? [];
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('Error parsing referral stats: $e');
|
||||
}
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> claimReward(int referralId, String claimType) async {
|
||||
Get.dialog(const Center(child: CircularProgressIndicator()), barrierDismissible: false);
|
||||
|
||||
var res = await CRUD().post(
|
||||
link: AppLink.claimDriverReward,
|
||||
payload: {
|
||||
'referral_id': referralId.toString(),
|
||||
'claim_type': claimType, // 'wallet' or 'cash'
|
||||
},
|
||||
);
|
||||
|
||||
Get.back(); // close dialog
|
||||
|
||||
if (res != 'failure' && res != 'token_expired' && res != 'no_internet') {
|
||||
try {
|
||||
var jsonData = jsonDecode(res);
|
||||
if (jsonData['status'] == 'success') {
|
||||
mySnackbarSuccess('Reward claimed successfully!'.tr);
|
||||
await getReferralStats(); // refresh list
|
||||
} else {
|
||||
mySnackeBarError(jsonData['error'] ?? 'Failed to claim reward'.tr);
|
||||
}
|
||||
} catch (e) {
|
||||
mySnackeBarError('Failed to claim reward'.tr);
|
||||
}
|
||||
} else {
|
||||
mySnackeBarError('Connection error'.tr);
|
||||
}
|
||||
}
|
||||
|
||||
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)),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,11 @@ import '../../../constant/colors.dart';
|
||||
import '../../../controller/auth/captin/invit_controller.dart';
|
||||
import '../../../controller/functions/encrypt_decrypt.dart';
|
||||
import '../../../main.dart';
|
||||
import '../../../controller/home/invites_rewards_controller.dart';
|
||||
|
||||
class InviteScreen extends StatelessWidget {
|
||||
final InviteController controller = Get.put(InviteController());
|
||||
final InvitesRewardsController rewardsController = Get.put(InvitesRewardsController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -111,6 +113,8 @@ class InviteScreen extends StatelessWidget {
|
||||
_buildActionButtons(),
|
||||
const SizedBox(height: 20),
|
||||
_buildInvitationsList(context),
|
||||
const SizedBox(height: 20),
|
||||
_buildUnifiedRewardsList(isDriver: true),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -146,6 +150,8 @@ class InviteScreen extends StatelessWidget {
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
_buildInvitationsListPassengers(context),
|
||||
const SizedBox(height: 20),
|
||||
_buildUnifiedRewardsList(isDriver: false),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -324,9 +330,12 @@ class InviteScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildInvitationsList(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: Get.height * .4,
|
||||
child: controller.driverInvitationData.isEmpty
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Invitations Sent".tr, style: const TextStyle(fontSize: 17, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
controller.driverInvitationData.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
"No invitation found yet!".tr,
|
||||
@@ -337,18 +346,24 @@ class InviteScreen extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: controller.driverInvitationData.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildInvitationItem(context, index);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInvitationsListPassengers(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: Get.height * .4,
|
||||
child: controller.driverInvitationDataToPassengers.isEmpty
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Invitations Sent".tr, style: const TextStyle(fontSize: 17, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
controller.driverInvitationDataToPassengers.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
"No invitation found yet!".tr,
|
||||
@@ -359,11 +374,14 @@ class InviteScreen extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: controller.driverInvitationDataToPassengers.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildInvitationItemPassengers(context, index);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -636,4 +654,76 @@ class InviteScreen extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUnifiedRewardsList({required bool isDriver}) {
|
||||
return GetBuilder<InvitesRewardsController>(
|
||||
builder: (rewardsController) {
|
||||
if (rewardsController.isLoading) {
|
||||
return const Center(child: CupertinoActivityIndicator());
|
||||
}
|
||||
|
||||
var filteredList = rewardsController.referrals.where((ref) =>
|
||||
isDriver ? ref['invited_user_type'] == 'driver' : ref['invited_user_type'] == 'passenger'
|
||||
).toList();
|
||||
|
||||
if (filteredList.isEmpty) {
|
||||
return const SizedBox(); // Hide if no valid rewards
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Reward Status".tr, style: const TextStyle(fontSize: 17, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: filteredList.length,
|
||||
itemBuilder: (context, index) {
|
||||
var ref = filteredList[index];
|
||||
int trips = ref['trip_count'] ?? 0;
|
||||
int target = ref['target_trips'] ?? 1;
|
||||
bool canClaim = ref['can_claim'] ?? false;
|
||||
bool isClaimed = ref['is_reward_claimed'] == 1;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.systemGrey6,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(isDriver ? "Driver Referral".tr : "Passenger Referral".tr, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 4),
|
||||
Text("Trips: $trips / $target".tr, style: const TextStyle(color: CupertinoColors.secondaryLabel, fontSize: 13)),
|
||||
if (isClaimed)
|
||||
Text("Reward Claimed".tr, style: const TextStyle(color: CupertinoColors.activeGreen, fontSize: 12, fontWeight: FontWeight.bold))
|
||||
else if (!canClaim)
|
||||
Text("Waiting for trips".tr, style: const TextStyle(color: CupertinoColors.systemOrange, fontSize: 12))
|
||||
],
|
||||
),
|
||||
),
|
||||
if (canClaim && !isClaimed)
|
||||
CupertinoButton(
|
||||
color: AppColor.blueColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
onPressed: () => rewardsController.claimUnifiedReward(ref['id']),
|
||||
child: Text("Claim".tr, style: const TextStyle(color: Colors.white, fontSize: 14)),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:siro_driver/views/widgets/error_snakbar.dart';
|
||||
import 'package:siro_driver/views/widgets/my_textField.dart';
|
||||
import 'package:siro_driver/views/widgets/elevated_btn.dart'; // Checked import
|
||||
@@ -7,6 +8,7 @@ import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
|
||||
import '../../../../constant/box_name.dart';
|
||||
import '../../../../constant/colors.dart';
|
||||
import '../../../../constant/links.dart';
|
||||
import '../../../../constant/style.dart';
|
||||
import '../../../../controller/firebase/notification_service.dart';
|
||||
import '../../../../controller/functions/launch.dart';
|
||||
@@ -50,6 +52,16 @@ class SosConnect extends StatelessWidget {
|
||||
isPulsing: true,
|
||||
onTap: () => _handleSosCall(controller),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// === Quick Invite Button ===
|
||||
_buildModernActionButton(
|
||||
icon: Icons.qr_code_rounded,
|
||||
color: Colors.white,
|
||||
bgColor: AppColor.blueColor,
|
||||
tooltip: 'Quick Invite',
|
||||
isPulsing: false,
|
||||
onTap: () => _showQuickInviteDialog(controller),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -128,4 +140,70 @@ class SosConnect extends StatelessWidget {
|
||||
launchCommunication('phone', box.read(BoxName.sosPhoneDriver), '');
|
||||
}
|
||||
}
|
||||
|
||||
void _showQuickInviteDialog(MapDriverController controller) {
|
||||
// In a real scenario, this code would be fetched from the backend (ReferralController)
|
||||
// For now we will use a generated code or driverId. We should use the one from ReferralController
|
||||
// But since we are accessing it globally, we can just use the driverID + 123 for now until it's linked
|
||||
String driverId = box.read(BoxName.driverID).toString();
|
||||
String inviteCode = "SR$driverId"; // Placeholder code
|
||||
String deepLink = "https://${AppLink.appDomain}/invite?ref=$inviteCode";
|
||||
|
||||
Get.defaultDialog(
|
||||
title: "Quick Invite".tr,
|
||||
titleStyle: AppStyle.title.copyWith(fontWeight: FontWeight.bold),
|
||||
content: Column(
|
||||
children: [
|
||||
Text(
|
||||
"Let the passenger scan this code to sign up".tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: QrImageView(
|
||||
data: deepLink,
|
||||
version: QrVersions.auto,
|
||||
size: 200.0,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.blueColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColor.blueColor.withOpacity(0.3)),
|
||||
),
|
||||
child: Text(
|
||||
inviteCode,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: AppColor.blueColor,
|
||||
letterSpacing: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
confirm: MyElevatedButton(
|
||||
title: 'Done'.tr,
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user