Skip to content

Commit faacefa

Browse files
added size pizza
1 parent e2d96b7 commit faacefa

File tree

7 files changed

+529
-275
lines changed

7 files changed

+529
-275
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:flutter/foundation.dart' show ChangeNotifier, ValueNotifier;
2+
import 'package:flutter_animation/pizza_order/constant/ingredient.dart';
3+
4+
class PizzaOrderBLoC extends ChangeNotifier{
5+
final listIngredients = <Ingredient>[];
6+
final notifierTotal = ValueNotifier(15);
7+
final notifierDeletedIngredient = ValueNotifier<Ingredient>(null);
8+
void addIngredient(Ingredient ingredient){
9+
listIngredients.add(ingredient);
10+
notifierTotal.value++;
11+
}
12+
13+
bool containsIngredient(Ingredient ingredient){
14+
for (Ingredient i in listIngredients) {
15+
if (i.compare(ingredient)) {
16+
return true;
17+
}
18+
}
19+
return false;
20+
}
21+
22+
void removeIngredient(Ingredient ingredient) {
23+
listIngredients.remove(ingredient);
24+
notifierTotal.value--;
25+
notifierDeletedIngredient.value =ingredient;
26+
27+
}
28+
29+
void refreshDeletedIngredient() {
30+
notifierDeletedIngredient.value = null;
31+
}
32+
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_animation/pizza_order/bloc/pizza_order_bloc.dart';
3+
4+
class PizzaOrderProvider extends InheritedWidget {
5+
PizzaOrderProvider({this.bloc, @required this.child}) : super(child: child);
6+
final PizzaOrderBLoC bloc;
7+
final Widget child;
8+
9+
static PizzaOrderBLoC of(BuildContext context) =>
10+
context.findAncestorWidgetOfExactType<PizzaOrderProvider>().bloc;
11+
12+
@override
13+
bool updateShouldNotify(covariant InheritedWidget oldWidget) => true;
14+
}

lib/pizza_order/constent/ingredient.dart renamed to lib/pizza_order/constant/ingredient.dart

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
import 'package:flutter/cupertino.dart';
1+
import 'package:flutter/material.dart';
22

33
class Ingredient {
4-
const Ingredient(this.image,this.positions);
5-
final List<Offset> positions;
4+
const Ingredient(this.image,this.imageUnit, this.positions);
5+
66
final String image;
7+
final List<Offset> positions;
8+
final String imageUnit;
79

810
bool compare(Ingredient i) => i.image == image;
911
}
1012

1113
final ingredients = const <Ingredient>[
1214
Ingredient('assets/pizza_order/chili.png',
13-
<Offset>[
14-
Offset(0.2, 0.2),
15-
Offset(0.6, 0.2),
16-
Offset(0.4, 0.25),
17-
Offset(0.5, 0.3),
18-
Offset(0.4, 0.65)
19-
]),
20-
Ingredient('assets/pizza_order/garlic.png',
15+
'assets/pizza_order/chili_unit.png',
16+
<Offset>[
17+
Offset(0.2, 0.2),
18+
Offset(0.6, 0.2),
19+
Offset(0.4, 0.25),
20+
Offset(0.5, 0.3),
21+
Offset(0.4, 0.65)
22+
]),
23+
Ingredient('assets/pizza_order/mushroom.png',
24+
'assets/pizza_order/mushroom_unit.png',
2125
<Offset>[
2226
Offset(0.2, 0.35),
2327
Offset(0.65, 0.35),
@@ -26,14 +30,16 @@ final ingredients = const <Ingredient>[
2630
Offset(0.3, 0.5)
2731
]),
2832
Ingredient('assets/pizza_order/olive.png',
33+
'assets/pizza_order/olive_unit.png',
2934
<Offset>[
3035
Offset(0.25, 0.5),
31-
Offset(0.65, 0.6),
36+
Offset(0.4, 0.4),
3237
Offset(0.2, 0.3),
3338
Offset(0.4, 0.2),
34-
Offset(0.2, 0.6)
39+
Offset(0.2, 0.45)
3540
]),
3641
Ingredient('assets/pizza_order/onion.png',
42+
'assets/pizza_order/onion.png',
3743
<Offset>[
3844
Offset(0.2, 0.65),
3945
Offset(0.65, 0.3),
@@ -42,6 +48,7 @@ final ingredients = const <Ingredient>[
4248
Offset(0.4, 0.65)
4349
]),
4450
Ingredient('assets/pizza_order/pea.png',
51+
'assets/pizza_order/pea_unit.png',
4552
<Offset>[
4653
Offset(0.2, 0.35),
4754
Offset(0.65, 0.35),
@@ -50,6 +57,7 @@ final ingredients = const <Ingredient>[
5057
Offset(0.3, 0.5)
5158
]),
5259
Ingredient('assets/pizza_order/pickle.png',
60+
'assets/pizza_order/pickle_unit.png',
5361
<Offset>[
5462
Offset(0.2, 0.65),
5563
Offset(0.65, 0.3),
@@ -58,6 +66,7 @@ final ingredients = const <Ingredient>[
5866
Offset(0.4, 0.65)
5967
]),
6068
Ingredient('assets/pizza_order/potato.png',
69+
'assets/pizza_order/potato_unit.png',
6170
<Offset>[
6271
Offset(0.2, 0.2),
6372
Offset(0.6, 0.2),

0 commit comments

Comments
 (0)