diff --git a/lib/widgets/leetcode_card.dart b/lib/widgets/leetcode_card.dart index e7de190..6d52580 100644 --- a/lib/widgets/leetcode_card.dart +++ b/lib/widgets/leetcode_card.dart @@ -12,7 +12,10 @@ class LeetCodeCard extends StatefulWidget { State createState() => _LeetCodeCardState(); } -class _LeetCodeCardState extends State { +class _LeetCodeCardState extends State + with SingleTickerProviderStateMixin { + late AnimationController _refreshController; + List _submissions = []; Map? _progress; bool _isLoading = false; @@ -118,6 +121,10 @@ class _LeetCodeCardState extends State { void initState() { super.initState(); _fetchData(); + _refreshController = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 500), + ); } Widget _buildProgressCard() { @@ -135,7 +142,7 @@ class _LeetCodeCardState extends State { children: [ const Text( '解题进度', - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), const SizedBox(height: 8), ...acceptedQuestions.map((q) { @@ -153,8 +160,13 @@ class _LeetCodeCardState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text('击败用户'), - Text('${totalBeatsPercentage.toStringAsFixed(1)}%'), + const Text('击败用户', + style: TextStyle(fontWeight: FontWeight.bold)), + Text('${totalBeatsPercentage.toStringAsFixed(1)}%', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + color: Colors.green)), ], ), ], @@ -176,19 +188,34 @@ class _LeetCodeCardState extends State { children: [ const Text( 'LeetCode 最近提交', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), - IconButton( - icon: const Icon(Icons.refresh), - onPressed: _isLoading ? null : _fetchData, + RotationTransition( + turns: _refreshController, + child: IconButton( + icon: const Icon(Icons.refresh, size: 28), + onPressed: _isLoading + ? null + : () async { + _refreshController.forward(from: 0.0); + await _fetchData(); + }, + ), ), ], ), if (_isLoading) - const Center( + Center( child: Padding( - padding: EdgeInsets.all(16.0), - child: CircularProgressIndicator(), + padding: const EdgeInsets.all(16.0), + child: AnimatedBuilder( + animation: _refreshController, + builder: (_, child) => Transform.rotate( + angle: _refreshController.value * 2 * 3.14, + child: child, + ), + child: const CircularProgressIndicator(), + ), ), ) else if (_error != null) @@ -212,7 +239,8 @@ class _LeetCodeCardState extends State { const Center( child: Padding( padding: EdgeInsets.all(16.0), - child: Text('暂无提交记录'), + child: + Text('暂无提交记录', style: TextStyle(fontSize: 16)), ), ) else @@ -228,12 +256,16 @@ class _LeetCodeCardState extends State { title: Text( question['translatedTitle'] ?? question['title'], + style: const TextStyle(fontSize: 16), ), subtitle: Text( '提交时间: ${timeago.format(DateTime.fromMillisecondsSinceEpoch(submission['submitTime'] * 1000), locale: 'zh_CN')}', + style: const TextStyle(fontSize: 14), ), trailing: Text( '#${question['questionFrontendId']}', + style: const TextStyle( + fontSize: 14, fontWeight: FontWeight.bold), ), ); },