simple navigation for creating recipe
This commit is contained in:
53
lib/pages/create_recipe_page.dart
Normal file
53
lib/pages/create_recipe_page.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.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(),
|
||||
];
|
||||
|
||||
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) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
destinations: _destinations,
|
||||
selectedIndex: _currentPageIndex,
|
||||
onDestinationSelected: (value) => setState(() {
|
||||
_currentPageIndex = value;
|
||||
}),
|
||||
),
|
||||
body: _pages.elementAt(_currentPageIndex),
|
||||
);
|
||||
}
|
||||
}
|
||||
10
lib/pages/create_recipe_pages/ingredients_page.dart
Normal file
10
lib/pages/create_recipe_pages/ingredients_page.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class IngredientsPage extends StatelessWidget {
|
||||
const IngredientsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: const Text('Ingredients'));
|
||||
}
|
||||
}
|
||||
12
lib/pages/create_recipe_pages/metadata_page.dart
Normal file
12
lib/pages/create_recipe_pages/metadata_page.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MetadataPage extends StatelessWidget {
|
||||
const MetadataPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Center(
|
||||
child: Text('Metadata'),
|
||||
);
|
||||
}
|
||||
}
|
||||
10
lib/pages/create_recipe_pages/steps_page.dart
Normal file
10
lib/pages/create_recipe_pages/steps_page.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StepsPage extends StatelessWidget {
|
||||
const StepsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: const Text('Steps'));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'create_recipe_page.dart';
|
||||
|
||||
class OverviewPage extends StatelessWidget {
|
||||
const OverviewPage({super.key});
|
||||
static const String routeName = '/';
|
||||
@@ -11,7 +13,8 @@ class OverviewPage extends StatelessWidget {
|
||||
title: Text('Recipe Journal'),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {},
|
||||
onPressed: () =>
|
||||
Navigator.pushNamed(context, CreateRecipePage.routeName),
|
||||
label: Text('Create New'),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user