Skip to content

Commit

Permalink
[FL-2344] iButton deleted back button (flipperdevices#1096)
Browse files Browse the repository at this point in the history
Co-authored-by: あく <[email protected]>
  • Loading branch information
Karator and skotopes authored Apr 11, 2022
1 parent b22ad77 commit a25552e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
31 changes: 5 additions & 26 deletions applications/ibutton/scene/ibutton_scene_info.cpp
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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:
Expand All @@ -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;
}

Expand Down

0 comments on commit a25552e

Please sign in to comment.