u2f_scene_error.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if(app->error == U2fAppErrorNoFiles) {
  12. widget_add_icon_element(app->widget, 0, 0, &I_SDQuestion_35x43);
  13. widget_add_string_multiline_element(
  14. app->widget,
  15. 81,
  16. 4,
  17. AlignCenter,
  18. AlignTop,
  19. FontSecondary,
  20. "No SD card or\napp data found.\nThis app will not\nwork without\nrequired files.");
  21. widget_add_button_element(
  22. app->widget, GuiButtonTypeLeft, "Back", u2f_scene_error_event_callback, app);
  23. } else if(app->error == U2fAppErrorCloseRpc) {
  24. widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
  25. widget_add_string_multiline_element(
  26. app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nis active!");
  27. widget_add_string_multiline_element(
  28. app->widget,
  29. 3,
  30. 30,
  31. AlignLeft,
  32. AlignTop,
  33. FontSecondary,
  34. "Disconnect from\nPC or phone to\nuse this function.");
  35. }
  36. view_dispatcher_switch_to_view(app->view_dispatcher, U2fAppViewError);
  37. }
  38. bool u2f_scene_error_on_event(void* context, SceneManagerEvent event) {
  39. U2fApp* app = context;
  40. bool consumed = false;
  41. if(event.type == SceneManagerEventTypeCustom) {
  42. if(event.event == U2fCustomEventErrorBack) {
  43. view_dispatcher_stop(app->view_dispatcher);
  44. consumed = true;
  45. }
  46. }
  47. return consumed;
  48. }
  49. void u2f_scene_error_on_exit(void* context) {
  50. U2fApp* app = context;
  51. widget_reset(app->widget);
  52. }