111
This commit is contained in:
@@ -355,6 +355,19 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
final referralRewards =
|
||||
_welfareData?['referralRewards'] as List<dynamic>? ?? [];
|
||||
|
||||
// 汇总统计
|
||||
int totalEarned = 0;
|
||||
int totalClaimable = 0;
|
||||
for (var r in referralRewards) {
|
||||
final map = r as Map<String, dynamic>;
|
||||
final milestones = map['milestones'] as List<dynamic>? ?? [];
|
||||
for (var m in milestones) {
|
||||
final ms = m as Map<String, dynamic>;
|
||||
if (ms['claimed'] as bool? ?? false) totalEarned++;
|
||||
if (ms['claimable'] as bool? ?? false) totalClaimable++;
|
||||
}
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -370,6 +383,29 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
color: context.appColors.onSurfaceMuted,
|
||||
),
|
||||
),
|
||||
// 汇总统计
|
||||
if (referralRewards.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: AppSpacing.sm),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
border: Border.all(color: context.appColors.ghostBorder),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildStatItem('已邀请', '${referralRewards.length}人'),
|
||||
Container(width: 1, height: 20, color: context.appColors.ghostBorder),
|
||||
_buildStatItem('已获得', '${totalEarned * 100} USDT'),
|
||||
if (totalClaimable > 0) ...[
|
||||
Container(width: 1, height: 20, color: context.appColors.ghostBorder),
|
||||
_buildStatItem('待领取', '$totalClaimable个', highlight: true),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 推广列表卡片
|
||||
@@ -384,6 +420,23 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatItem(String label, String value, {bool highlight = false}) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(label, style: AppTextStyles.bodySmall(context).copyWith(
|
||||
color: context.colors.onSurfaceVariant,
|
||||
)),
|
||||
const SizedBox(height: 2),
|
||||
Text(value, style: AppTextStyles.headlineSmall(context).copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: highlight ? context.appColors.up : context.colors.onSurface,
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyReferralList(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
@@ -416,6 +469,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
final totalDeposit = data['totalDeposit']?.toString() ?? '0';
|
||||
final claimableCount = data['claimableCount'] as int? ?? 0;
|
||||
final milestones = data['milestones'] as List<dynamic>? ?? [];
|
||||
final userId = data['userId'] as int? ?? 0;
|
||||
final isLast = index == referralRewards.length - 1;
|
||||
|
||||
// 进度计算
|
||||
@@ -446,7 +500,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
Text(
|
||||
username,
|
||||
style: AppTextStyles.headlineSmall(context).copyWith(
|
||||
fontWeight: FontWeight.w500, // 添加 w500
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
@@ -472,6 +526,11 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// 里程碑详情
|
||||
if (milestones.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildMilestoneDetails(milestones, userId),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -487,6 +546,66 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 里程碑详情行 — 显示每个里程碑状态
|
||||
Widget _buildMilestoneDetails(List<dynamic> milestones, int userId) {
|
||||
final upColor = context.appColors.up;
|
||||
|
||||
return Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 6,
|
||||
children: milestones.map((m) {
|
||||
final ms = m as Map<String, dynamic>;
|
||||
final milestoneVal = ms['milestone'] as int? ?? 1;
|
||||
final earned = ms['earned'] as bool? ?? false;
|
||||
final claimed = ms['claimed'] as bool? ?? false;
|
||||
final claimable = ms['claimable'] as bool? ?? false;
|
||||
final threshold = ms['threshold']?.toString() ?? '${milestoneVal * 1000}';
|
||||
|
||||
Color bgColor;
|
||||
Color textColor;
|
||||
String label;
|
||||
|
||||
if (claimed) {
|
||||
bgColor = upColor.withValues(alpha: 0.1);
|
||||
textColor = upColor;
|
||||
label = '${threshold}✓';
|
||||
} else if (claimable) {
|
||||
bgColor = context.appColors.accentPrimary.withValues(alpha: 0.15);
|
||||
textColor = context.appColors.accentPrimary;
|
||||
label = '${threshold}🎁';
|
||||
} else if (earned) {
|
||||
bgColor = upColor.withValues(alpha: 0.06);
|
||||
textColor = upColor;
|
||||
label = '${threshold}';
|
||||
} else {
|
||||
bgColor = context.appColors.surfaceCardHigh;
|
||||
textColor = context.colors.onSurfaceVariant;
|
||||
label = '${threshold}';
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onTap: claimable ? () => _claimReferralBonus(userId, milestoneVal) : null,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
border: claimable ? Border.all(color: textColor.withValues(alpha: 0.3)) : null,
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: AppTextStyles.bodySmall(context).copyWith(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: textColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAvatar(String username) {
|
||||
return Container(
|
||||
width: 32,
|
||||
|
||||
Reference in New Issue
Block a user