u2f_scene_error.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. } else if(app->error == U2fAppErrorCloseRpc) {
  22. widget_add_string_multiline_element(
  23. app->widget,
  24. 63,
  25. 10,
  26. AlignCenter,
  27. AlignTop,
  28. FontSecondary,
  29. "Disconnect from\ncompanion app\nto use this function");
  30. }
  31. widget_add_button_element(
  32. app->widget, GuiButtonTypeLeft, "Back", u2f_scene_error_event_callback, app);
  33. view_dispatcher_switch_to_view(app->view_dispatcher, U2fAppViewError);
  34. }
  35. bool u2f_scene_error_on_event(void* context, SceneManagerEvent event) {
  36. U2fApp* app = context;
  37. bool consumed = false;
  38. if(event.type == SceneManagerEventTypeCustom) {
  39. if(event.event == U2fCustomEventErrorBack) {
  40. view_dispatcher_stop(app->view_dispatcher);
  41. consumed = true;
  42. }
  43. }
  44. return consumed;
  45. }
  46. void u2f_scene_error_on_exit(void* context) {
  47. U2fApp* app = context;
  48. widget_reset(app->widget);
  49. }