xremote_scene_save_remote_item.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "../xremote.h"
  2. #include "../models/cross/xremote_cross_remote.h"
  3. #include <string.h>
  4. #include <toolbox/path.h>
  5. void xremote_scene_save_remote_item_on_enter(void* context) {
  6. XRemote* app = context;
  7. TextInput* text_input = app->text_input;
  8. text_input_set_header_text(text_input, "Name the Sequence");
  9. size_t enter_name_length = XREMOTE_MAX_REMOTE_NAME_LENGTH;
  10. CrossRemoteItem* item = xremote_cross_remote_get_item(app->cross_remote, app->edit_item);
  11. strncpy(app->text_store[0], furi_string_get_cstr(item->name), enter_name_length);
  12. text_input_set_result_callback(
  13. text_input,
  14. xremote_text_input_callback,
  15. context,
  16. app->text_store[0],
  17. enter_name_length,
  18. false);
  19. view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdTextInput);
  20. }
  21. bool xremote_scene_save_remote_item_on_event(void* context, SceneManagerEvent event) {
  22. XRemote* app = context;
  23. CrossRemote* remote = app->cross_remote;
  24. SceneManager* scene_manager = app->scene_manager;
  25. bool consumed = false;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. xremote_cross_remote_rename_item(remote, app->edit_item, app->text_store[0]);
  28. scene_manager_next_scene(scene_manager, XRemoteSceneCreate);
  29. consumed = true;
  30. }
  31. return consumed;
  32. }
  33. void xremote_scene_save_remote_item_on_exit(void* context) {
  34. XRemote* app = context;
  35. size_t enter_name_length = XREMOTE_MAX_REMOTE_NAME_LENGTH;
  36. strncpy(app->text_store[0], "", enter_name_length);
  37. }