[FL-2534] Correct scene navigation UX in storage app #1308

This commit is contained in:
あく 2022-06-10 19:49:25 +09:00 committed by GitHub
parent 761de00501
commit e0005d5336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 11 deletions

View File

@ -113,11 +113,14 @@ void storage_settings_scene_benchmark_on_enter(void* context) {
StorageSettings* app = context; StorageSettings* app = context;
DialogEx* dialog_ex = app->dialog_ex; DialogEx* dialog_ex = app->dialog_ex;
FS_Error sd_status = storage_sd_status(app->fs_api);
scene_manager_set_scene_state(app->scene_manager, StorageSettingsBenchmark, sd_status);
dialog_ex_set_context(dialog_ex, app); dialog_ex_set_context(dialog_ex, app);
dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_benchmark_dialog_callback); dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_benchmark_dialog_callback);
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx); view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
if(storage_sd_status(app->fs_api) != FSE_OK) { if(sd_status != FSE_OK) {
dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_text( dialog_ex_set_text(
dialog_ex, dialog_ex,
@ -126,7 +129,7 @@ void storage_settings_scene_benchmark_on_enter(void* context) {
32, 32,
AlignCenter, AlignCenter,
AlignCenter); AlignCenter);
dialog_ex_set_left_button_text(dialog_ex, "Back"); dialog_ex_set_center_button_text(dialog_ex, "Ok");
} else { } else {
storage_settings_scene_benchmark(app); storage_settings_scene_benchmark(app);
notification_message(app->notification, &sequence_blink_green_100); notification_message(app->notification, &sequence_blink_green_100);
@ -137,13 +140,19 @@ bool storage_settings_scene_benchmark_on_event(void* context, SceneManagerEvent
StorageSettings* app = context; StorageSettings* app = context;
bool consumed = false; bool consumed = false;
FS_Error sd_status =
scene_manager_get_scene_state(app->scene_manager, StorageSettingsBenchmark);
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) { switch(event.event) {
case DialogExResultLeft: case DialogExResultCenter:
consumed = scene_manager_previous_scene(app->scene_manager); consumed = scene_manager_previous_scene(app->scene_manager);
break; break;
} }
} else if(event.type == SceneManagerEventTypeBack && sd_status != FSE_OK) {
consumed = true;
} }
return consumed; return consumed;
} }

View File

@ -9,9 +9,9 @@ static void
void storage_settings_scene_format_confirm_on_enter(void* context) { void storage_settings_scene_format_confirm_on_enter(void* context) {
StorageSettings* app = context; StorageSettings* app = context;
FS_Error sd_status = storage_sd_status(app->fs_api);
DialogEx* dialog_ex = app->dialog_ex; DialogEx* dialog_ex = app->dialog_ex;
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
FS_Error sd_status = storage_sd_status(app->fs_api);
if(sd_status == FSE_NOT_READY) { if(sd_status == FSE_NOT_READY) {
dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter);
@ -22,10 +22,12 @@ void storage_settings_scene_format_confirm_on_enter(void* context) {
32, 32,
AlignCenter, AlignCenter,
AlignCenter); AlignCenter);
dialog_ex_set_center_button_text(dialog_ex, "Ok");
} else { } else {
dialog_ex_set_right_button_text(dialog_ex, "Format");
dialog_ex_set_header(dialog_ex, "Format SD card?", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_header(dialog_ex, "Format SD card?", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_text(dialog_ex, "All data will be lost", 64, 32, AlignCenter, AlignCenter); dialog_ex_set_text(dialog_ex, "All data will be lost", 64, 32, AlignCenter, AlignCenter);
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Format");
} }
dialog_ex_set_context(dialog_ex, app); dialog_ex_set_context(dialog_ex, app);
@ -44,12 +46,18 @@ bool storage_settings_scene_format_confirm_on_event(void* context, SceneManagerE
case DialogExResultLeft: case DialogExResultLeft:
consumed = scene_manager_previous_scene(app->scene_manager); consumed = scene_manager_previous_scene(app->scene_manager);
break; break;
case DialogExResultCenter:
consumed = scene_manager_previous_scene(app->scene_manager);
break;
case DialogExResultRight: case DialogExResultRight:
scene_manager_next_scene(app->scene_manager, StorageSettingsFormatting); scene_manager_next_scene(app->scene_manager, StorageSettingsFormatting);
consumed = true; consumed = true;
break; break;
} }
} else if(event.type == SceneManagerEventTypeBack) {
consumed = true;
} }
return consumed; return consumed;
} }

