nfc_magic_scene_wrong_card.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../nfc_magic_i.h"
  2. void nfc_magic_scene_wrong_card_widget_callback(
  3. GuiButtonType result,
  4. InputType type,
  5. void* context) {
  6. NfcMagic* nfc_magic = context;
  7. if(type == InputTypeShort) {
  8. view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
  9. }
  10. }
  11. void nfc_magic_scene_wrong_card_on_enter(void* context) {
  12. NfcMagic* nfc_magic = context;
  13. Widget* widget = nfc_magic->widget;
  14. notification_message(nfc_magic->notifications, &sequence_error);
  15. widget_add_icon_element(widget, 73, 17, &I_DolphinCommon_56x48);
  16. widget_add_string_element(
  17. widget, 1, 4, AlignLeft, AlignTop, FontPrimary, "This is wrong card");
  18. widget_add_string_multiline_element(
  19. widget,
  20. 1,
  21. 17,
  22. AlignLeft,
  23. AlignTop,
  24. FontSecondary,
  25. "Writing this file is\nnot supported for\nthis magic card.");
  26. widget_add_button_element(
  27. widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_wrong_card_widget_callback, nfc_magic);
  28. // Setup and start worker
  29. view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
  30. }
  31. bool nfc_magic_scene_wrong_card_on_event(void* context, SceneManagerEvent event) {
  32. NfcMagic* nfc_magic = context;
  33. bool consumed = false;
  34. if(event.type == SceneManagerEventTypeCustom) {
  35. if(event.event == GuiButtonTypeLeft) {
  36. consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
  37. }
  38. }
  39. return consumed;
  40. }
  41. void nfc_magic_scene_wrong_card_on_exit(void* context) {
  42. NfcMagic* nfc_magic = context;
  43. widget_reset(nfc_magic->widget);
  44. }