nfc_magic_scene_not_magic.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "../nfc_magic_i.h"
  2. void nfc_magic_scene_not_magic_widget_callback(GuiButtonType result, InputType type, void* context) {
  3. NfcMagic* nfc_magic = context;
  4. if(type == InputTypeShort) {
  5. view_dispatcher_send_custom_event(nfc_magic->view_dispatcher, result);
  6. }
  7. }
  8. void nfc_magic_scene_not_magic_on_enter(void* context) {
  9. NfcMagic* nfc_magic = context;
  10. Widget* widget = nfc_magic->widget;
  11. notification_message(nfc_magic->notifications, &sequence_error);
  12. widget_add_string_element(
  13. widget, 3, 4, AlignLeft, AlignTop, FontPrimary, "This is wrong card");
  14. widget_add_string_multiline_element(
  15. widget, 4, 17, AlignLeft, AlignTop, FontSecondary, "Not magic or unsupported\ncard");
  16. widget_add_button_element(
  17. widget, GuiButtonTypeLeft, "Retry", nfc_magic_scene_not_magic_widget_callback, nfc_magic);
  18. // Setup and start worker
  19. view_dispatcher_switch_to_view(nfc_magic->view_dispatcher, NfcMagicViewWidget);
  20. }
  21. bool nfc_magic_scene_not_magic_on_event(void* context, SceneManagerEvent event) {
  22. NfcMagic* nfc_magic = context;
  23. bool consumed = false;
  24. if(event.type == SceneManagerEventTypeCustom) {
  25. if(event.event == GuiButtonTypeLeft) {
  26. consumed = scene_manager_previous_scene(nfc_magic->scene_manager);
  27. }
  28. }
  29. return consumed;
  30. }
  31. void nfc_magic_scene_not_magic_on_exit(void* context) {
  32. NfcMagic* nfc_magic = context;
  33. widget_reset(nfc_magic->widget);
  34. }