jblanked 1 год назад
Родитель
Сommit
e9db74d049
2 измененных файлов с 55 добавлено и 1 удалено
  1. 36 0
      easy_flipper/easy_flipper.c
  2. 19 1
      easy_flipper/easy_flipper.h

+ 36 - 0
easy_flipper/easy_flipper.c

@@ -587,4 +587,40 @@ bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer
     }
     }
     furi_string_set_str(*furi_string, buffer);
     furi_string_set_str(*furi_string, buffer);
     return true;
     return true;
+}
+
+bool easy_flipper_set_text_box(
+    TextBox **text_box,
+    int32_t view_id,
+    char *text,
+    bool start_at_end,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher)
+{
+    if (!text_box)
+    {
+        FURI_LOG_E(EASY_TAG, "Invalid arguments provided to set_text_box");
+        return false;
+    }
+    *text_box = text_box_alloc();
+    if (!*text_box)
+    {
+        FURI_LOG_E(EASY_TAG, "Failed to allocate TextBox");
+        return false;
+    }
+    if (text)
+    {
+        text_box_set_text(*text_box, text);
+    }
+    if (previous_callback)
+    {
+        view_set_previous_callback(text_box_get_view(*text_box), previous_callback);
+    }
+    text_box_set_font(*text_box, TextBoxFontText);
+    if (start_at_end)
+    {
+        text_box_set_focus(*text_box, TextBoxFocusEnd);
+    }
+    view_dispatcher_add_view(*view_dispatcher, view_id, text_box_get_view(*text_box));
+    return true;
 }
 }

+ 19 - 1
easy_flipper/easy_flipper.h

@@ -23,8 +23,8 @@
 #include <text_input/uart_text_input.h>
 #include <text_input/uart_text_input.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
-#include <jsmn/jsmn.h>
 #include <jsmn/jsmn_furi.h>
 #include <jsmn/jsmn_furi.h>
+#include <jsmn/jsmn.h>
 
 
 #define EASY_TAG "EasyFlipper"
 #define EASY_TAG "EasyFlipper"
 
 
@@ -267,4 +267,22 @@ bool easy_flipper_set_loading(
  */
  */
 bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer);
 bool easy_flipper_set_char_to_furi_string(FuriString **furi_string, char *buffer);
 
 
+/**
+ * @brief Initialize a TextBox object
+ * @param text_box The TextBox object to initialize
+ * @param view_id The ID/Index of the view
+ * @param text The text to display in the text box
+ * @param start_at_end Start the text box at the end
+ * @param previous_callback The previous callback function (can be set to NULL)
+ * @param view_dispatcher The ViewDispatcher object
+ * @return true if successful, false otherwise
+ */
+bool easy_flipper_set_text_box(
+    TextBox **text_box,
+    int32_t view_id,
+    char *text,
+    bool start_at_end,
+    uint32_t(previous_callback)(void *),
+    ViewDispatcher **view_dispatcher);
+
 #endif
 #endif