passy_scene_read_error.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. widget_add_button_element(
  19. widget, GuiButtonTypeLeft, "Retry", passy_scene_read_error_widget_callback, passy);
  20. widget_add_string_element(
  21. widget, 64, 5, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(primary_str));
  22. widget_add_string_element(
  23. widget,
  24. 64,
  25. 20,
  26. AlignCenter,
  27. AlignCenter,
  28. FontSecondary,
  29. furi_string_get_cstr(secondary_str));
  30. furi_string_free(primary_str);
  31. furi_string_free(secondary_str);
  32. view_dispatcher_switch_to_view(passy->view_dispatcher, PassyViewWidget);
  33. }
  34. bool passy_scene_read_error_on_event(void* context, SceneManagerEvent event) {
  35. Passy* passy = context;
  36. bool consumed = false;
  37. if(event.type == SceneManagerEventTypeCustom) {
  38. if(event.event == GuiButtonTypeLeft) {
  39. consumed = scene_manager_previous_scene(passy->scene_manager);
  40. }
  41. } else if(event.type == SceneManagerEventTypeBack) {
  42. scene_manager_search_and_switch_to_previous_scene(
  43. passy->scene_manager, PassySceneMainMenu);
  44. consumed = true;
  45. }
  46. return consumed;
  47. }
  48. void passy_scene_read_error_on_exit(void* context) {
  49. Passy* passy = context;
  50. // Clear view
  51. widget_reset(passy->widget);
  52. }