esubghz_chat_chat_box.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "../esubghz_chat_i.h"
  2. /* Prepares the text box scene. */
  3. void scene_on_enter_chat_box(void* context)
  4. {
  5. FURI_LOG_T(APPLICATION_NAME, "scene_on_enter_chat_box");
  6. furi_assert(context);
  7. ESubGhzChatState* state = context;
  8. text_box_reset(state->chat_box);
  9. text_box_set_text(state->chat_box,
  10. furi_string_get_cstr(state->chat_box_store));
  11. text_box_set_focus(state->chat_box, TextBoxFocusEnd);
  12. view_dispatcher_switch_to_view(state->view_dispatcher, ESubGhzChatView_ChatBox);
  13. }
  14. /* Handles scene manager events for the text box scene. */
  15. bool scene_on_event_chat_box(void* context, SceneManagerEvent event)
  16. {
  17. FURI_LOG_T(APPLICATION_NAME, "scene_on_event_chat_box");
  18. furi_assert(context);
  19. ESubGhzChatState* state = context;
  20. bool consumed = false;
  21. switch(event.type) {
  22. case SceneManagerEventTypeCustom:
  23. switch(event.event) {
  24. /* switch to message input scene */
  25. case ESubGhzChatEvent_GotoMsgInput:
  26. if (!scene_manager_previous_scene(
  27. state->scene_manager)) {
  28. view_dispatcher_stop(state->view_dispatcher);
  29. }
  30. consumed = true;
  31. break;
  32. case ESubGhzChatEvent_GotoKeyDisplay:
  33. scene_manager_next_scene(state->scene_manager,
  34. ESubGhzChatScene_KeyDisplay);
  35. consumed = true;
  36. break;
  37. }
  38. break;
  39. default:
  40. consumed = false;
  41. break;
  42. }
  43. return consumed;
  44. }
  45. /* Cleans up the text box scene. */
  46. void scene_on_exit_chat_box(void* context)
  47. {
  48. FURI_LOG_T(APPLICATION_NAME, "scene_on_exit_chat_box");
  49. furi_assert(context);
  50. ESubGhzChatState* state = context;
  51. text_box_reset(state->chat_box);
  52. }