[FL-2344] iButton deleted back button (#1096)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Dmitry Pavlov 2022-04-11 14:59:50 +03:00 committed by GitHub
parent b22ad77bbe
commit a25552eb99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 27 deletions

View File

@ -22,7 +22,7 @@ void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) {
app->set_text_store("\e#Delete %s?\e#", ibutton_key_get_name_p(key));
widget_add_text_box_element(
widget, 0, 0, 128, 27, AlignCenter, AlignCenter, app->get_text_store());
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", widget_callback, app);
widget_add_button_element(widget, GuiButtonTypeLeft, "Cancel", widget_callback, app);
widget_add_button_element(widget, GuiButtonTypeRight, "Delete", widget_callback, app);
switch(ibutton_key_get_type(key)) {

View File

@ -1,18 +1,6 @@
#include "ibutton_scene_info.h"
#include "../ibutton_app.h"
static void widget_callback(GuiButtonType result, InputType type, void* context) {
furi_assert(context);
iButtonApp* app = static_cast<iButtonApp*>(context);
iButtonEvent event;
if(type == InputTypeShort) {
event.type = iButtonEvent::Type::EventTypeWidgetButtonResult;
event.payload.widget_button_result = result;
app->get_view_manager()->send_event(&event);
}
}
void iButtonSceneInfo::on_enter(iButtonApp* app) {
iButtonAppViewManager* view_manager = app->get_view_manager();
Widget* widget = view_manager->get_widget();
@ -21,8 +9,7 @@ void iButtonSceneInfo::on_enter(iButtonApp* app) {
app->set_text_store("%s", ibutton_key_get_name_p(key));
widget_add_text_box_element(
widget, 0, 0, 128, 27, AlignCenter, AlignCenter, app->get_text_store());
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", widget_callback, app);
widget, 0, 0, 128, 28, AlignCenter, AlignCenter, app->get_text_store());
switch(ibutton_key_get_type(key)) {
case iButtonKeyDS1990:
@ -37,36 +24,28 @@ void iButtonSceneInfo::on_enter(iButtonApp* app) {
key_data[6],
key_data[7]);
widget_add_string_element(
widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Dallas");
widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Dallas");
break;
case iButtonKeyMetakom:
app->set_text_store(
"%02X %02X %02X %02X", key_data[0], key_data[1], key_data[2], key_data[3]);
widget_add_string_element(
widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Metakom");
widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Metakom");
break;
case iButtonKeyCyfral:
app->set_text_store("%02X %02X", key_data[0], key_data[1]);
widget_add_string_element(
widget, 64, 45, AlignCenter, AlignBottom, FontSecondary, "Cyfral");
widget, 64, 51, AlignCenter, AlignBottom, FontSecondary, "Cyfral");
break;
}
widget_add_string_element(
widget, 64, 33, AlignCenter, AlignBottom, FontPrimary, app->get_text_store());
widget, 64, 35, AlignCenter, AlignBottom, FontPrimary, app->get_text_store());
view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewWidget);
}
bool iButtonSceneInfo::on_event(iButtonApp* app, iButtonEvent* event) {
bool consumed = false;
if(event->type == iButtonEvent::Type::EventTypeWidgetButtonResult) {
if(event->payload.widget_button_result == GuiButtonTypeLeft) {
app->switch_to_previous_scene();
consumed = true;
}
}
return consumed;
}