fix(theme): 修复组件主题硬编码问题

- asset_card: Colors.white/black → colorScheme
- gradient_button: Colors.white → onPrimary
- trade_button: Colors.white → onPrimary
- 支持亮/暗主题动态切换
This commit is contained in:
2026-03-24 08:45:54 +08:00
parent 13841b1958
commit b4eeb61aa1
3 changed files with 34 additions and 22 deletions

View File

@@ -45,11 +45,15 @@ class TradeButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final gradient = isBuy ? AppColorScheme.buyGradient : AppColorScheme.sellGradient;
final text = isBuy
? '买入${coinCode != null ? ' $coinCode' : ''}'
: '卖出${coinCode != null ? ' $coinCode' : ''}';
// 主题感知颜色 - 在渐变背景上使用 onPrimary
final textColor = colorScheme.onPrimary;
return Container(
width: fullWidth ? double.infinity : null,
height: 48,
@@ -68,24 +72,24 @@ class TradeButton extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
const SizedBox.square(
SizedBox.square(
dimension: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
color: textColor,
),
)
else
Icon(
isBuy ? Icons.arrow_downward_rounded : Icons.arrow_upward_rounded,
size: 18,
color: Colors.white,
color: textColor,
),
const SizedBox(width: 8),
Text(
text,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: textColor,
fontSize: 16,
fontWeight: FontWeight.w600,
),