nfc_scene_read_card_success.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "../nfc_i.h"
  2. void nfc_scene_read_card_success_widget_callback(
  3. GuiButtonType result,
  4. InputType type,
  5. void* context) {
  6. furi_assert(context);
  7. Nfc* nfc = context;
  8. if(type == InputTypeShort) {
  9. view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
  10. }
  11. }
  12. void nfc_scene_read_card_success_on_enter(void* context) {
  13. Nfc* nfc = context;
  14. FuriString* temp_str;
  15. temp_str = furi_string_alloc();
  16. // Setup view
  17. FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
  18. Widget* widget = nfc->widget;
  19. furi_string_set(temp_str, nfc_get_dev_type(data->type));
  20. widget_add_string_element(
  21. widget, 64, 12, AlignCenter, AlignBottom, FontPrimary, furi_string_get_cstr(temp_str));
  22. furi_string_set(temp_str, "UID:");
  23. for(uint8_t i = 0; i < data->uid_len; i++) {
  24. furi_string_cat_printf(temp_str, " %02X", data->uid[i]);
  25. }
  26. widget_add_string_element(
  27. widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, furi_string_get_cstr(temp_str));
  28. widget_add_button_element(
  29. widget, GuiButtonTypeLeft, "Retry", nfc_scene_read_card_success_widget_callback, nfc);
  30. furi_string_free(temp_str);
  31. view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
  32. }
  33. bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event) {
  34. Nfc* nfc = context;
  35. bool consumed = false;
  36. if(event.type == SceneManagerEventTypeCustom) {
  37. if(event.event == GuiButtonTypeLeft) {
  38. consumed = scene_manager_previous_scene(nfc->scene_manager);
  39. }
  40. }
  41. return consumed;
  42. }
  43. void nfc_scene_read_card_success_on_exit(void* context) {
  44. Nfc* nfc = context;
  45. // Clear view
  46. widget_reset(nfc->widget);
  47. }