diff --git a/scenes/gemini_scene_config.h b/scenes/gemini_scene_config.h index a4a7f159b37..caa86fab1d7 100644 --- a/scenes/gemini_scene_config.h +++ b/scenes/gemini_scene_config.h @@ -2,5 +2,6 @@ ADD_SCENE(gemini, main_menu, MainMenu) ADD_SCENE(gemini, receive_serial, ReceiveSerial) ADD_SCENE(gemini, set_name, SetName) ADD_SCENE(gemini, send_known_aps, SendKnownAps) +ADD_SCENE(gemini, start_chatting, StartChatting) ADD_SCENE(gemini, missing_api_key, MissingApiKey) ADD_SCENE(gemini, under_construction, UnderConstruction) diff --git a/scenes/gemini_scene_main_menu.c b/scenes/gemini_scene_main_menu.c index 530f593d432..54af03c8cc6 100644 --- a/scenes/gemini_scene_main_menu.c +++ b/scenes/gemini_scene_main_menu.c @@ -104,8 +104,7 @@ bool gemini_scene_main_menu_on_event(void* context, SceneManagerEvent event) { consumed = true; break; case GeminiSceneMainMenuEventStartChatting: - // TODO: Replace with correct scene - scene_manager_next_scene(app->scene_manager, GeminiSceneUnderConstruction); + scene_manager_next_scene(app->scene_manager, GeminiSceneStartChatting); consumed = true; break; case GeminiSceneMainMenuEventHelp: diff --git a/scenes/gemini_scene_set_name.c b/scenes/gemini_scene_set_name.c index 30aad153e73..56b39add343 100644 --- a/scenes/gemini_scene_set_name.c +++ b/scenes/gemini_scene_set_name.c @@ -1,7 +1,7 @@ #include "../gemini_app_i.h" #define TEXT_BUFFER_SIZE 64 -char text_buffer[TEXT_BUFFER_SIZE]; +static char text_buffer[TEXT_BUFFER_SIZE]; enum { GeminiSceneSetNameEventOk, diff --git a/scenes/gemini_scene_start_chatting.c b/scenes/gemini_scene_start_chatting.c new file mode 100644 index 00000000000..911ecc01ad1 --- /dev/null +++ b/scenes/gemini_scene_start_chatting.c @@ -0,0 +1,49 @@ +#include "../gemini_app_i.h" + +#define TEXT_BUFFER_SIZE 128 +static char text_buffer[TEXT_BUFFER_SIZE]; + +enum { + GeminiSceneStartChattingEventOk, +} GeminiSceneStartChattingEvent; + +static void gemini_scene_start_chatting_text_input_callback(void* context) { + GeminiApp* app = context; + scene_manager_handle_custom_event(app->scene_manager, GeminiSceneStartChattingEventOk); +} + +void gemini_scene_start_chatting_on_enter(void* context) { + GeminiApp* app = context; + text_input_set_header_text(app->text_input, "Enter message"); + text_input_set_minimum_length(app->text_input, 0); + text_buffer[0] = '\0'; + text_input_set_result_callback(app->text_input, gemini_scene_start_chatting_text_input_callback, app, text_buffer, TEXT_BUFFER_SIZE, true); + view_dispatcher_switch_to_view(app->view_dispatcher, GeminiViewTextInput); +} + +bool gemini_scene_start_chatting_on_event(void* context, SceneManagerEvent event) { + GeminiApp* app = context; + bool consumed = false; + if (event.type == SceneManagerEventTypeCustom) { + switch(event.event) { + case GeminiSceneStartChattingEventOk: + if (strlen(text_buffer) > 0) { + uart_helper_send(app->uart_helper, text_buffer, 0); + // We want BACK to go back to the start chatting scene. + gemini_scene_receive_serial_set_next(app, GeminiSceneStartChatting); + scene_manager_search_and_switch_to_another_scene(app->scene_manager, GeminiSceneReceiveSerial); + consumed = true; + } else { + scene_manager_previous_scene(app->scene_manager); + consumed = true; + } + break; + } + } + + return consumed; +} + +void gemini_scene_start_chatting_on_exit(void* context) { + UNUSED(context); +} \ No newline at end of file