add
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:asset_assistant/pages/exchange_page.dart';
|
||||
import 'package:asset_assistant/pages/home_page.dart';
|
||||
import 'package:asset_assistant/pages/login_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -21,9 +22,11 @@ class MyApp extends StatelessWidget {
|
||||
title: '资产助手',
|
||||
debugShowCheckedModeBanner: false, // 移除 debug 标签
|
||||
initialRoute: initialRoute,
|
||||
// 在MaterialApp的routes中添加
|
||||
routes: {
|
||||
'/login': (context) => const LoginPage(),
|
||||
'/home': (context) => HomePage(),
|
||||
'/exchange': (context) => ExchangePage(),
|
||||
},
|
||||
theme: ThemeData(
|
||||
// 金融暗夜风格主题配置
|
||||
|
||||
116
frontend/asset_assistant/lib/pages/exchange_page.dart
Normal file
116
frontend/asset_assistant/lib/pages/exchange_page.dart
Normal file
@@ -0,0 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExchangePage extends StatelessWidget {
|
||||
// 功能列表数据
|
||||
final List<Map<String, dynamic>> features = [
|
||||
{'icon': Icons.bar_chart, 'title': '数据分析'},
|
||||
{'icon': Icons.balance, 'title': '交易'},
|
||||
{'icon': Icons.account_balance, 'title': '交易所'},
|
||||
{'icon': Icons.branding_watermark, 'title': '品种'},
|
||||
];
|
||||
|
||||
ExchangePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('交易所'),
|
||||
centerTitle: true,
|
||||
elevation: 4,
|
||||
shadowColor: Colors.black12,
|
||||
backgroundColor: theme.colorScheme.surfaceContainerHighest,
|
||||
automaticallyImplyLeading: false,
|
||||
),
|
||||
// 使用SafeArea确保内容在安全区域内
|
||||
body: SafeArea(
|
||||
// 移除不必要的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,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFeatureItem({
|
||||
required BuildContext context,
|
||||
required IconData icon,
|
||||
required String title,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// 点击事件可以在这里添加
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
splashColor: theme.colorScheme.primary.withValues(alpha: 0.1),
|
||||
highlightColor: theme.colorScheme.primary.withValues(alpha: 0.05),
|
||||
child: Container(
|
||||
height: 64,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, size: 24, color: theme.colorScheme.secondary),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
title,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Icon(Icons.arrow_forward_ios, size: 18, color: theme.hintColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:asset_assistant/pages/exchange_page.dart'; // 导入ExchangePage
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
// 功能列表数据
|
||||
// 功能列表数据 - 为交易所项添加路由信息
|
||||
final List<Map<String, dynamic>> features = [
|
||||
{'icon': Icons.bar_chart, 'title': '数据分析'},
|
||||
{'icon': Icons.balance, 'title': '交易'},
|
||||
{'icon': Icons.account_balance, 'title': '交易所'},
|
||||
{'icon': Icons.branding_watermark, 'title': '品种'},
|
||||
{'icon': Icons.bar_chart, 'title': '数据分析', 'route': null},
|
||||
{'icon': Icons.balance, 'title': '交易', 'route': null},
|
||||
{'icon': Icons.account_balance, 'title': '交易所', 'route': '/exchange'},
|
||||
{'icon': Icons.branding_watermark, 'title': '品种', 'route': null},
|
||||
];
|
||||
|
||||
HomePage({super.key});
|
||||
|
||||
// 退出登录方法
|
||||
// 退出登录方法(保持不变)
|
||||
void _logout(BuildContext context) async {
|
||||
final result = await showDialog(
|
||||
context: context,
|
||||
@@ -31,9 +32,7 @@ class HomePage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
|
||||
// 检查组件是否仍处于挂载状态
|
||||
if (result == true && context.mounted) {
|
||||
// 清除用户登录状态的逻辑
|
||||
Navigator.pushReplacementNamed(context, '/login');
|
||||
}
|
||||
}
|
||||
@@ -64,29 +63,23 @@ class HomePage extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
// 使用SafeArea确保内容在安全区域内
|
||||
body: SafeArea(
|
||||
// 移除不必要的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'],
|
||||
route: features[index]['route'], // 传递路由信息
|
||||
);
|
||||
|
||||
// 在每个列表项下方添加分割线,包括最后一个
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -107,10 +100,12 @@ class HomePage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// 修改_buildFeatureItem方法,添加路由参数和导航逻辑
|
||||
Widget _buildFeatureItem({
|
||||
required BuildContext context,
|
||||
required IconData icon,
|
||||
required String title,
|
||||
String? route, // 新增路由参数
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
@@ -118,11 +113,17 @@ class HomePage extends StatelessWidget {
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// 点击事件可以在这里添加
|
||||
// 点击事件处理 - 如果有路由信息则导航
|
||||
if (route != null && context.mounted) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => ExchangePage()),
|
||||
);
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
splashColor: theme.colorScheme.primary.withValues(alpha: 0.1),
|
||||
highlightColor: theme.colorScheme.primary.withValues(alpha: 0.05),
|
||||
splashColor: theme.colorScheme.primary.withAlpha(26), // 修改为withAlpha更兼容
|
||||
highlightColor: theme.colorScheme.primary.withAlpha(13),
|
||||
child: Container(
|
||||
height: 64,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
|
||||
Reference in New Issue
Block a user