Initial commit: Flutter 无书应用项目

This commit is contained in:
Developer
2026-03-30 02:35:31 +08:00
commit 9175ff9905
566 changed files with 103261 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import '../constants/app_constants.dart';
import '../routes/app_routes.dart';
import './home/home_page.dart';
import './discover_page.dart';
import './favorites_page.dart';
import './profile/profile_page.dart';
/// 时间: 2025-03-21
/// 功能: 主导航页面包含底部导航栏和4个主要页面
/// 介绍: 这是应用的主要导航容器,提供底部导航栏来切换主页、发现、收藏和个人页面
/// 最新变化: 新创建文件,实现了底部导航栏功能,添加黑屏检查
class MainNavigation extends StatefulWidget {
const MainNavigation({super.key});
@override
State<MainNavigation> createState() => _MainNavigationState();
}
class _MainNavigationState extends State<MainNavigation> {
int _currentIndex = 0;
final List<Widget> _pages = [
const HomePage(),
const DiscoverPage(),
const FavoritesPage(),
const ProfilePage(),
];
final List<BottomNavigationBarItem> _bottomNavItems = [
const BottomNavigationBarItem(
icon: Icon(Icons.home),
activeIcon: Icon(Icons.home, color: AppConstants.primaryColor),
label: '主页',
),
const BottomNavigationBarItem(
icon: Icon(Icons.explore),
activeIcon: Icon(Icons.explore, color: AppConstants.primaryColor),
label: '发现',
),
const BottomNavigationBarItem(
icon: Icon(Icons.favorite_border),
activeIcon: Icon(Icons.favorite, color: AppConstants.primaryColor),
label: '收藏',
),
const BottomNavigationBarItem(
icon: Icon(Icons.person_outline),
activeIcon: Icon(Icons.person, color: AppConstants.primaryColor),
label: '个人',
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(index: _currentIndex, children: _pages),
bottomNavigationBar: Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 8,
offset: const Offset(0, -2),
),
],
),
child: SafeArea(
top: false,
child: BottomNavigationBar(
currentIndex: _currentIndex,
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
type: BottomNavigationBarType.fixed,
selectedItemColor: AppConstants.primaryColor,
unselectedItemColor: Colors.grey[600],
backgroundColor: Colors.white,
elevation: 0,
items: _bottomNavItems,
selectedFontSize: 12,
unselectedFontSize: 12,
),
),
),
);
}
}