feat:增加图表组件

This commit is contained in:
2025-07-13 22:00:55 +08:00
parent 55ca36cba2
commit 8a1b507166
14 changed files with 464 additions and 218 deletions

View File

@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:food_hub_app/profile.dart';
import 'package:food_hub_app/record.dart';
import 'package:food_hub_app/views/home.dart';
import 'package:food_hub_app/views/login.dart';
import 'package:food_hub_app/views/recordForm.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
@@ -19,7 +18,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(fontFamily: 'CustomFont', primaryColor: Colors.green),
theme: ThemeData(fontFamily: 'CustomFont'),
supportedLocales: const [
Locale('en', 'US'), // 英语
Locale('zh', 'CN'), // 中文
@@ -41,89 +40,9 @@ class MyApp extends StatelessWidget {
},
home: LoginPage(),
routes: {
'/home': (context) => MainPage(),
'/home': (context) => HomePage(),
'/recordForm': (context) => RecordFormPage(),
},
);
}
}
class MainPage extends StatefulWidget {
const MainPage({super.key});
@override
State<StatefulWidget> createState() => _MainPage();
}
class _MainPage extends State<MainPage> {
int _currentIndex = 0;
final List<Widget> _tabPages = const [RecordPage(), ProfilePage()];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('Food Hub'),
backgroundColor: Colors.green,
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
// 打开侧边栏或菜单
},
),
actions: [
IconButton(
icon: Icon(Icons.search),
onPressed: () {
// 搜索功能
},
),
IconButton(
icon: Icon(Icons.more_vert),
onPressed: () {
// 更多选项
},
),
],
),
backgroundColor: Color(0xFFF5F5F5),
body: _tabPages[_currentIndex],
floatingActionButton:
_currentIndex == _tabPages.length - 1 ? null : addItemButton(context),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
iconSize: 25,
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "记录"),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
label: "我的",
),
],
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
);
}
}
Widget addItemButton(BuildContext context) {
void onAddItemClick(BuildContext context) {
Navigator.pushNamed(context, '/recordForm');
}
return FloatingActionButton(
mini: true,
onPressed: () => onAddItemClick(context),
backgroundColor: Colors.green,
shape: const CircleBorder(),
child: Icon(Icons.add, color: Colors.white),
);
}