优化
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../core/theme/app_spacing.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../home/home_page.dart';
|
||||
import '../market/market_page.dart';
|
||||
import '../trade/trade_page.dart';
|
||||
@@ -76,19 +74,10 @@ class MainPageState extends State<MainPage> {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: colorScheme.background,
|
||||
body: Column(
|
||||
children: [
|
||||
// 公共顶部导航栏
|
||||
const _TopAppBar(),
|
||||
// 页面内容
|
||||
Expanded(
|
||||
child: LazyIndexedStack(
|
||||
index: _currentIndex,
|
||||
loadedIndexes: _loadedPages,
|
||||
children: _pages,
|
||||
),
|
||||
),
|
||||
],
|
||||
body: LazyIndexedStack(
|
||||
index: _currentIndex,
|
||||
loadedIndexes: _loadedPages,
|
||||
children: _pages,
|
||||
),
|
||||
bottomNavigationBar: _BottomNavBar(
|
||||
items: _navItems,
|
||||
@@ -99,125 +88,6 @@ class MainPageState extends State<MainPage> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 顶部导航栏 - 玻璃拟态效果
|
||||
class _TopAppBar extends StatelessWidget {
|
||||
const _TopAppBar();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return Container(
|
||||
height: 64, // 顶部导航栏高度保持固定
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surfaceBright.withOpacity(0.4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: colorScheme.primary.withOpacity(isDark ? 0.15 : 0.08),
|
||||
blurRadius: 64, // 大模糊效果保持固定
|
||||
offset: const Offset(0, 32),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ClipRRect(
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: AppSpacing.xl, sigmaY: AppSpacing.xl),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: AppSpacing.lg),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// 左侧头像和标题
|
||||
Consumer<AuthProvider>(
|
||||
builder: (context, auth, _) {
|
||||
return Row(
|
||||
children: [
|
||||
// 头像
|
||||
Container(
|
||||
width: 32, // 头像尺寸保持固定
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: colorScheme.outlineVariant.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: colorScheme.surfaceContainerHigh,
|
||||
child: Text(
|
||||
auth.user?.avatarText ?? 'U',
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
// 标题
|
||||
Text(
|
||||
'模拟所',
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.w900,
|
||||
letterSpacing: -0.5,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
// 右侧操作按钮
|
||||
Row(
|
||||
children: [
|
||||
_IconBtn(
|
||||
icon: LucideIcons.search,
|
||||
onTap: () {},
|
||||
),
|
||||
SizedBox(width: AppSpacing.sm),
|
||||
_IconBtn(
|
||||
icon: LucideIcons.bell,
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 图标按钮
|
||||
class _IconBtn extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _IconBtn({required this.icon, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(AppSpacing.sm),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 底部导航栏 - "The Kinetic Vault" 设计风格
|
||||
class _BottomNavBar extends StatelessWidget {
|
||||
final List<_NavItem> items;
|
||||
|
||||
Reference in New Issue
Block a user