Line data Source code
1 : import 'package:amadeus_proto/exercises/exercises_provider.dart';
2 :
3 : enum RhythmState { start, playing, end, done }
4 :
5 : class BeatsClickingProvider extends ExerciseProvider {
6 : int _startMilliseconds = 0;
7 : List<int> _pressed = [];
8 : String _rhythmImage = "";
9 : List<int> _timers = [];
10 : int _gap = 0;
11 :
12 : RhythmState _playing = RhythmState.start;
13 :
14 0 : String get rhythmImage => _rhythmImage;
15 0 : set rhythmImage(String value) {
16 0 : _rhythmImage = value;
17 0 : notifyListeners();
18 : }
19 :
20 0 : List<int> get timers => _timers;
21 0 : set timers(List<int> value) {
22 0 : _timers = value;
23 0 : notifyListeners();
24 : }
25 :
26 0 : int get gap => _gap;
27 0 : set gap(int value) {
28 0 : _gap = value;
29 0 : notifyListeners();
30 : }
31 :
32 0 : int get startMilliseconds => _startMilliseconds;
33 0 : set startMilliseconds(int value) {
34 0 : _startMilliseconds = value;
35 0 : notifyListeners();
36 : }
37 :
38 0 : List<int> get pressed => _pressed;
39 0 : RhythmState get playing => _playing;
40 0 : set playing(RhythmState playing) {
41 0 : _playing = playing;
42 0 : notifyListeners();
43 : }
44 :
45 0 : @override
46 : void reset() {
47 0 : _startMilliseconds = 0;
48 0 : _pressed = [];
49 0 : _playing = RhythmState.start;
50 0 : isInitialized = false;
51 0 : displayDialog = false;
52 : }
53 :
54 0 : void resetNotify() {
55 0 : _startMilliseconds = 0;
56 0 : _pressed = [];
57 0 : _playing = RhythmState.start;
58 0 : notifyListeners();
59 : }
60 :
61 0 : void addPressed(int value) {
62 0 : _pressed.add(value);
63 0 : notifyListeners();
64 : }
65 :
66 0 : void initializeData(dynamic data) {
67 0 : question = data["question"];
68 0 : lives = data["lives"];
69 :
70 0 : rhythmImage = data["assetImage"];
71 0 : timers = data["timers"].cast<int>();
72 0 : gap = data["gap"];
73 0 : isInitialized = true;
74 : }
75 : }
|