feat:增加图表组件
This commit is contained in:
80
lib/views/record.dart
Normal file
80
lib/views/record.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/recipe_calendar.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/recipe_list.dart';
|
||||
import 'package:food_hub_app/widgets/recipe/recipe_timeline.dart';
|
||||
import 'package:tdesign_flutter/tdesign_flutter.dart';
|
||||
|
||||
import '../models/recipe.dart';
|
||||
|
||||
class RecordPage extends StatefulWidget {
|
||||
const RecordPage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _RecordPageState();
|
||||
}
|
||||
|
||||
class _RecordPageState extends State<RecordPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final List<Recipe> recipeList = [
|
||||
Recipe("韭菜炒鸡蛋", "家常菜", "2025-05-04", "https://picsum.photos/200", 10, 2, 4),
|
||||
Recipe("红烧肉", "家常菜", "2025-05-05", "https://picsum.photos/200", 12, 4, 7),
|
||||
];
|
||||
|
||||
final List<Record> recordList = [
|
||||
Record("韭菜炒鸡蛋", "家常菜", "2025-05-04", "https://picsum.photos/200"),
|
||||
Record("红烧肉", "家常菜", "2025-05-05", "https://picsum.photos/200"),
|
||||
];
|
||||
|
||||
late final TabController _tabController = TabController(
|
||||
length: 3,
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// 定义标签列表
|
||||
final List<TDTab> tabs = [
|
||||
const TDTab(text: '菜谱', icon: Icon(Icons.book)),
|
||||
const TDTab(text: '日历', icon: Icon(Icons.calendar_month)),
|
||||
const TDTab(text: '时间轴', icon: Icon(Icons.timeline)),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(0),
|
||||
child: Column(
|
||||
children: [
|
||||
TDTabBar(
|
||||
tabs: tabs,
|
||||
controller: _tabController,
|
||||
backgroundColor: Colors.white,
|
||||
showIndicator: true,
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
RecipeList(recipeList: recipeList),
|
||||
RecipeCalendar(),
|
||||
RecipeTimeline(recipeList: recipeList),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user