esubghz_chat_chat_box.c 1.8 KB

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