nfc_scene_save_success.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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, NfcSceneSavedMenu)) {
  26. consumed = scene_manager_search_and_switch_to_previous_scene(
  27. nfc->scene_manager, NfcSceneSavedMenu);
  28. } else {
  29. consumed = scene_manager_search_and_switch_to_another_scene(
  30. nfc->scene_manager, NfcSceneFileSelect);
  31. }
  32. }
  33. }
  34. return consumed;
  35. }
  36. void nfc_scene_save_success_on_exit(void* context) {
  37. Nfc* nfc = context;
  38. // Clear view
  39. popup_reset(nfc->popup);
  40. }