SensorNameEdit_view.c 970 B

1234567891011121314151617181920212223242526272829
  1. #include "UnitempViews.h"
  2. #include <gui/modules/text_input.h>
  3. //Окно ввода текста
  4. static TextInput* text_input;
  5. //Текущий редактируемый датчик
  6. static Sensor* editable_sensor;
  7. #define VIEW_ID UnitempViewSensorNameEdit
  8. static void _sensor_name_changed_callback(void* context) {
  9. UNUSED(context);
  10. unitemp_SensorEdit_switch(editable_sensor);
  11. }
  12. void unitemp_SensorNameEdit_alloc(void) {
  13. text_input = text_input_alloc();
  14. view_dispatcher_add_view(app->view_dispatcher, VIEW_ID, text_input_get_view(text_input));
  15. text_input_set_header_text(text_input, "Sensor name");
  16. }
  17. void unitemp_SensorNameEdit_switch(Sensor* sensor) {
  18. editable_sensor = sensor;
  19. text_input_set_result_callback(
  20. text_input, _sensor_name_changed_callback, app, sensor->name, 11, true);
  21. view_dispatcher_switch_to_view(app->view_dispatcher, VIEW_ID);
  22. }
  23. void unitemp_SensorNameEdit_free(void) {
  24. text_input_free(text_input);
  25. }