- 新增 CategoryScreen 屏幕用于显示分类- 新增 ItemCategory 模型类用于分类数据管理 - 新增 ItemCategoryRepository 用于分类数据持久化 - 新增 item_category_table 创建分类表结构 -重构 HomeScreen 底部导航栏,增加分类选项 - 重命名相关屏幕文件,统一命名规范 - 调整 ItemScreen 以适应新增的分类功能- 更新 SQLiteHelper 以支持分类表创建和默认分类插入 - 删除 StatisticsScreen 屏幕
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flutter/material.dart';
 | |
| import 'package:item_tracker/screens/category_screens/category_screen.dart';
 | |
| import 'package:item_tracker/screens/item_screens/item_list_screen.dart';
 | |
| import 'package:item_tracker/screens/my_screen.dart'; // 新增导入
 | |
| 
 | |
| class HomeScreen extends StatefulWidget {
 | |
|   @override
 | |
|   _HomeScreenState createState() => _HomeScreenState();
 | |
| }
 | |
| 
 | |
| class _HomeScreenState extends State<HomeScreen> {
 | |
|   int _selectedIndex = 0;
 | |
|   static List<Widget> _widgetOptions = <Widget>[
 | |
|     ItemListScreen(), 
 | |
|     CategoryScreen(),
 | |
|     MyScreen(),
 | |
|   ];
 | |
| 
 | |
|   void _onItemTapped(int index) {
 | |
|     setState(() {
 | |
|       _selectedIndex = index;
 | |
|     });
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     return Scaffold(
 | |
|       appBar: AppBar(
 | |
|         title: Text('物品记录器'),
 | |
|       ),
 | |
|       body: Center(
 | |
|         child: _widgetOptions.elementAt(_selectedIndex),
 | |
|       ),
 | |
|       bottomNavigationBar: BottomNavigationBar(
 | |
|         items: const <BottomNavigationBarItem>[
 | |
|           BottomNavigationBarItem(
 | |
|             icon: Icon(Icons.add_business_sharp),
 | |
|             label: '首页',
 | |
|           ),
 | |
|           BottomNavigationBarItem(
 | |
|             icon: Icon(Icons.add_business_sharp),
 | |
|             label: '分类',
 | |
|           ),
 | |
|           BottomNavigationBarItem(
 | |
|             icon: Icon(Icons.person),
 | |
|             label: '我的',
 | |
|           ),
 | |
|         ],
 | |
|         currentIndex: _selectedIndex,
 | |
|         selectedItemColor: Colors.blue,
 | |
|         onTap: _onItemTapped,
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| } |