uhf_scene_save_success.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../uhf_app_i.h"
  2. #include <dolphin/dolphin.h>
  3. void uhf_scene_save_success_popup_callback(void* context) {
  4. UHFApp* uhf_app = context;
  5. view_dispatcher_send_custom_event(uhf_app->view_dispatcher, UHFCustomEventViewExit);
  6. }
  7. void uhf_scene_save_success_on_enter(void* context) {
  8. UHFApp* uhf_app = context;
  9. dolphin_deed(DolphinDeedNfcSave);
  10. // Setup view
  11. Popup* popup = uhf_app->popup;
  12. popup_set_icon(popup, 36, 5, &I_DolphinDone_80x58);
  13. popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
  14. popup_set_timeout(popup, 1500);
  15. popup_set_context(popup, uhf_app);
  16. popup_set_callback(popup, uhf_scene_save_success_popup_callback);
  17. popup_enable_timeout(popup);
  18. view_dispatcher_switch_to_view(uhf_app->view_dispatcher, UHFViewPopup);
  19. }
  20. bool uhf_scene_save_success_on_event(void* context, SceneManagerEvent event) {
  21. UHFApp* uhf_app = context;
  22. bool consumed = false;
  23. if(event.type == SceneManagerEventTypeCustom) {
  24. if(event.event == UHFCustomEventViewExit) {
  25. if(scene_manager_has_previous_scene(uhf_app->scene_manager, UHFSceneTagMenu)) {
  26. consumed = scene_manager_search_and_switch_to_previous_scene(
  27. uhf_app->scene_manager, UHFSceneTagMenu);
  28. } else {
  29. consumed = scene_manager_search_and_switch_to_previous_scene(
  30. uhf_app->scene_manager, UHFSceneStart);
  31. }
  32. }
  33. }
  34. return consumed;
  35. }
  36. void uhf_scene_save_success_on_exit(void* context) {
  37. UHFApp* uhf_app = context;
  38. // Clear view
  39. popup_reset(uhf_app->popup);
  40. }