forked from MarsGoatz/CobraChickenEasterEgg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_state.dart
60 lines (47 loc) · 1.22 KB
/
app_state.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'package:mobx/mobx.dart';
part 'app_state.g.dart';
class AppState = _AppState with _$AppState;
abstract class _AppState with Store {
@observable
bool initialized = false;
@observable
String option;
@observable
int cobraChickenRevealTaps = 0;
@observable
ObservableList<String> options =
ObservableList.of([kSlytherin, kGryffindor, kWhatTheDuck]);
@action
void setOption(String newOption) {
option = newOption;
}
@action
void setInitialized() {
initialized = true;
}
@action
void incrementCobraChickenRevealTaps() {
if (cobraChickenRevealTaps <= 10) cobraChickenRevealTaps++;
if (cobraChickenRevealTaps == 10) addCobraChicken();
}
@action
void addCobraChicken() {
options.add(kCobraChicken);
}
@action
void reset() {
options = ObservableList.of([kSlytherin, kGryffindor, kWhatTheDuck]);
cobraChickenRevealTaps = 0;
initialized = false;
}
}
final kSlytherin = "Slytherin";
final kGryffindor = "Gryffindor";
final kWhatTheDuck = "What the duck?";
final kCobraChicken = "Cobra Chicken";
final optionToImageMap = {
kSlytherin: 'slytherin.jpg',
kGryffindor: 'gryffindor.jpg',
kWhatTheDuck: 'duck.jpg',
kCobraChicken: 'cobrachicken.jpg'
};