revert(mobile): 回滚火柴人组件到稳定版本

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-24 03:00:52 -08:00
parent 27bee6d7f1
commit e2872b13fb
1 changed files with 125 additions and 124 deletions

View File

@ -8,7 +8,7 @@ class StickmanRankingData {
final String nickname;
final String? avatarUrl;
final int completedCount; //
final int targetCount; // (5/1)
final int targetCount; // (: 50000, : 10000)
final double monthlyEarnings; //
final bool isCurrentUser; //
final String? accountSequence; //
@ -25,10 +25,7 @@ class StickmanRankingData {
});
/// (0.0 - 1.0)
/// completedCount / targetCount 100%
double get progress => targetCount > 0
? (completedCount / targetCount).clamp(0.0, 1.0)
: 0.0;
double get progress => (completedCount / targetCount).clamp(0.0, 1.0);
}
///
@ -184,12 +181,8 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
return SizedBox(
height: raceTrackHeight,
child: LayoutBuilder(
builder: (context, constraints) {
final containerWidth = constraints.maxWidth;
// Positioned widgets
final List<Widget> children = [
child: Stack(
children: [
// 线
Positioned.fill(
child: CustomPaint(
@ -198,12 +191,11 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
),
),
),
];
//
for (int index = 0; index < trackCount; index++) {
//
...List.generate(trackCount, (index) {
final verticalPosition = index * trackHeight + 10 + trackHeight / 2 - 16;
children.add(Positioned(
return Positioned(
right: 8,
top: verticalPosition,
child: const Icon(
@ -211,63 +203,64 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
color: Colors.red,
size: 24,
),
));
}
//
for (int index = 0; index < sortedRankings.length; index++) {
final data = sortedRankings[index];
final widgets = _buildStickmanWidgets(data, index, sortedRankings.length, raceTrackHeight, containerWidth);
children.addAll(widgets);
}
return AnimatedBuilder(
animation: _bounceController,
builder: (context, child) {
return Stack(
clipBehavior: Clip.none,
children: children,
);
},
);
},
}),
//
...sortedRankings.asMap().entries.map((entry) {
final index = entry.key;
final data = entry.value;
return _buildStickman(data, index, sortedRankings.length, raceTrackHeight);
}),
],
),
);
}
/// Positioned widgets
List<Widget> _buildStickmanWidgets(StickmanRankingData data, int rank, int total, double raceTrackHeight, double containerWidth) {
// (0.0 - 1.0)
final progress = data.progress;
///
Widget _buildStickman(StickmanRankingData data, int rank, int total, double raceTrackHeight) {
// ()
final horizontalProgress = data.progress;
// ()
//
final usableHeight = raceTrackHeight - 40;
final trackHeight = usableHeight / total;
final verticalPosition = rank * trackHeight + 10;
// :
// = 70 ()
// = - = (containerWidth - 32) - 50 = containerWidth - 82
const double startX = 70.0;
final double endX = containerWidth - 82.0;
final double stickmanLeft = startX + (endX - startX) * progress;
return AnimatedBuilder(
animation: _bounceController,
builder: (context, child) {
//
final bounce = _bounceController.value * 3;
return [
// -
Positioned(
// - padding(32) - padding(32) - (40) - (30)
// 100%
final screenWidth = MediaQuery.of(context).size.width;
final containerWidth = screenWidth - 32 - 32; // padding + padding
final stickmanHalfWidth = 30.0; //
final flagAreaWidth = 40.0; // right:824+
final nicknameAreaWidth = 65.0; //
final availableWidth = containerWidth - flagAreaWidth - stickmanHalfWidth - nicknameAreaWidth;
final leftPosition = nicknameAreaWidth + availableWidth * horizontalProgress;
return Positioned(
left: 0,
top: verticalPosition + 15 - bounce,
child: SizedBox(
width: 65,
top: verticalPosition - bounce,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// -
SizedBox(
width: nicknameAreaWidth,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
decoration: BoxDecoration(
color: data.isCurrentUser
? const Color(0xFFD4AF37).withValues(alpha: 0.2)
: Colors.white.withValues(alpha: 0.8),
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(4),
border: data.isCurrentUser
? Border.all(color: const Color(0xFFD4AF37), width: 1)
: null,
@ -277,7 +270,8 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
style: TextStyle(
fontSize: 9,
fontFamily: 'Inter',
fontWeight: data.isCurrentUser ? FontWeight.w600 : FontWeight.w400,
fontWeight:
data.isCurrentUser ? FontWeight.w600 : FontWeight.w400,
color: data.isCurrentUser
? const Color(0xFFD4AF37)
: const Color(0xFF5D4037),
@ -287,12 +281,13 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
),
),
),
),
//
Positioned(
left: stickmanLeft,
top: verticalPosition - bounce,
child: Column(
SizedBox(
width: leftPosition - nicknameAreaWidth + stickmanHalfWidth * 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
//
@ -328,8 +323,14 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
),
],
),
],
),
];
),
],
),
);
},
);
}
///