Skip to content

Commit

Permalink
feat: "Show info ..." implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
QtRoS committed Oct 7, 2023
1 parent 01a4e38 commit dfa00d3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 41 deletions.
18 changes: 12 additions & 6 deletions scenes/hex_viewer_scene_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

enum SubmenuIndex {
SubmenuIndexScene1 = 10,
// SubmenuIndexScene2,
SubmenuIndexScene2,
// SubmenuIndexScene3,
SubmenuIndexScene4,
// SubmenuIndexScene5,
Expand Down Expand Up @@ -32,6 +32,12 @@ void hex_viewer_scene_menu_on_enter(void* context) {
SubmenuIndexScene1,
hex_viewer_scene_menu_submenu_callback,
app);
submenu_add_item(
app->submenu,
"Show info ...",
SubmenuIndexScene2,
hex_viewer_scene_menu_submenu_callback,
app);
// submenu_add_item(app->submenu, "Settings", SubmenuIndexSettings, hex_viewer_scene_menu_submenu_callback, app);

submenu_set_selected_item(
Expand All @@ -55,11 +61,11 @@ bool hex_viewer_scene_menu_on_event(void* context, SceneManagerEvent event) {
app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene1);
scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_1);
return true;
// } else if (event.event == SubmenuIndexScene2) {
// scene_manager_set_scene_state(
// app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene2);
// scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_2);
// return true;
} else if(event.event == SubmenuIndexScene2) {
scene_manager_set_scene_state(
app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene2);
scene_manager_next_scene(app->scene_manager, HexViewerSceneScene_2);
return true;
// } else if (event.event == SubmenuIndexScene3) {
// scene_manager_set_scene_state(
// app->scene_manager, HexViewerSceneMenu, SubmenuIndexScene3);
Expand Down
63 changes: 32 additions & 31 deletions scenes/hex_viewer_scene_scene_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,46 @@
#include "../helpers/hex_viewer_led.h"
#include "../views/hex_viewer_scene_2.h"

void hex_viewer_scene_2_callback(HexViewerCustomEvent event, void* context) {
furi_assert(context);
HexViewer* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, event);
}
// void hex_viewer_scene_2_callback(HexViewerCustomEvent event, void* context) {
// furi_assert(context);
// HexViewer* app = context;
// view_dispatcher_send_custom_event(app->view_dispatcher, event);
// }

void hex_viewer_scene_scene_2_on_enter(void* context) {
furi_assert(context);
HexViewer* app = context;
hex_viewer_scene_2_set_callback(app->hex_viewer_scene_2, hex_viewer_scene_2_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, HexViewerViewIdScene2);

FuriString* buffer;
buffer = furi_string_alloc();
furi_string_printf(
buffer,
"File path: %s\nFile size: %lu (0x%lX)",
furi_string_get_cstr(app->file_path),
app->model->file_size,
app->model->file_size);

// DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
dialog_message_set_header(message, "Hex Viewer v2.0", 16, 2, AlignLeft, AlignTop);
dialog_message_set_icon(message, &I_hex_10px, 3, 2);
dialog_message_set_text(message, furi_string_get_cstr(buffer), 3, 16, AlignLeft, AlignTop);
dialog_message_set_buttons(message, NULL, NULL, "Back");
dialog_message_show(app->dialogs, message);

furi_string_free(buffer);
dialog_message_free(message);
// furi_record_close(RECORD_DIALOGS);

scene_manager_search_and_switch_to_previous_scene(
app->scene_manager, HexViewerViewIdStartscreen);
}

bool hex_viewer_scene_scene_2_on_event(void* context, SceneManagerEvent event) {
HexViewer* app = context;
bool consumed = false;

if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case HexViewerCustomEventScene2Left:
case HexViewerCustomEventScene2Right:
break;
case HexViewerCustomEventScene2Up:
case HexViewerCustomEventScene2Down:
break;
case HexViewerCustomEventScene2Back:
notification_message(app->notification, &sequence_reset_red);
notification_message(app->notification, &sequence_reset_green);
notification_message(app->notification, &sequence_reset_blue);
if(!scene_manager_search_and_switch_to_previous_scene(
app->scene_manager, HexViewerSceneMenu)) {
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
}
consumed = true;
break;
}
}
UNUSED(app);
UNUSED(event);
bool consumed = true;

return consumed;
}
Expand All @@ -50,4 +52,3 @@ void hex_viewer_scene_scene_2_on_exit(void* context) {
HexViewer* app = context;
UNUSED(app);
}

6 changes: 2 additions & 4 deletions views/hex_viewer_startscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void hex_viewer_startscreen_draw(Canvas* canvas, HexViewerStartscreenModel* mode
canvas_set_color(canvas, ColorBlack);

elements_button_left(canvas, model->mode ? "Addr" : "Text");
elements_button_right(canvas, "Info");
//elements_button_right(canvas, "Info");
elements_button_center(canvas, "Menu");

int ROW_HEIGHT = 12;
Expand Down Expand Up @@ -214,9 +214,7 @@ void hex_viewer_startscreen_enter(void* context) {
with_view_model(
instance->view,
HexViewerStartscreenModel * model,
{
update_local_model_from_app(instance->context, model);
},
{ update_local_model_from_app(instance->context, model); },
true);
}

Expand Down

0 comments on commit dfa00d3

Please sign in to comment.