|
| 1 | +#include "../picopass_i.h" |
| 2 | +#include <dolphin/dolphin.h> |
| 3 | + |
| 4 | +void picopass_scene_write_card_failure_widget_callback( |
| 5 | + GuiButtonType result, |
| 6 | + InputType type, |
| 7 | + void* context) { |
| 8 | + furi_assert(context); |
| 9 | + Picopass* picopass = context; |
| 10 | + |
| 11 | + if(type == InputTypeShort) { |
| 12 | + view_dispatcher_send_custom_event(picopass->view_dispatcher, result); |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +void picopass_scene_write_card_failure_on_enter(void* context) { |
| 17 | + Picopass* picopass = context; |
| 18 | + Widget* widget = picopass->widget; |
| 19 | + FuriString* str = furi_string_alloc_set("Write Failure!"); |
| 20 | + |
| 21 | + widget_add_button_element( |
| 22 | + widget, |
| 23 | + GuiButtonTypeLeft, |
| 24 | + "Retry", |
| 25 | + picopass_scene_write_card_failure_widget_callback, |
| 26 | + picopass); |
| 27 | + |
| 28 | + widget_add_button_element( |
| 29 | + widget, |
| 30 | + GuiButtonTypeRight, |
| 31 | + "Menu", |
| 32 | + picopass_scene_write_card_failure_widget_callback, |
| 33 | + picopass); |
| 34 | + |
| 35 | + widget_add_string_element( |
| 36 | + widget, 64, 5, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(str)); |
| 37 | + |
| 38 | + furi_string_free(str); |
| 39 | + |
| 40 | + view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget); |
| 41 | +} |
| 42 | + |
| 43 | +bool picopass_scene_write_card_failure_on_event(void* context, SceneManagerEvent event) { |
| 44 | + Picopass* picopass = context; |
| 45 | + bool consumed = false; |
| 46 | + |
| 47 | + if(event.type == SceneManagerEventTypeCustom) { |
| 48 | + if(event.event == GuiButtonTypeLeft) { |
| 49 | + consumed = scene_manager_previous_scene(picopass->scene_manager); |
| 50 | + } else if(event.event == GuiButtonTypeRight) { |
| 51 | + // Clear device name |
| 52 | + picopass_device_set_name(picopass->dev, ""); |
| 53 | + consumed = scene_manager_search_and_switch_to_previous_scene( |
| 54 | + picopass->scene_manager, PicopassSceneStart); |
| 55 | + } |
| 56 | + } |
| 57 | + return consumed; |
| 58 | +} |
| 59 | + |
| 60 | +void picopass_scene_write_card_failure_on_exit(void* context) { |
| 61 | + Picopass* picopass = context; |
| 62 | + |
| 63 | + // Clear view |
| 64 | + widget_reset(picopass->widget); |
| 65 | +} |
0 commit comments