nfc_magic_scene_wrong_card.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../nfc_magic_app_i.h"
  2. void nfc_magic_scene_wrong_card_widget_callback(
  3. GuiButtonType result,
  4. InputType type,
  5. void* context) {
  6. NfcMagicApp* instance = context;
  7. if(type == InputTypeShort) {
  8. view_dispatcher_send_custom_event(instance->view_dispatcher, result);
  9. }
  10. }
  11. void nfc_magic_scene_wrong_card_on_enter(void* context) {
  12. NfcMagicApp* instance = context;
  13. Widget* widget = instance->widget;
  14. notification_message(instance->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, instance);
  28. // Setup and start worker
  29. view_dispatcher_switch_to_view(instance->view_dispatcher, NfcMagicAppViewWidget);
  30. }
  31. bool nfc_magic_scene_wrong_card_on_event(void* context, SceneManagerEvent event) {
  32. NfcMagicApp* instance = context;
  33. bool consumed = false;
  34. if(event.type == SceneManagerEventTypeCustom) {
  35. if(event.event == GuiButtonTypeLeft) {
  36. consumed = scene_manager_previous_scene(instance->scene_manager);
  37. }
  38. }
  39. return consumed;
  40. }
  41. void nfc_magic_scene_wrong_card_on_exit(void* context) {
  42. NfcMagicApp* instance = context;
  43. widget_reset(instance->widget);
  44. }