nfc_scene_save_success.c 2.1 KB

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