nfc_scene_save_success.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. void nfc_scene_save_success_popup_callback(void* context) {
  4. Nfc* 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 = (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 = (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(nfc->scene_manager, NfcSceneSetType)) {
  29. consumed = scene_manager_search_and_switch_to_another_scene(
  30. nfc->scene_manager, NfcSceneFileSelect);
  31. } else if(scene_manager_has_previous_scene(
  32. nfc->scene_manager, NfcSceneMifareDesfireMenu)) {
  33. consumed = scene_manager_search_and_switch_to_previous_scene(
  34. nfc->scene_manager, NfcSceneMifareDesfireMenu);
  35. } else {
  36. consumed = scene_manager_search_and_switch_to_previous_scene(
  37. nfc->scene_manager, NfcSceneStart);
  38. }
  39. }
  40. }
  41. return consumed;
  42. }
  43. void nfc_scene_save_success_on_exit(void* context) {
  44. Nfc* nfc = (Nfc*)context;
  45. // Clear view
  46. Popup* popup = nfc->popup;
  47. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  48. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  49. popup_set_icon(popup, 0, 0, NULL);
  50. popup_set_callback(popup, NULL);
  51. popup_set_context(popup, NULL);
  52. popup_set_timeout(popup, 0);
  53. popup_disable_timeout(popup);
  54. }