nfc_scene_save_success.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "../nfc_i.h"
  2. #include <dolphin/dolphin.h>
  3. #define SCENE_SAVE_SUCCESS_CUSTOM_EVENT (0UL)
  4. void nfc_scene_save_success_popup_callback(void* context) {
  5. Nfc* nfc = (Nfc*)context;
  6. view_dispatcher_send_custom_event(nfc->view_dispatcher, SCENE_SAVE_SUCCESS_CUSTOM_EVENT);
  7. }
  8. void nfc_scene_save_success_on_enter(void* context) {
  9. Nfc* nfc = (Nfc*)context;
  10. DOLPHIN_DEED(DolphinDeedNfcSave);
  11. // Setup view
  12. Popup* popup = nfc->popup;
  13. popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
  14. popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
  15. popup_set_timeout(popup, 1500);
  16. popup_set_context(popup, nfc);
  17. popup_set_callback(popup, nfc_scene_save_success_popup_callback);
  18. popup_enable_timeout(popup);
  19. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
  20. }
  21. bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
  22. Nfc* nfc = (Nfc*)context;
  23. bool consumed = false;
  24. if(event.type == SceneManagerEventTypeCustom) {
  25. if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
  26. if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneCardMenu)) {
  27. consumed = scene_manager_search_and_switch_to_previous_scene(
  28. nfc->scene_manager, NfcSceneCardMenu);
  29. } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
  30. consumed = scene_manager_search_and_switch_to_another_scene(
  31. nfc->scene_manager, NfcSceneFileSelect);
  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 = (Nfc*)context;
  42. // Clear view
  43. Popup* popup = nfc->popup;
  44. popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
  45. popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
  46. popup_set_icon(popup, 0, 0, NULL);
  47. popup_set_callback(popup, NULL);
  48. popup_set_context(popup, NULL);
  49. popup_set_timeout(popup, 0);
  50. popup_disable_timeout(popup);
  51. }