factor:布局颜色重构

This commit is contained in:
2025-11-21 14:11:35 +08:00
parent 8f0f641d37
commit e38e26e685
18 changed files with 572 additions and 179 deletions

View File

@@ -283,3 +283,67 @@ Widget pieChart({
],
);
}
Color _getRankColor(BuildContext context, int index) {
switch (index) {
case 0: // 金牌
return const Color(0xFFFFD700); // 标准金色
case 1: // 银牌
return const Color(0xFFC0C0C0); // 标准银色
case 2: // 铜牌
return const Color(0xFFCD7F32); // 标准铜色
default:
return Theme.of(context).colorScheme.onSurface; // 普通颜色
}
}
Widget rankChart({
required BuildContext context,
required String unit,
required List<ChartData> data,
}) {
return ListView.builder(
itemCount: data.length,
itemBuilder: (context, index) {
final item = data[index];
final rank = index + 1;
return SizedBox(
height: 35,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 25,
alignment: Alignment.center,
child: Text(
'$rank.',
style: TextStyle(
fontWeight: FontWeight.bold,
color: _getRankColor(context, index),
),
),
),
Text(
item.name,
style: TextStyle(
fontWeight: index < 3 ? FontWeight.bold : FontWeight.normal,
color: _getRankColor(context, index),
),
),
],
),
Text(
'${item.value.toStringAsFixed(0)} $unit',
style: TextStyle(
fontWeight: index < 3 ? FontWeight.bold : FontWeight.normal,
color: _getRankColor(context, index),
),
),
],
),
);
},
);
}