u2f_scene_error.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "../u2f_app_i.h"
  2. static void u2f_scene_error_event_callback(GuiButtonType result, InputType type, void* context) {
  3. furi_assert(context);
  4. U2fApp* app = context;
  5. if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
  6. view_dispatcher_send_custom_event(app->view_dispatcher, U2fCustomEventErrorBack);
  7. }
  8. }
  9. void u2f_scene_error_on_enter(void* context) {
  10. U2fApp* app = context;
  11. widget_add_icon_element(app->widget, 0, 0, &I_SDQuestion_35x43);
  12. widget_add_string_multiline_element(
  13. app->widget,
  14. 81,
  15. 4,
  16. AlignCenter,
  17. AlignTop,
  18. FontSecondary,
  19. "No SD card or\napp data found.\nThis app will not\nwork without\nrequired files.");
  20. widget_add_button_element(
  21. app->widget, GuiButtonTypeLeft, "Back", u2f_scene_error_event_callback, app);
  22. view_dispatcher_switch_to_view(app->view_dispatcher, U2fAppViewError);
  23. }
  24. bool u2f_scene_error_on_event(void* context, SceneManagerEvent event) {
  25. U2fApp* app = context;
  26. bool consumed = false;
  27. if(event.type == SceneManagerEventTypeCustom) {
  28. if(event.event == U2fCustomEventErrorBack) {
  29. view_dispatcher_stop(app->view_dispatcher);
  30. consumed = true;
  31. }
  32. }
  33. return consumed;
  34. }
  35. void u2f_scene_error_on_exit(void* context) {
  36. U2fApp* app = context;
  37. widget_reset(app->widget);
  38. }