passy_scene_adv_warning.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "../passy_i.h"
  2. #define TAG "PassySceneReadCardSuccess"
  3. void passy_scene_adv_warning_widget_callback(GuiButtonType result, InputType type, void* context) {
  4. furi_assert(context);
  5. Passy* passy = context;
  6. if(type == InputTypeShort) {
  7. view_dispatcher_send_custom_event(passy->view_dispatcher, result);
  8. }
  9. }
  10. void passy_scene_adv_warning_on_enter(void* context) {
  11. Passy* passy = context;
  12. Widget* widget = passy->widget;
  13. FuriString* first_str = furi_string_alloc_set("These DG may require");
  14. FuriString* second_str = furi_string_alloc_set("advanced authentication.\n");
  15. FuriString* third_str = furi_string_alloc_set("Do not expect them to work.\n");
  16. FuriString* fourth_str = furi_string_alloc_set("Do not open issues for them.\n");
  17. widget_add_string_element(
  18. widget, 64, 8, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(first_str));
  19. widget_add_string_element(
  20. widget, 64, 20, AlignCenter, AlignCenter, FontPrimary, furi_string_get_cstr(second_str));
  21. widget_add_string_element(
  22. widget, 0, 32, AlignLeft, AlignCenter, FontSecondary, furi_string_get_cstr(third_str));
  23. widget_add_string_element(
  24. widget, 0, 44, AlignLeft, AlignCenter, FontSecondary, furi_string_get_cstr(fourth_str));
  25. widget_add_button_element(
  26. widget, GuiButtonTypeCenter, "OK", passy_scene_adv_warning_widget_callback, passy);
  27. furi_string_free(first_str);
  28. furi_string_free(second_str);
  29. furi_string_free(third_str);
  30. furi_string_free(fourth_str);
  31. view_dispatcher_switch_to_view(passy->view_dispatcher, PassyViewWidget);
  32. }
  33. bool passy_scene_adv_warning_on_event(void* context, SceneManagerEvent event) {
  34. Passy* passy = context;
  35. bool consumed = false;
  36. if(event.type == SceneManagerEventTypeCustom) {
  37. if(event.event == GuiButtonTypeLeft) {
  38. consumed = scene_manager_previous_scene(passy->scene_manager);
  39. } else if(event.event == GuiButtonTypeCenter) {
  40. passy->read_type = PassyReadCOM;
  41. scene_manager_next_scene(passy->scene_manager, PassySceneRead);
  42. }
  43. } else if(event.type == SceneManagerEventTypeBack) {
  44. consumed = scene_manager_previous_scene(passy->scene_manager);
  45. }
  46. return consumed;
  47. }
  48. void passy_scene_adv_warning_on_exit(void* context) {
  49. Passy* passy = context;
  50. // Clear view
  51. widget_reset(passy->widget);
  52. }