3
3
#include <gui/elements.h>
4
4
5
5
typedef enum {
6
+ DictAttackStateStart ,
6
7
DictAttackStateRead ,
7
8
DictAttackStateCardRemoved ,
8
9
} DictAttackState ;
@@ -29,7 +30,12 @@ typedef struct {
29
30
30
31
static void dict_attack_draw_callback (Canvas * canvas , void * model ) {
31
32
DictAttackViewModel * m = model ;
32
- if (m -> state == DictAttackStateCardRemoved ) {
33
+ if (m -> state == DictAttackStateStart ) {
34
+ canvas_draw_icon (canvas , 0 , 8 , & I_RFIDDolphinReceive_97x61 );
35
+ canvas_set_font (canvas , FontPrimary );
36
+ elements_multiline_text_aligned (
37
+ canvas , 128 , 40 , AlignRight , AlignCenter , "Apply card to\nthe back" );
38
+ } else if (m -> state == DictAttackStateCardRemoved ) {
33
39
canvas_set_font (canvas , FontPrimary );
34
40
canvas_draw_str_aligned (canvas , 64 , 4 , AlignCenter , AlignTop , "Lost the tag!" );
35
41
canvas_set_font (canvas , FontSecondary );
@@ -78,8 +84,8 @@ static void dict_attack_draw_callback(Canvas* canvas, void* model) {
78
84
m -> sectors_read ,
79
85
m -> sectors_total );
80
86
canvas_draw_str_aligned (canvas , 0 , 43 , AlignLeft , AlignTop , draw_str );
87
+ elements_button_center (canvas , "Skip" );
81
88
}
82
- elements_button_center (canvas , "Skip" );
83
89
}
84
90
85
91
static bool dict_attack_input_callback (InputEvent * event , void * context ) {
@@ -126,7 +132,7 @@ void dict_attack_reset(DictAttack* dict_attack) {
126
132
dict_attack -> view ,
127
133
DictAttackViewModel * model ,
128
134
{
129
- model -> state = DictAttackStateRead ;
135
+ model -> state = DictAttackStateStart ;
130
136
model -> sectors_total = 1 ;
131
137
model -> sectors_read = 0 ;
132
138
model -> sector_current = 0 ;
@@ -181,7 +187,12 @@ void dict_attack_set_card_removed(DictAttack* dict_attack) {
181
187
with_view_model (
182
188
dict_attack -> view ,
183
189
DictAttackViewModel * model ,
184
- { model -> state = DictAttackStateCardRemoved ; },
190
+ {
191
+ // Only mark card as removed it if had been Read
192
+ if (model -> state == DictAttackStateRead ) {
193
+ model -> state = DictAttackStateCardRemoved ;
194
+ }
195
+ },
185
196
true);
186
197
}
187
198
0 commit comments