mifare_nested_scene_run_app.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "../mifare_nested_i.h"
  2. void mifare_nested_scene_run_app_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_run_app_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, 73, 13, &I_DolphinCry);
  16. widget_add_string_element(widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "You need to");
  17. widget_add_string_element(widget, 3, 16, AlignLeft, AlignTop, FontPrimary, "recover keys.");
  18. widget_add_string_element(widget, 3, 28, AlignLeft, AlignTop, FontPrimary, "Read README");
  19. widget_add_button_element(
  20. widget,
  21. GuiButtonTypeLeft,
  22. "Back",
  23. mifare_nested_scene_run_app_widget_callback,
  24. mifare_nested);
  25. // Setup and start worker
  26. view_dispatcher_switch_to_view(mifare_nested->view_dispatcher, MifareNestedViewWidget);
  27. }
  28. bool mifare_nested_scene_run_app_on_event(void* context, SceneManagerEvent event) {
  29. MifareNested* mifare_nested = context;
  30. bool consumed = false;
  31. if(event.type == SceneManagerEventTypeCustom) {
  32. if(event.event == GuiButtonTypeCenter || event.event == GuiButtonTypeLeft) {
  33. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  34. consumed = true;
  35. }
  36. } else if(event.type == SceneManagerEventTypeBack) {
  37. scene_manager_search_and_switch_to_previous_scene(mifare_nested->scene_manager, 0);
  38. consumed = true;
  39. }
  40. return consumed;
  41. }
  42. void mifare_nested_scene_run_app_on_exit(void* context) {
  43. MifareNested* mifare_nested = context;
  44. widget_reset(mifare_nested->widget);
  45. }