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_segment.dart'; import 'package:food_hub_app/widgets/recipe/recipe_timeline.dart'; import 'models/recipe.dart'; class RecordPage extends StatefulWidget { const RecordPage({super.key}); @override State createState() => _RecordPageState(); } class _RecordPageState extends State { ViewType _selectedViewType = ViewType.recipe; final List recipeList = [ Recipe("韭菜炒鸡蛋", "家常菜", "2025-05-04", "https://picsum.photos/200", 10, 2, 4), Recipe("红烧肉", "家常菜", "2025-05-05", "https://picsum.photos/200", 12, 4, 7), ]; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(10), child: Column( mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start, children: [ RecipeSegment( selectedViewType: _selectedViewType, onViewTypeChanged: (value) { setState(() { _selectedViewType = value; }); }, ), const SizedBox(height: 10), const Divider(height: 1), const SizedBox(height: 10), // 内容区域 Expanded(child: _buildContent()), ], ), ); } Widget _buildContent() { switch (_selectedViewType) { case ViewType.recipe: return RecipeList(recipeList: recipeList); case ViewType.calendar: return RecipeCalendar(); case ViewType.timeline: return RecipeTimeline(recipeList: recipeList); } } }