View File

@ -8,9 +8,11 @@ static void storage_settings_scene_sd_info_dialog_callback(DialogExResult result
void storage_settings_scene_sd_info_on_enter(void* context) { void storage_settings_scene_sd_info_on_enter(void* context) {
StorageSettings* app = context; StorageSettings* app = context;
DialogEx* dialog_ex = app->dialog_ex;
SDInfo sd_info; SDInfo sd_info;
FS_Error sd_status = storage_sd_info(app->fs_api, &sd_info); FS_Error sd_status = storage_sd_info(app->fs_api, &sd_info);
DialogEx* dialog_ex = app->dialog_ex; scene_manager_set_scene_state(app->scene_manager, StorageSettingsSDInfo, sd_status);
dialog_ex_set_context(dialog_ex, app); dialog_ex_set_context(dialog_ex, app);
dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_sd_info_dialog_callback); dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_sd_info_dialog_callback);
@ -24,6 +26,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
32, 32,
AlignCenter, AlignCenter,
AlignCenter); AlignCenter);
dialog_ex_set_center_button_text(dialog_ex, "Ok");
} else { } else {
string_printf( string_printf(
app->text_string, app->text_string,
@ -43,17 +46,25 @@ bool storage_settings_scene_sd_info_on_event(void* context, SceneManagerEvent ev
StorageSettings* app = context; StorageSettings* app = context;
bool consumed = false; bool consumed = false;
FS_Error sd_status = scene_manager_get_scene_state(app->scene_manager, StorageSettingsSDInfo);
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) { switch(event.event) {
case DialogExResultLeft: case DialogExResultLeft:
consumed = scene_manager_previous_scene(app->scene_manager); consumed = scene_manager_previous_scene(app->scene_manager);
break; break;
case DialogExResultCenter:
consumed = scene_manager_previous_scene(app->scene_manager);
break;
case DialogExResultRight: case DialogExResultRight:
scene_manager_next_scene(app->scene_manager, StorageSettingsUnmounted); scene_manager_next_scene(app->scene_manager, StorageSettingsUnmounted);
consumed = true; consumed = true;
break; break;
} }
} else if(event.type == SceneManagerEventTypeBack && sd_status != FSE_OK) {
consumed = true;
} }
return consumed; return consumed;
} }

View File

@ -9,11 +9,11 @@ static void
void storage_settings_scene_unmount_confirm_on_enter(void* context) { void storage_settings_scene_unmount_confirm_on_enter(void* context) {
StorageSettings* app = context; StorageSettings* app = context;
FS_Error sd_status = storage_sd_status(app->fs_api);
DialogEx* dialog_ex = app->dialog_ex; DialogEx* dialog_ex = app->dialog_ex;
FS_Error sd_status = storage_sd_status(app->fs_api);
if(sd_status == FSE_NOT_READY) { if(sd_status == FSE_NOT_READY) {
dialog_ex_set_center_button_text(dialog_ex, "OK");
dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_text( dialog_ex_set_text(
dialog_ex, dialog_ex,
@ -22,12 +22,13 @@ void storage_settings_scene_unmount_confirm_on_enter(void* context) {
32, 32,
AlignCenter, AlignCenter,
AlignCenter); AlignCenter);
dialog_ex_set_center_button_text(dialog_ex, "OK");
} else { } else {
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Unmount");
dialog_ex_set_header(dialog_ex, "Unmount SD card?", 64, 10, AlignCenter, AlignCenter); dialog_ex_set_header(dialog_ex, "Unmount SD card?", 64, 10, AlignCenter, AlignCenter);
dialog_ex_set_text( dialog_ex_set_text(
dialog_ex, "SD card will be\nunavailable", 64, 32, AlignCenter, AlignCenter); dialog_ex, "SD card will be\nunavailable", 64, 32, AlignCenter, AlignCenter);
dialog_ex_set_left_button_text(dialog_ex, "Cancel");
dialog_ex_set_right_button_text(dialog_ex, "Unmount");
} }
dialog_ex_set_context(dialog_ex, app); dialog_ex_set_context(dialog_ex, app);