nfc_scene_save_success.c 1.7 KB

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