68 lines
1.7 KiB
Dart
68 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../services/providers/recipe_provider.dart';
|
|
import 'create_recipe_pages/ingredients_page.dart';
|
|
import 'create_recipe_pages/metadata_page.dart';
|
|
import 'create_recipe_pages/steps_page.dart';
|
|
|
|
class CreateRecipePage extends StatefulWidget {
|
|
const CreateRecipePage({super.key});
|
|
|
|
static const String routeName = '/create';
|
|
|
|
@override
|
|
State<CreateRecipePage> createState() => _CreateRecipePageState();
|
|
}
|
|
|
|
class _CreateRecipePageState extends State<CreateRecipePage> {
|
|
int _currentPageIndex = 0;
|
|
final List<Widget> _pages = [
|
|
const MetadataPage(),
|
|
const IngredientsPage(),
|
|
const StepsPage(),
|
|
];
|
|
|
|
late RecipeProvider _recipeProvider;
|
|
|
|
final List<NavigationDestination> _destinations = [
|
|
NavigationDestination(
|
|
icon: Icon(Icons.list),
|
|
label: 'Metadata',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.emoji_food_beverage),
|
|
label: 'Ingredients',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.format_list_numbered_outlined),
|
|
label: 'Steps',
|
|
),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
_recipeProvider = context.watch<RecipeProvider>();
|
|
return Scaffold(
|
|
appBar: AppBar(),
|
|
bottomNavigationBar: NavigationBar(
|
|
destinations: _destinations,
|
|
selectedIndex: _currentPageIndex,
|
|
onDestinationSelected: (value) => setState(() {
|
|
_currentPageIndex = value;
|
|
}),
|
|
),
|
|
body: IndexedStack(
|
|
index: _currentPageIndex,
|
|
children: _pages,
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
_recipeProvider.disposeRecipe();
|
|
}
|
|
}
|