feat: 优化交易账户和币种选择功能
- 交易账户卡片添加总市值显示和持仓列表 - 持仓列表USDT自动排在最上面 - 交易页面添加币种选择弹窗功能 - 行情页面点击币种跳转到交易页面 - 支持从外部传入选中币种参数 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,9 +14,8 @@ import '../mine/mine_page.dart';
|
||||
class _NavItem {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final Widget page;
|
||||
|
||||
const _NavItem({required this.label, required this.icon, required this.page});
|
||||
const _NavItem({required this.label, required this.icon});
|
||||
}
|
||||
|
||||
/// 主页面 - "The Kinetic Vault" 设计风格
|
||||
@@ -24,20 +23,26 @@ class MainPage extends StatefulWidget {
|
||||
const MainPage({super.key});
|
||||
|
||||
@override
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
State<MainPage> createState() => MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
class MainPageState extends State<MainPage> {
|
||||
int _currentIndex = 0;
|
||||
final Set<int> _loadedPages = {0};
|
||||
String? _tradeCoinCode; // 交易页面选中的币种代码
|
||||
late final List<Widget> _pages;
|
||||
|
||||
static final _navItems = [
|
||||
_NavItem(label: '首页', icon: LucideIcons.house, page: const HomePage()),
|
||||
_NavItem(label: '行情', icon: LucideIcons.trendingUp, page: const MarketPage()),
|
||||
_NavItem(label: '交易', icon: LucideIcons.arrowLeftRight, page: const TradePage()),
|
||||
_NavItem(label: '资产', icon: LucideIcons.wallet, page: const AssetPage()),
|
||||
_NavItem(label: '我的', icon: LucideIcons.user, page: const MinePage()),
|
||||
];
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_pages = [
|
||||
const HomePage(),
|
||||
const MarketPage(),
|
||||
TradePage(initialCoinCode: _tradeCoinCode),
|
||||
const AssetPage(),
|
||||
const MinePage(),
|
||||
];
|
||||
}
|
||||
|
||||
void _onTabChanged(int index) {
|
||||
setState(() {
|
||||
@@ -46,6 +51,25 @@ class _MainPageState extends State<MainPage> {
|
||||
});
|
||||
}
|
||||
|
||||
/// 切换到交易页面并选中指定币种
|
||||
void switchToTrade(String coinCode) {
|
||||
setState(() {
|
||||
_tradeCoinCode = coinCode;
|
||||
_currentIndex = 2; // 交易页面索引
|
||||
_loadedPages.add(2);
|
||||
// 重新构建交易页面
|
||||
_pages[2] = TradePage(initialCoinCode: _tradeCoinCode);
|
||||
});
|
||||
}
|
||||
|
||||
static const _navItems = [
|
||||
_NavItem(label: '首页', icon: LucideIcons.house),
|
||||
_NavItem(label: '行情', icon: LucideIcons.trendingUp),
|
||||
_NavItem(label: '交易', icon: LucideIcons.arrowLeftRight),
|
||||
_NavItem(label: '资产', icon: LucideIcons.wallet),
|
||||
_NavItem(label: '我的', icon: LucideIcons.user),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
@@ -61,7 +85,7 @@ class _MainPageState extends State<MainPage> {
|
||||
child: LazyIndexedStack(
|
||||
index: _currentIndex,
|
||||
loadedIndexes: _loadedPages,
|
||||
children: _navItems.map((item) => item.page).toList(),
|
||||
children: _pages,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user