infrared_scene_learn_done.c 1.4 KB

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