mifare_nested_scene_nonces_collected.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../mifare_nested_i.h"
  2. void mifare_nested_scene_nonces_collected_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_nonces_collected_on_enter(void* context) {
  12. MifareNested* mifare_nested = context;
  13. Widget* widget = mifare_nested->widget;
  14. notification_message(mifare_nested->notifications, &sequence_success);
  15. widget_add_icon_element(widget, 50, 17, &I_DolphinSuccess);
  16. widget_add_string_element(widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "Nonces collected!");
  17. widget_add_button_element(
  18. widget,
  19. GuiButtonTypeLeft,
  20. "Back",
  21. mifare_nested_scene_nonces_collected_widget_callback,
  22. mifare_nested);
  23. // Setup and start worker
  24. view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget);
  25. }
  26. bool mifare_nested_scene_nonces_collected_on_event(void* context, SceneManagerEvent event) {
  27. MifareNested* mifare_nested = context;
  28. bool consumed = false;
  29. if(event.type == SceneManagerEventTypeCustom) {
  30. if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) {
  31. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  32. consumed = true;
  33. }
  34. } else if(event.type == SceneManagerEventTypeBack) {
  35. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  36. consumed = true;
  37. }
  38. return consumed;
  39. }
  40. void mifare_nested_scene_nonces_collected_on_exit(void* context) {
  41. MifareNested* mifare_nested = context;
  42. widget_reset(mifare_nested->widget);
  43. }