passy_scene_read_error.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "../passy_i.h"
  2. #include <dolphin/dolphin.h>
  3. #define TAG "PassySceneReadCardSuccess"
  4. void passy_scene_read_error_widget_callback(GuiButtonType result, InputType type, void* context) {
  5. furi_assert(context);
  6. Passy* passy = context;
  7. if(type == InputTypeShort) {
  8. view_dispatcher_send_custom_event(passy->view_dispatcher, result);
  9. }
  10. }
  11. void passy_scene_read_error_on_enter(void* context) {
  12. Passy* passy = context;
  13. Widget* widget = passy->widget;
  14. // Send notification
  15. notification_message(passy->notifications, &sequence_error);
  16. FuriString* primary_str = furi_string_alloc_set("Read Errror");
  17. FuriString* secondary_str = furi_string_alloc_set("Try again?");
  18. if(passy->read_type == PassyReadDG7) {
  19. furi_string_set(primary_str, "No data in DG7");
  20. furi_string_set(secondary_str, "This document does not contain data in DG7.");
  21. }
  22. widget_add_button_element(
  23. widget, GuiButtonTypeLeft, "Retry", passy_scene_read_error_widget_callback, passy);
  24. widget_add_string_element(
  25. widget, 64, 5, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(primary_str));
  26. widget_add_string_element(
  27. widget,
  28. 64,
  29. 20,
  30. AlignCenter,
  31. AlignCenter,
  32. FontSecondary,
  33. furi_string_get_cstr(secondary_str));
  34. furi_string_free(primary_str);
  35. furi_string_free(secondary_str);
  36. view_dispatcher_switch_to_view(passy->view_dispatcher, PassyViewWidget);
  37. }
  38. bool passy_scene_read_error_on_event(void* context, SceneManagerEvent event) {
  39. Passy* passy = context;
  40. bool consumed = false;
  41. if(event.type == SceneManagerEventTypeCustom) {
  42. if(event.event == GuiButtonTypeLeft) {
  43. consumed = scene_manager_previous_scene(passy->scene_manager);
  44. }
  45. } else if(event.type == SceneManagerEventTypeBack) {
  46. scene_manager_search_and_switch_to_previous_scene(
  47. passy->scene_manager, PassySceneMainMenu);
  48. consumed = true;
  49. }
  50. return consumed;
  51. }
  52. void passy_scene_read_error_on_exit(void* context) {
  53. Passy* passy = context;
  54. // Clear view
  55. widget_reset(passy->widget);
  56. }