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 'steps.dart';
|
||||
|
||||
@@ -14,5 +15,3 @@ class Recipe {
|
||||
this.difficulty,
|
||||
});
|
||||
}
|
||||
|
||||
enum Difficulty { veryEasy, easy, intermediate, hard, veryHard }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../models/recipe.dart';
|
||||
import '../models/difficulty.dart';
|
||||
import '../widgets/difficulty_dropdown.dart';
|
||||
|
||||
class CreateRecipe extends StatefulWidget {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rezepte/models/recipe.dart';
|
||||
|
||||
import '../models/difficulty.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));
|
||||
List<DropdownMenuEntry> dropdownMenuEntryList = Difficulty.difficulties
|
||||
.map(
|
||||
(e) => _toDropdownMenuEntry(Difficulty.difficulties.indexOf(e), e),
|
||||
)
|
||||
.toList();
|
||||
|
||||
return DropdownMenu(
|
||||
dropdownMenuEntries: dropdownMenuEntryList,
|
||||
|
||||
Reference in New Issue
Block a user