blackhat_scene_rename.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "../blackhat_app_i.h"
  2. void blackhat_text_input_callback(void* context)
  3. {
  4. furi_assert(context);
  5. BlackhatApp* app = context;
  6. view_dispatcher_send_custom_event(
  7. app->view_dispatcher, BlackhatEventTextInput
  8. );
  9. }
  10. void blackhat_scene_rename_on_enter(void* context)
  11. {
  12. BlackhatApp* app = context;
  13. TextInput* text_input = app->text_input;
  14. text_input_set_result_callback(
  15. text_input,
  16. blackhat_text_input_callback,
  17. context,
  18. app->text_input_ch,
  19. ENTER_NAME_LENGTH,
  20. false
  21. );
  22. view_dispatcher_switch_to_view(
  23. app->view_dispatcher, BlackhatAppViewTextInput
  24. );
  25. }
  26. bool blackhat_scene_rename_on_event(void* context, SceneManagerEvent event)
  27. {
  28. BlackhatApp* app = context;
  29. bool consumed = false;
  30. if (event.type == SceneManagerEventTypeCustom) {
  31. snprintf(
  32. app->text_store,
  33. sizeof(app->text_store),
  34. "%s '%s'\n",
  35. app->selected_tx_string,
  36. app->text_input_ch
  37. );
  38. blackhat_uart_tx(app->uart, app->text_store, strlen(app->text_store));
  39. scene_manager_search_and_switch_to_previous_scene(
  40. app->scene_manager, BlackhatSceneStart
  41. );
  42. consumed = true;
  43. }
  44. return consumed;
  45. }
  46. void blackhat_scene_rename_on_exit(void* context)
  47. {
  48. BlackhatApp* app = context;
  49. variable_item_list_reset(app->var_item_list);
  50. }