nfc_apdu_runner_scene_logs.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "../nfc_apdu_runner.h"
  2. #include "nfc_apdu_runner_scene.h"
  3. // 日志场景进入回调
  4. void nfc_apdu_runner_scene_logs_on_enter(void* context) {
  5. NfcApduRunner* app = context;
  6. TextBox* text_box = app->text_box;
  7. text_box_reset(text_box);
  8. text_box_set_font(text_box, TextBoxFontText);
  9. FuriString* text = furi_string_alloc();
  10. furi_string_cat_str(text, "Execution Log:\n\n");
  11. for(uint32_t i = 0; i < app->log_count; i++) {
  12. if(app->log_entries[i].is_error) {
  13. furi_string_cat_str(text, "[ERROR] ");
  14. } else {
  15. furi_string_cat_str(text, "[INFO] ");
  16. }
  17. furi_string_cat_str(text, app->log_entries[i].message);
  18. furi_string_cat_str(text, "\n");
  19. }
  20. if(app->log_count == 0) {
  21. furi_string_cat_str(text, "No logs available.\nRun a script first.");
  22. }
  23. text_box_set_text(text_box, furi_string_get_cstr(text));
  24. furi_string_free(text);
  25. view_dispatcher_switch_to_view(app->view_dispatcher, NfcApduRunnerViewTextBox);
  26. }
  27. // 日志场景事件回调
  28. bool nfc_apdu_runner_scene_logs_on_event(void* context, SceneManagerEvent event) {
  29. UNUSED(context);
  30. UNUSED(event);
  31. return false;
  32. }
  33. // 日志场景退出回调
  34. void nfc_apdu_runner_scene_logs_on_exit(void* context) {
  35. NfcApduRunner* app = context;
  36. text_box_reset(app->text_box);
  37. }