infrared_scene_learn_done.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../infrared_i.h"
  2. #include <dolphin/dolphin.h>
  3. void infrared_scene_learn_done_on_enter(void* context) {
  4. Infrared* infrared = context;
  5. Popup* popup = infrared->popup;
  6. popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
  7. DOLPHIN_DEED(DolphinDeedIrSave);
  8. if(infrared->app_state.is_learning_new_remote) {
  9. popup_set_header(popup, "New remote\ncreated!", 0, 0, AlignLeft, AlignTop);
  10. } else {
  11. popup_set_header(popup, "Saved!", 5, 7, AlignLeft, AlignTop);
  12. }
  13. popup_set_callback(popup, infrared_popup_closed_callback);
  14. popup_set_context(popup, context);
  15. popup_set_timeout(popup, 1500);
  16. popup_enable_timeout(popup);
  17. view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
  18. }
  19. bool infrared_scene_learn_done_on_event(void* context, SceneManagerEvent event) {
  20. Infrared* infrared = context;
  21. bool consumed = false;
  22. if(event.type == SceneManagerEventTypeCustom) {
  23. if(event.event == InfraredCustomEventTypePopupClosed) {
  24. if(!scene_manager_search_and_switch_to_previous_scene(
  25. infrared->scene_manager, InfraredSceneRemote)) {
  26. scene_manager_next_scene(infrared->scene_manager, InfraredSceneRemote);
  27. }
  28. consumed = true;
  29. }
  30. }
  31. return consumed;
  32. }
  33. void infrared_scene_learn_done_on_exit(void* context) {
  34. Infrared* infrared = context;
  35. infrared->app_state.is_learning_new_remote = false;
  36. popup_set_header(infrared->popup, NULL, 0, 0, AlignLeft, AlignTop);
  37. }