mifare_nested_scene_failed.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "../mifare_nested_i.h"
  2. void mifare_nested_scene_failed_widget_callback(
  3. GuiButtonType result,
  4. InputType type,
  5. void* context) {
  6. MifareNested* mifare_nested = context;
  7. if(type == InputTypeShort) {
  8. view_dispatcher_send_custom_event(mifare_nested->view_dispatcher, result);
  9. }
  10. }
  11. void mifare_nested_scene_failed_on_enter(void* context) {
  12. MifareNested* mifare_nested = context;
  13. Widget* widget = mifare_nested->widget;
  14. notification_message(mifare_nested->notifications, &sequence_error);
  15. widget_add_icon_element(widget, 73, 13, &I_DolphinCry);
  16. widget_add_string_element(
  17. widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Failed to preform attack");
  18. widget_add_button_element(
  19. widget,
  20. GuiButtonTypeLeft,
  21. "Back",
  22. mifare_nested_scene_failed_widget_callback,
  23. mifare_nested);
  24. // Setup and start worker
  25. view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget);
  26. }
  27. bool mifare_nested_scene_failed_on_event(void* context, SceneManagerEvent event) {
  28. MifareNested* mifare_nested = context;
  29. bool consumed = false;
  30. if(event.type == SceneManagerEventTypeCustom) {
  31. if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) {
  32. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  33. consumed = true;
  34. }
  35. } else if(event.type == SceneManagerEventTypeBack) {
  36. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  37. consumed = true;
  38. }
  39. return consumed;
  40. }
  41. void mifare_nested_scene_failed_on_exit(void* context) {
  42. MifareNested* mifare_nested = context;
  43. widget_reset(mifare_nested->widget);
  44. }