111
This commit is contained in:
@@ -10,7 +10,7 @@ import '../../../providers/market_provider.dart';
|
||||
import '../../components/glass_panel.dart';
|
||||
import '../main/main_page.dart';
|
||||
|
||||
/// 行情页面
|
||||
/// 行情頁面
|
||||
class MarketPage extends StatefulWidget {
|
||||
const MarketPage({super.key});
|
||||
|
||||
@@ -62,7 +62,7 @@ class _MarketPageState extends State<MarketPage>
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 页面标题 "行情"
|
||||
// 頁面標題 "行情"
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: AppSpacing.sm),
|
||||
child: Text(
|
||||
@@ -71,13 +71,13 @@ class _MarketPageState extends State<MarketPage>
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
// 精选区域:BTC + ETH 卡片
|
||||
// 精選區域:BTC + ETH 卡片
|
||||
_buildFeaturedSection(provider),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
// 分区标题:全部币种 + 更多
|
||||
// 分區標題:全部幣種 + 更多
|
||||
_buildSectionHeader(),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
// 币种列表卡片
|
||||
// 幣種列表卡片
|
||||
_buildCoinList(provider),
|
||||
],
|
||||
),
|
||||
@@ -88,7 +88,7 @@ class _MarketPageState extends State<MarketPage>
|
||||
);
|
||||
}
|
||||
|
||||
/// 精选区域:BTC + ETH 大卡片
|
||||
/// 精選區域:BTC + ETH 大卡片
|
||||
Widget _buildFeaturedSection(MarketProvider provider) {
|
||||
final featured = provider.featuredCoins;
|
||||
if (featured.isEmpty) return const SizedBox.shrink();
|
||||
@@ -111,13 +111,13 @@ class _MarketPageState extends State<MarketPage>
|
||||
);
|
||||
}
|
||||
|
||||
/// 分区标题:全部币种 + 更多
|
||||
/// 分區標題:全部幣種 + 更多
|
||||
Widget _buildSectionHeader() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'全部币种',
|
||||
'全部幣種',
|
||||
style: AppTextStyles.headlineLarge(context),
|
||||
),
|
||||
Text(
|
||||
@@ -130,14 +130,14 @@ class _MarketPageState extends State<MarketPage>
|
||||
);
|
||||
}
|
||||
|
||||
/// 币种列表
|
||||
/// 幣種列表
|
||||
Widget _buildCoinList(MarketProvider provider) {
|
||||
final coins = provider.otherCoins;
|
||||
|
||||
if (coins.isEmpty) {
|
||||
return _EmptyState(
|
||||
icon: LucideIcons.coins,
|
||||
message: '暂无数据',
|
||||
message: '暫無數據',
|
||||
onRetry: () => provider.refresh(),
|
||||
);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class _MarketPageState extends State<MarketPage>
|
||||
);
|
||||
}
|
||||
|
||||
/// 错误状态
|
||||
/// 錯誤狀態
|
||||
Widget _buildErrorState(MarketProvider provider) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
@@ -178,14 +178,14 @@ class _MarketPageState extends State<MarketPage>
|
||||
Icon(LucideIcons.circleAlert, size: 48, color: context.colors.error),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
Text(
|
||||
provider.error ?? '加载失败',
|
||||
provider.error ?? '加載失敗',
|
||||
style: TextStyle(color: context.colors.error),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
ShadButton(
|
||||
onPressed: () => provider.refresh(),
|
||||
child: const Text('重试'),
|
||||
child: const Text('重試'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -194,7 +194,7 @@ class _MarketPageState extends State<MarketPage>
|
||||
}
|
||||
}
|
||||
|
||||
/// 精选卡片:BTC / ETH (130px 高度,含迷你柱状图)
|
||||
/// 精選卡片:BTC / ETH (130px 高度,含迷你柱狀圖)
|
||||
class _FeaturedCard extends StatelessWidget {
|
||||
final Coin coin;
|
||||
|
||||
@@ -216,13 +216,13 @@ class _FeaturedCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// 第一行:币种名称 + 涨跌徽章
|
||||
// 第一行:幣種名稱 + 漲跌徽章
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'${coin.code}/USDT',
|
||||
style: AppTextStyles.labelLarge(context), // 缩小文字
|
||||
style: AppTextStyles.labelLarge(context), // 縮小文字
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xs + 2, vertical: 2),
|
||||
@@ -234,27 +234,27 @@ class _FeaturedCard extends StatelessWidget {
|
||||
coin.formattedChange,
|
||||
style: AppTextStyles.labelSmall(context).copyWith(
|
||||
color: changeColor,
|
||||
fontSize: 10, // 缩小文字
|
||||
fontSize: 10, // 縮小文字
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// 第二行:价格
|
||||
// 第二行:價格
|
||||
Text(
|
||||
'\$${_formatFeaturedPrice(coin)}',
|
||||
style: AppTextStyles.headlineLarge(context).copyWith( // 缩小文字
|
||||
style: AppTextStyles.headlineLarge(context).copyWith( // 縮小文字
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
// 第三行:币种全名
|
||||
// 第三行:幣種全名
|
||||
Text(
|
||||
coin.name,
|
||||
style: AppTextStyles.bodySmall(context).copyWith( // 缩小文字
|
||||
style: AppTextStyles.bodySmall(context).copyWith( // 縮小文字
|
||||
color: context.colors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
// 第四行:迷你柱状图
|
||||
// 第四行:迷你柱狀圖
|
||||
Expanded(
|
||||
child: _MiniBarChart(isUp: isUp, seed: coin.code.hashCode),
|
||||
),
|
||||
@@ -263,7 +263,7 @@ class _FeaturedCard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 精选卡片使用简短价格格式(带逗号)
|
||||
/// 精選卡片使用簡短價格格式(帶逗號)
|
||||
String _formatFeaturedPrice(Coin coin) {
|
||||
if (coin.price >= 1000) {
|
||||
return _addCommas(coin.price.toStringAsFixed(2));
|
||||
@@ -288,7 +288,7 @@ class _FeaturedCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 迷你柱状图(模拟价格走势)
|
||||
/// 迷你柱狀圖(模擬價格走勢)
|
||||
class _MiniBarChart extends StatelessWidget {
|
||||
final bool isUp;
|
||||
final int seed;
|
||||
@@ -301,7 +301,7 @@ class _MiniBarChart extends StatelessWidget {
|
||||
? context.appColors.up
|
||||
: context.appColors.down;
|
||||
|
||||
// 生成随机但确定的高度序列
|
||||
// 生成隨機但確定的高度序列
|
||||
final heights = _generateHeights();
|
||||
|
||||
return Row(
|
||||
@@ -310,7 +310,7 @@ class _MiniBarChart extends StatelessWidget {
|
||||
children: heights.map((h) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 2), // 增加间距
|
||||
padding: const EdgeInsets.only(left: 2), // 增加間距
|
||||
child: Container(
|
||||
height: h,
|
||||
decoration: BoxDecoration(
|
||||
@@ -326,13 +326,13 @@ class _MiniBarChart extends StatelessWidget {
|
||||
|
||||
List<double> _generateHeights() {
|
||||
final random = Random(seed);
|
||||
final base = 6.0; // 降低基础高度
|
||||
final range = 12.0; // 降低范围
|
||||
final base = 6.0; // 降低基礎高度
|
||||
final range = 12.0; // 降低範圍
|
||||
return List.generate(6, (_) => base + random.nextDouble() * range);
|
||||
}
|
||||
}
|
||||
|
||||
/// 币种列表行
|
||||
/// 幣種列表行
|
||||
class _CoinRow extends StatelessWidget {
|
||||
final Coin coin;
|
||||
|
||||
@@ -354,10 +354,10 @@ class _CoinRow extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
// 头像:圆形字母头像
|
||||
// 頭像:圓形字母頭像
|
||||
_CoinAvatar(letter: coin.displayIcon, code: coin.code),
|
||||
const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
// 币种信息:交易对 + 全名
|
||||
// 幣種信息:交易對 + 全名
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -375,7 +375,7 @@ class _CoinRow extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// 右侧:价格 + 涨跌标签
|
||||
// 右側:價格 + 漲跌標籤
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -412,7 +412,7 @@ class _CoinRow extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 币种头像组件
|
||||
/// 幣種頭像組件
|
||||
class _CoinAvatar extends StatelessWidget {
|
||||
final String letter;
|
||||
final String code;
|
||||
@@ -421,7 +421,7 @@ class _CoinAvatar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 使用主题变量而非硬编码
|
||||
// 使用主題變量而非硬編碼
|
||||
final bgColor = context.colors.primary.withValues(alpha: context.appColors.glowOpacity);
|
||||
|
||||
return Container(
|
||||
@@ -456,7 +456,7 @@ class _CoinAvatar extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 空状态
|
||||
/// 空狀態
|
||||
class _EmptyState extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String message;
|
||||
@@ -481,7 +481,7 @@ class _EmptyState extends StatelessWidget {
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
ShadButton(
|
||||
onPressed: onRetry,
|
||||
child: const Text('重试'),
|
||||
child: const Text('重試'),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user