Update: 2026-06-10 02:44:54

This commit is contained in:
Hamza-Ayed
2026-06-10 02:44:55 +03:00
parent 9bc7a31c94
commit a0473a8b0f
134 changed files with 1706 additions and 544 deletions

View File

@@ -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)),
)
],
),
);
},
),
],
);
},
);
}
}