[FL-2049] Reset submenu index on exit #840

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich 2021-11-24 17:05:23 +03:00 committed by GitHub
parent a13f87fedb
commit 92c499b41b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -169,6 +169,9 @@ static uint32_t loader_hide_menu(void* context) {
} }
static uint32_t loader_back_to_primary_menu(void* context) { static uint32_t loader_back_to_primary_menu(void* context) {
furi_assert(context);
Submenu* submenu = context;
submenu_set_selected_item(submenu, 0);
return LoaderMenuViewPrimary; return LoaderMenuViewPrimary;
} }
@ -200,6 +203,7 @@ static Loader* loader_alloc() {
instance->view_dispatcher, LoaderMenuViewPrimary, menu_get_view(instance->primary_menu)); instance->view_dispatcher, LoaderMenuViewPrimary, menu_get_view(instance->primary_menu));
// Plugins menu // Plugins menu
instance->plugins_menu = submenu_alloc(); instance->plugins_menu = submenu_alloc();
view_set_context(submenu_get_view(instance->plugins_menu), instance->plugins_menu);
view_set_previous_callback( view_set_previous_callback(
submenu_get_view(instance->plugins_menu), loader_back_to_primary_menu); submenu_get_view(instance->plugins_menu), loader_back_to_primary_menu);
view_dispatcher_add_view( view_dispatcher_add_view(
@ -208,12 +212,14 @@ static Loader* loader_alloc() {
submenu_get_view(instance->plugins_menu)); submenu_get_view(instance->plugins_menu));
// Debug menu // Debug menu
instance->debug_menu = submenu_alloc(); instance->debug_menu = submenu_alloc();
view_set_context(submenu_get_view(instance->debug_menu), instance->debug_menu);
view_set_previous_callback( view_set_previous_callback(
submenu_get_view(instance->debug_menu), loader_back_to_primary_menu); submenu_get_view(instance->debug_menu), loader_back_to_primary_menu);
view_dispatcher_add_view( view_dispatcher_add_view(
instance->view_dispatcher, LoaderMenuViewDebug, submenu_get_view(instance->debug_menu)); instance->view_dispatcher, LoaderMenuViewDebug, submenu_get_view(instance->debug_menu));
// Settings menu // Settings menu
instance->settings_menu = submenu_alloc(); instance->settings_menu = submenu_alloc();
view_set_context(submenu_get_view(instance->settings_menu), instance->settings_menu);
view_set_previous_callback( view_set_previous_callback(
submenu_get_view(instance->settings_menu), loader_back_to_primary_menu); submenu_get_view(instance->settings_menu), loader_back_to_primary_menu);
view_dispatcher_add_view( view_dispatcher_add_view(