forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from leedave/feature/addTextNumberInputs
Feature/add text number inputs
- Loading branch information
Showing
10 changed files
with
151 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "../boilerplate.h" | ||
|
||
void boilerplate_scene_scene_5_text_input_callback(void* context) { | ||
furi_assert(context); | ||
Boilerplate* app = context; | ||
view_dispatcher_send_custom_event(app->view_dispatcher, 0); | ||
} | ||
|
||
void boilerplate_scene_scene_5_on_enter(void* context) { | ||
Boilerplate* app = context; | ||
TextInput* text_input = app->text_input; | ||
|
||
text_input_set_header_text(text_input, "This is a custom text"); | ||
|
||
size_t enter_name_length = 32; | ||
text_input_set_result_callback( | ||
text_input, | ||
boilerplate_scene_scene_5_text_input_callback, | ||
context, | ||
app->text_store[0], | ||
enter_name_length, | ||
false); | ||
|
||
view_dispatcher_switch_to_view(app->view_dispatcher, BoilerplateViewIdTextInput); | ||
} | ||
|
||
bool boilerplate_scene_scene_5_on_event(void* context, SceneManagerEvent event) { | ||
Boilerplate* app = context; | ||
bool consumed = false; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { //Back button pressed | ||
scene_manager_previous_scene(app->scene_manager); | ||
return true; | ||
} | ||
return consumed; | ||
} | ||
|
||
void boilerplate_scene_scene_5_on_exit(void* context) { | ||
UNUSED(context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "../boilerplate.h" | ||
|
||
void boilerplate_scene_6_callback(void* context, int32_t number) { | ||
Boilerplate* app = context; | ||
app->current_number = number; | ||
view_dispatcher_send_custom_event(app->view_dispatcher, 0); | ||
} | ||
|
||
void boilerplate_scene_scene_6_on_enter(void* context) { | ||
furi_assert(context); | ||
Boilerplate* app = context; | ||
NumberInput* number_input = app->number_input; | ||
|
||
char str[50]; | ||
int32_t min_value = -128; | ||
int32_t max_value = 2048; | ||
snprintf(str, sizeof(str), "Set Number (%ld - %ld)", min_value, max_value); | ||
|
||
number_input_set_header_text(number_input, str); | ||
number_input_set_result_callback( | ||
number_input, | ||
boilerplate_scene_6_callback, | ||
context, | ||
app->current_number, | ||
min_value, | ||
max_value); | ||
|
||
view_dispatcher_switch_to_view(app->view_dispatcher, BoilerplateViewIdNumberInput); | ||
} | ||
|
||
bool boilerplate_scene_scene_6_on_event(void* context, SceneManagerEvent event) { | ||
Boilerplate* app = context; | ||
bool consumed = false; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { //Back button pressed | ||
scene_manager_previous_scene(app->scene_manager); | ||
return true; | ||
} | ||
return consumed; | ||
} | ||
|
||
void boilerplate_scene_scene_6_on_exit(void* context) { | ||
UNUSED(context); | ||
} |