esubghz_chat_chat_box.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /* error condition, exit for real */
  29. state->exit_for_real = true;
  30. view_dispatcher_stop(state->view_dispatcher);
  31. }
  32. consumed = true;
  33. break;
  34. case ESubGhzChatEvent_GotoKeyDisplay:
  35. scene_manager_next_scene(state->scene_manager,
  36. ESubGhzChatScene_KeyDisplay);
  37. consumed = true;
  38. break;
  39. }
  40. break;
  41. default:
  42. consumed = false;
  43. break;
  44. }
  45. return consumed;
  46. }
  47. /* Cleans up the text box scene. */
  48. void scene_on_exit_chat_box(void* context)
  49. {
  50. FURI_LOG_T(APPLICATION_NAME, "scene_on_exit_chat_box");
  51. furi_assert(context);
  52. ESubGhzChatState* state = context;
  53. text_box_reset(state->chat_box);
  54. }