added difficulty class and dropdown
This commit is contained in:
8
lib/models/difficulty.dart
Normal file
8
lib/models/difficulty.dart
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class Difficulty {
|
||||||
|
static List<String> get difficulties {
|
||||||
|
return List<String>.generate(_Difficulty.values.length,
|
||||||
|
(index) => _Difficulty.values.elementAt(index).name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum _Difficulty { veryEasy, easy, intermediate, hard, veryHard }
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'difficulty.dart';
|
||||||
import 'ingredient.dart';
|
import 'ingredient.dart';
|
||||||
import 'steps.dart';
|
import 'steps.dart';
|
||||||
|
|
||||||
@@ -14,5 +15,3 @@ class Recipe {
|
|||||||
this.difficulty,
|
this.difficulty,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Difficulty { veryEasy, easy, intermediate, hard, veryHard }
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../models/recipe.dart';
|
import '../models/difficulty.dart';
|
||||||
import '../widgets/difficulty_dropdown.dart';
|
import '../widgets/difficulty_dropdown.dart';
|
||||||
|
|
||||||
class CreateRecipe extends StatefulWidget {
|
class CreateRecipe extends StatefulWidget {
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rezepte/models/recipe.dart';
|
import 'package:rezepte/models/recipe.dart';
|
||||||
|
|
||||||
|
import '../models/difficulty.dart';
|
||||||
|
|
||||||
class DifficultyDropdown extends StatelessWidget {
|
class DifficultyDropdown extends StatelessWidget {
|
||||||
const DifficultyDropdown({super.key});
|
const DifficultyDropdown({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<DropdownMenuEntry> dropdownMenuEntryList = List.generate(
|
List<DropdownMenuEntry> dropdownMenuEntryList = Difficulty.difficulties
|
||||||
Difficulty.values.length,
|
.map(
|
||||||
(index) => _toDropdownMenuEntry(
|
(e) => _toDropdownMenuEntry(Difficulty.difficulties.indexOf(e), e),
|
||||||
index, Difficulty.values.elementAt(index).name));
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
return DropdownMenu(
|
return DropdownMenu(
|
||||||
dropdownMenuEntries: dropdownMenuEntryList,
|
dropdownMenuEntries: dropdownMenuEntryList,
|
||||||
|
|||||||
Reference in New Issue
Block a user