diff --git a/frontend/asset_assistant/lib/pages/home_page.dart b/frontend/asset_assistant/lib/pages/home_page.dart index 10535f4..d49bd0a 100644 --- a/frontend/asset_assistant/lib/pages/home_page.dart +++ b/frontend/asset_assistant/lib/pages/home_page.dart @@ -4,19 +4,10 @@ import 'package:flutter/services.dart'; class HomePage extends StatelessWidget { // 功能列表数据 final List> features = [ - {'icon': Icons.home, 'title': '首页'}, - {'icon': Icons.search, 'title': '搜索'}, - {'icon': Icons.notifications, 'title': '通知'}, - {'icon': Icons.message, 'title': '消息'}, - {'icon': Icons.person, 'title': '个人中心'}, - {'icon': Icons.settings, 'title': '设置'}, - {'icon': Icons.help, 'title': '帮助中心'}, - {'icon': Icons.share, 'title': '分享'}, - // 可以添加更多项测试滚动 - {'icon': Icons.accessibility, 'title': '无障碍'}, - {'icon': Icons.add_alert, 'title': '提醒'}, - {'icon': Icons.book, 'title': '书籍'}, - {'icon': Icons.camera, 'title': '相机'}, + {'icon': Icons.bar_chart, 'title': '数据分析'}, + {'icon': Icons.balance, 'title': '交易'}, + {'icon': Icons.account_balance, 'title': '交易所'}, + {'icon': Icons.branding_watermark, 'title': '品种'}, ]; HomePage({super.key}); @@ -75,35 +66,41 @@ class HomePage extends StatelessWidget { ), // 使用SafeArea确保内容在安全区域内 body: SafeArea( - // 使用Expanded确保ListView获得足够空间 - child: Expanded( - child: Container( - color: theme.colorScheme.surface, - // 确保ListView占满可用空间 - child: ListView.separated( - // 关键修复:添加内边距但不影响滚动范围 - padding: const EdgeInsets.symmetric(vertical: 8), - // 确保列表有足够多的项可以滚动(已添加测试项) - itemCount: features.length, - // 增强的滚动物理效果 - physics: const BouncingScrollPhysics( - parent: AlwaysScrollableScrollPhysics(), - ), - separatorBuilder: (context, index) => Divider( - height: 1, - thickness: 1, - indent: 72, - endIndent: 16, - color: theme.dividerColor, - ), - itemBuilder: (context, index) { - return _buildFeatureItem( - context: context, - icon: features[index]['icon'], - title: features[index]['title'], - ); - }, - ), + // 移除不必要的Expanded,避免约束冲突 + child: Container( + color: theme.colorScheme.surface, + // 让容器占满整个可用空间 + width: double.infinity, + height: double.infinity, + child: ListView.builder( + // 修改为ListView.builder + padding: const EdgeInsets.symmetric(vertical: 8), + itemCount: features.length, + // 优化Web端滚动物理效果,同时支持触摸和鼠标滚动 + physics: const ScrollPhysics(parent: BouncingScrollPhysics()), + itemBuilder: (context, index) { + // 构建列表项 + Widget item = _buildFeatureItem( + context: context, + icon: features[index]['icon'], + title: features[index]['title'], + ); + + // 在每个列表项下方添加分割线,包括最后一个 + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + item, + Divider( + height: 1, + thickness: 1, + indent: 72, + endIndent: 16, + color: theme.dividerColor, + ), + ], + ); + }, ), ), ),