111
This commit is contained in:
@@ -389,7 +389,7 @@ class _AssetCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 代币列表
|
||||
/// 资产列表
|
||||
class _TokenList extends StatelessWidget {
|
||||
final List holdings;
|
||||
|
||||
@@ -399,11 +399,22 @@ class _TokenList extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
// 对持仓进行排序:USDT 放在最上面
|
||||
final sortedHoldings = List.from(holdings);
|
||||
sortedHoldings.sort((a, b) {
|
||||
final codeA = (a.coinCode ?? a['coinCode'] ?? '').toString().toUpperCase();
|
||||
final codeB = (b.coinCode ?? b['coinCode'] ?? '').toString().toUpperCase();
|
||||
// USDT 排在最前面
|
||||
if (codeA == 'USDT') return -1;
|
||||
if (codeB == 'USDT') return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'代币列表',
|
||||
'资产列表',
|
||||
style: GoogleFonts.spaceGrotesk(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -411,18 +422,18 @@ class _TokenList extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
if (holdings.isEmpty)
|
||||
if (sortedHoldings.isEmpty)
|
||||
_EmptyState(icon: LucideIcons.wallet, message: '暂无持仓')
|
||||
else
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: holdings.length,
|
||||
itemCount: sortedHoldings.length,
|
||||
separatorBuilder: (_, __) => Divider(
|
||||
height: 1,
|
||||
color: colorScheme.outlineVariant.withOpacity(0.2),
|
||||
),
|
||||
itemBuilder: (context, index) => _TokenItem(holding: holdings[index]),
|
||||
itemBuilder: (context, index) => _TokenItem(holding: sortedHoldings[index]),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user