loadFontsQuran method

Future<void> loadFontsQuran()

-------- Methods ----------

Implementation

// Future<void> _initSearch() async {
//   quranSearch = QuranSearch(ayahs); // تأكد من أن `ayahs` محملة مسبقًا
//   await quranSearch.loadModel(); // تحميل نموذج BERT
// }

Future<void> loadFontsQuran() async {
  lastPage = _quranRepository.getLastPage() ?? 1;
  if (lastPage != 0) {
    jumpToPage(lastPage - 1);
  }
  if (state.surahs.isEmpty) {
    List<dynamic> surahsJson = await _quranRepository.getFontsQuran();
    state.surahs =
        surahsJson.map((s) => SurahModel.fromDownloadedFontsJson(s)).toList();

    for (final surah in state.surahs) {
      state.allAyahs.addAll(surah.ayahs);
      // log('Added ${surah.arabicName} ayahs');
      update();
    }
    List.generate(604, (pageIndex) {
      state.pages.add(state.allAyahs
          .where((ayah) => ayah.page == pageIndex + 1)
          .toList());
    });
    state.isQuranLoaded = true;
    // log('Pages Length: ${state.pages.length}', name: 'Quran Controller');
  }
}