mifare_nested_scene_need_collection.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "../mifare_nested_i.h"
  2. void mifare_nested_scene_need_collection_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_need_collection_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, 0, 4, AlignLeft, AlignTop, FontPrimary, "You need to collect");
  18. widget_add_string_element(widget, 0, 16, AlignLeft, AlignTop, FontPrimary, "nonces");
  19. widget_add_string_element(widget, 1, 28, AlignLeft, AlignTop, FontPrimary, "Run \"Nested");
  20. widget_add_string_element(widget, 1, 40, AlignLeft, AlignTop, FontPrimary, "attack\"");
  21. widget_add_button_element(
  22. widget,
  23. GuiButtonTypeLeft,
  24. "Back",
  25. mifare_nested_scene_need_collection_widget_callback,
  26. mifare_nested);
  27. // Setup and start worker
  28. view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget);
  29. }
  30. bool mifare_nested_scene_need_collection_on_event(void* context, SceneManagerEvent event) {
  31. MifareNested* mifare_nested = context;
  32. bool consumed = false;
  33. if(event.type == SceneManagerEventTypeCustom) {
  34. if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) {
  35. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  36. consumed = true;
  37. }
  38. } else if(event.type == SceneManagerEventTypeBack) {
  39. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  40. consumed = true;
  41. }
  42. return consumed;
  43. }
  44. void mifare_nested_scene_need_collection_on_exit(void* context) {
  45. MifareNested* mifare_nested = context;
  46. widget_reset(mifare_nested->widget);
  47. }