view_playlist_content.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "nfc_playlist.h"
  2. #include "scences/view_playlist_content.h"
  3. void nfc_playlist_view_playlist_content_scene_on_enter(void* context) {
  4. NfcPlaylist* nfc_playlist = context;
  5. Storage* storage = furi_record_open(RECORD_STORAGE);
  6. File* file = storage_file_alloc(storage);
  7. uint8_t buffer[8000];
  8. FuriString* playlist_content = furi_string_alloc();
  9. storage_file_open(file, furi_string_get_cstr(nfc_playlist->settings.file_path), FSAM_READ, FSOM_OPEN_EXISTING);
  10. uint16_t read_count = storage_file_read(file, buffer, 8000);
  11. for(uint16_t i = 0; i < read_count; i++) {
  12. furi_string_push_back(playlist_content, buffer[i]);
  13. }
  14. widget_add_text_scroll_element(nfc_playlist->widget, 4, 4, 124, 60, furi_string_get_cstr(playlist_content));
  15. widget_add_frame_element(nfc_playlist->widget, 0, 0, 128, 64, 0);
  16. furi_string_free(playlist_content);
  17. storage_file_close(file);
  18. storage_file_free(file);
  19. furi_record_close(RECORD_STORAGE);
  20. view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_ViewPlaylistContent);
  21. }
  22. bool nfc_playlist_view_playlist_content_scene_on_event(void* context, SceneManagerEvent event) {
  23. UNUSED(context);
  24. UNUSED(event);
  25. return false;
  26. }
  27. void nfc_playlist_view_playlist_content_scene_on_exit(void* context) {
  28. NfcPlaylist* nfc_playlist = context;
  29. widget_reset(nfc_playlist->widget);
  30. }