mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-14 19:53:35 -07:00
Add minimum input length functionality to keyboard
This commit is contained in:
@@ -23,6 +23,7 @@ typedef struct {
|
||||
const char* header;
|
||||
char* text_buffer;
|
||||
size_t text_buffer_size;
|
||||
size_t minimum_length;
|
||||
bool clear_default_text;
|
||||
FuriString* temp_str;
|
||||
|
||||
@@ -441,7 +442,7 @@ static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, I
|
||||
model->text_buffer, model->validator_text, model->validator_callback_context))) {
|
||||
model->validator_message_visible = true;
|
||||
furi_timer_start(text_input->timer, furi_kernel_get_tick_frequency() * 4);
|
||||
} else if(model->callback != 0 && text_length > 0) {
|
||||
} else if(model->callback != 0 && text_length >= model->minimum_length) {
|
||||
model->callback(model->callback_context);
|
||||
}
|
||||
} else if(selected == SWITCH_KEYBOARD_KEY) {
|
||||
@@ -631,6 +632,7 @@ void text_input_reset(TextInput* text_input) {
|
||||
model->selected_row = 0;
|
||||
model->selected_column = 0;
|
||||
model->selected_keyboard = 0;
|
||||
model->minimum_length = 1;
|
||||
model->clear_default_text = false;
|
||||
model->cursor_pos = 0;
|
||||
model->cursor_select = false;
|
||||
@@ -681,6 +683,18 @@ void text_input_set_result_callback(
|
||||
true);
|
||||
}
|
||||
|
||||
void text_input_set_minimum_length(
|
||||
TextInput* text_input,
|
||||
size_t minimum_length) {
|
||||
with_view_model(
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
{
|
||||
model->minimum_length = minimum_length;
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
void text_input_set_validator(
|
||||
TextInput* text_input,
|
||||
TextInputValidatorCallback callback,
|
||||
|
||||
@@ -70,6 +70,10 @@ void text_input_set_validator(
|
||||
TextInputValidatorCallback callback,
|
||||
void* callback_context);
|
||||
|
||||
void text_input_set_minimum_length(
|
||||
TextInput* text_input,
|
||||
size_t minimum_length);
|
||||
|
||||
TextInputValidatorCallback text_input_get_validator_callback(TextInput* text_input);
|
||||
|
||||
void* text_input_get_validator_callback_context(TextInput* text_input);
|
||||
|
||||
@@ -3454,6 +3454,7 @@ Function,+,text_input_get_validator_callback_context,void*,TextInput*
|
||||
Function,+,text_input_get_view,View*,TextInput*
|
||||
Function,+,text_input_reset,void,TextInput*
|
||||
Function,+,text_input_set_header_text,void,"TextInput*, const char*"
|
||||
Function,+,text_input_set_minimum_length,void,"TextInput*, size_t"
|
||||
Function,+,text_input_set_result_callback,void,"TextInput*, TextInputCallback, void*, char*, size_t, _Bool"
|
||||
Function,+,text_input_set_validator,void,"TextInput*, TextInputValidatorCallback, void*"
|
||||
Function,-,tga_save,void,const char*
|
||||
|
||||
|
Reference in New Issue
Block a user