[FL-3815] Fix the retry/exit confirmation prompts in iButton (#3613)

This commit is contained in:
Astra 2024-04-24 21:35:15 +09:00 committed by GitHub
parent c87683596a
commit 34abaa7e27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 2 additions and 62 deletions

View File

@ -17,6 +17,5 @@ ADD_SCENE(ibutton, delete_confirm, DeleteConfirm)
ADD_SCENE(ibutton, delete_success, DeleteSuccess) ADD_SCENE(ibutton, delete_success, DeleteSuccess)
ADD_SCENE(ibutton, retry_confirm, RetryConfirm) ADD_SCENE(ibutton, retry_confirm, RetryConfirm)
ADD_SCENE(ibutton, exit_confirm, ExitConfirm) ADD_SCENE(ibutton, exit_confirm, ExitConfirm)
ADD_SCENE(ibutton, read_exit_confirm, ReadExitConfirm)
ADD_SCENE(ibutton, view_data, ViewData) ADD_SCENE(ibutton, view_data, ViewData)
ADD_SCENE(ibutton, rpc, Rpc) ADD_SCENE(ibutton, rpc, Rpc)

View File

@ -1,59 +0,0 @@
#include "../ibutton_i.h"
static void ibutton_scene_read_exit_confirm_widget_callback(
GuiButtonType result,
InputType type,
void* context) {
iButton* ibutton = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(ibutton->view_dispatcher, result);
}
}
void ibutton_scene_read_exit_confirm_on_enter(void* context) {
iButton* ibutton = context;
Widget* widget = ibutton->widget;
widget_add_button_element(
widget,
GuiButtonTypeLeft,
"Exit",
ibutton_scene_read_exit_confirm_widget_callback,
ibutton);
widget_add_button_element(
widget,
GuiButtonTypeRight,
"Stay",
ibutton_scene_read_exit_confirm_widget_callback,
ibutton);
widget_add_string_element(
widget, 64, 19, AlignCenter, AlignBottom, FontPrimary, "Retry Reading?");
widget_add_string_element(
widget, 64, 31, AlignCenter, AlignBottom, FontSecondary, "All unsaved data will be lost!");
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewWidget);
}
bool ibutton_scene_read_exit_confirm_on_event(void* context, SceneManagerEvent event) {
iButton* ibutton = context;
SceneManager* scene_manager = ibutton->scene_manager;
bool consumed = false;
if(event.type == SceneManagerEventTypeBack) {
consumed = true; // Ignore Back button presses
} else if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
if(event.event == GuiButtonTypeLeft) {
scene_manager_search_and_switch_to_previous_scene(scene_manager, iButtonSceneRead);
} else if(event.event == GuiButtonTypeRight) {
scene_manager_previous_scene(scene_manager);
}
}
return consumed;
}
void ibutton_scene_read_exit_confirm_on_exit(void* context) {
iButton* ibutton = context;
widget_reset(ibutton->widget);
}

View File

@ -44,7 +44,7 @@ bool ibutton_scene_read_success_on_event(void* context, SceneManagerEvent event)
if(event.type == SceneManagerEventTypeBack) { if(event.type == SceneManagerEventTypeBack) {
consumed = true; consumed = true;
scene_manager_next_scene(scene_manager, iButtonSceneReadExitConfirm); scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
} else if(event.type == SceneManagerEventTypeCustom) { } else if(event.type == SceneManagerEventTypeCustom) {
consumed = true; consumed = true;
if(event.event == GuiButtonTypeRight) { if(event.event == GuiButtonTypeRight) {

View File

@ -15,7 +15,7 @@ void ibutton_scene_retry_confirm_on_enter(void* context) {
Widget* widget = ibutton->widget; Widget* widget = ibutton->widget;
widget_add_button_element( widget_add_button_element(
widget, GuiButtonTypeLeft, "Exit", ibutton_scene_retry_confirm_widget_callback, ibutton); widget, GuiButtonTypeLeft, "Retry", ibutton_scene_retry_confirm_widget_callback, ibutton);
widget_add_button_element( widget_add_button_element(
widget, GuiButtonTypeRight, "Stay", ibutton_scene_retry_confirm_widget_callback, ibutton); widget, GuiButtonTypeRight, "Stay", ibutton_scene_retry_confirm_widget_callback, ibutton);
widget_add_string_element( widget_add_string_element(