nfc_scene_save_success.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. void nfc_scene_save_success_popup_callback(void* context) {
  4. Nfc* nfc = context;
  5. view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventViewExit);
  6. }
  7. void nfc_scene_save_success_on_enter(void* context) {
  8. Nfc* nfc = context;
  9. DOLPHIN_DEED(DolphinDeedNfcSave);
  10. // Setup view
  11. Popup* popup = nfc->popup;
  12. popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
  13. popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
  14. popup_set_timeout(popup, 1500);
  15. popup_set_context(popup, nfc);
  16. popup_set_callback(popup, nfc_scene_save_success_popup_callback);
  17. popup_enable_timeout(popup);
  18. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  19. }
  20. bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
  21. Nfc* nfc = context;
  22. bool consumed = false;
  23. if(event.type == SceneManagerEventTypeCustom) {
  24. if(event.event == NfcCustomEventViewExit) {
  25. if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneCardMenu)) {
  26. consumed = scene_manager_search_and_switch_to_previous_scene(
  27. nfc->scene_manager, NfcSceneCardMenu);
  28. } else if(scene_manager_has_previous_scene(
  29. nfc->scene_manager, NfcSceneMifareDesfireMenu)) {
  30. consumed = scene_manager_search_and_switch_to_previous_scene(
  31. nfc->scene_manager, NfcSceneMifareDesfireMenu);
  32. } else {
  33. consumed = scene_manager_search_and_switch_to_previous_scene(
  34. nfc->scene_manager, NfcSceneStart);
  35. }
  36. }
  37. }
  38. return consumed;
  39. }
  40. void nfc_scene_save_success_on_exit(void* context) {
  41. Nfc* nfc = context;
  42. // Clear view
  43. popup_reset(nfc->popup);
  44. }