storage-settings-scene-eject-confirm.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "../storage-settings.h"
  2. static void
  3. storage_settings_scene_unmount_confirm_dialog_callback(DialogExResult result, void* context) {
  4. StorageSettings* app = context;
  5. view_dispatcher_send_custom_event(app->view_dispatcher, result);
  6. }
  7. void storage_settings_scene_unmount_confirm_on_enter(void* context) {
  8. StorageSettings* app = context;
  9. FS_Error sd_status = storage_sd_status(app->fs_api);
  10. DialogEx* dialog_ex = app->dialog_ex;
  11. dialog_ex_set_left_button_text(dialog_ex, "Back");
  12. if(sd_status == FSE_NOT_READY) {
  13. dialog_ex_set_header(dialog_ex, "SD card not mounted", 64, 10, AlignCenter, AlignCenter);
  14. dialog_ex_set_text(
  15. dialog_ex,
  16. "If an SD card is inserted,\r\npull it out and reinsert it",
  17. 64,
  18. 32,
  19. AlignCenter,
  20. AlignCenter);
  21. } else {
  22. dialog_ex_set_right_button_text(dialog_ex, "Unmount");
  23. dialog_ex_set_header(dialog_ex, "Unmount SD card?", 64, 10, AlignCenter, AlignCenter);
  24. dialog_ex_set_text(
  25. dialog_ex, "SD card will be\nunavailable", 64, 32, AlignCenter, AlignCenter);
  26. }
  27. dialog_ex_set_context(dialog_ex, app);
  28. dialog_ex_set_result_callback(
  29. dialog_ex, storage_settings_scene_unmount_confirm_dialog_callback);
  30. view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
  31. }
  32. bool storage_settings_scene_unmount_confirm_on_event(void* context, SceneManagerEvent event) {
  33. StorageSettings* app = context;
  34. bool consumed = false;
  35. if(event.type == SceneManagerEventTypeCustom) {
  36. switch(event.event) {
  37. case DialogExResultLeft:
  38. consumed = scene_manager_previous_scene(app->scene_manager);
  39. break;
  40. case DialogExResultRight:
  41. scene_manager_next_scene(app->scene_manager, StorageSettingsUnmounted);
  42. consumed = true;
  43. break;
  44. }
  45. }
  46. return consumed;
  47. }
  48. void storage_settings_scene_unmount_confirm_on_exit(void* context) {
  49. StorageSettings* app = context;
  50. DialogEx* dialog_ex = app->dialog_ex;
  51. dialog_ex_set_header(dialog_ex, NULL, 0, 0, AlignCenter, AlignCenter);
  52. dialog_ex_set_text(dialog_ex, NULL, 0, 0, AlignCenter, AlignTop);
  53. dialog_ex_set_icon(dialog_ex, 0, 0, NULL);
  54. dialog_ex_set_left_button_text(dialog_ex, NULL);
  55. dialog_ex_set_right_button_text(dialog_ex, NULL);
  56. dialog_ex_set_result_callback(dialog_ex, NULL);
  57. dialog_ex_set_context(dialog_ex, NULL);
  58. }