create recipe page edited
This commit is contained in:
@@ -1,15 +1,47 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CreateRecipe extends StatelessWidget {
|
import '../models/recipe.dart';
|
||||||
|
import '../widgets/difficulty_dropdown.dart';
|
||||||
|
|
||||||
|
class CreateRecipe extends StatefulWidget {
|
||||||
const CreateRecipe({super.key});
|
const CreateRecipe({super.key});
|
||||||
static const routeName = '/createRecipe';
|
static const routeName = '/createRecipe';
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CreateRecipe> createState() => _CreateRecipeState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateRecipeState extends State<CreateRecipe> {
|
||||||
|
Difficulty? _recipeDifficulty;
|
||||||
|
|
||||||
|
TextEditingController titleText = TextEditingController();
|
||||||
|
TextEditingController descriptionText = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Create Recipe'),
|
title: const Text('Create Recipe'),
|
||||||
),
|
),
|
||||||
|
body: Form(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: titleText,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Title',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
controller: descriptionText,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Description',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const DifficultyDropdown(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
lib/widgets/difficulty_dropdown.dart
Normal file
21
lib/widgets/difficulty_dropdown.dart
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:rezepte/models/recipe.dart';
|
||||||
|
|
||||||
|
class DifficultyDropdown extends StatelessWidget {
|
||||||
|
const DifficultyDropdown({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<DropdownMenuEntry> dropdownMenuEntryList = List.generate(
|
||||||
|
Difficulty.values.length,
|
||||||
|
(index) => _toDropdownMenuEntry(
|
||||||
|
index, Difficulty.values.elementAt(index).name));
|
||||||
|
|
||||||
|
return DropdownMenu(
|
||||||
|
dropdownMenuEntries: dropdownMenuEntryList,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DropdownMenuEntry _toDropdownMenuEntry(int index, String text) =>
|
||||||
|
DropdownMenuEntry(value: index, label: text);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user