nfc_scene_read_card_success.c 1.8 KB

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