Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Download the whole quran suwar and quran single surah #1194

Closed

Conversation

YassinNouh21
Copy link
Contributor

📝 Summary

This PR implements several enhancements and new features for the Quran audio player and reading functionality.

Description

  • Added favorite reciter functionality
  • Implemented batch download for all Surahs
  • Improved Quran player navigation and offline support
  • Added page selection dialog for Quran reading
  • Implemented new DownloadAudioQuranNotifier and state management

Key Changes:

  • New QuranFavoriteNotifier and QuranFavoriteState for managing favorite reciters and surahs
  • Batch download functionality for all Surahs with progress tracking
  • Improved audio handling with local and remote file support
  • Enhanced reciter selection screen with favorite and all reciter sections
  • New page selector dialog in Quran reading screen
  • Refactored and optimized data sources and repositories

Tests

🧪 Use case 1: Favorite Reciters

💬 Description:
Users can now mark reciters as favorites and easily access them in a separate section.

🧪 Use case 2: Batch Download

💬 Description:
Users can download all Surahs for offline listening with progress tracking.

🧪 Use case 3: Improved Navigation

💬 Description:
Enhanced navigation in Quran player and reading screens with new UI elements.

Checklist:

  • Coding Standards: I have reviewed my code to ensure it follows the project's coding standards.
  • Testing: I have tested the changes and they work as expected.
  • Merge Conflicts: I have resolved any merge conflicts with the latest main/development branch.
  • Branch Status: The branch is up-to-date with the target branch (main/development).

…orage, add `QuranRemoteDataSource` to handle remote
# Conflicts:
#	lib/l10n/intl_en.arb
#	lib/main.dart
#	lib/src/const/constants.dart
… following paths `assets/img/quran/` `assets/icon/`
- Added `QuranBackground` widget to provide a consistent background with image and gradient.
1. **Quran Notifier**:
   - Introduced a new method `getSuwarByReciter` in `QuranNotifier` to fetch the list of Surahs filtered by the selected reciter.
   - Enhanced error handling and state management for fetching Surahs based on the selected reciter.

2. **Reciter Selection Screen**:
   - Updated the `ReciterSelectionScreen` to use the new `QuranBackground` widget.
   - Improved the layout and user interaction for selecting reciters and recitation types.
   - Integrated keyboard navigation for better accessibility.

3. **Quran Player**:
   - Added a new `QuranPlayerScreen` to provide a dedicated player interface for Quran recitations.
   - Implemented a `SeekBar` and player controls for managing playback.
   - Enhanced playback state management with `QuranAudioPlayerState` and `QuranAudioPlayerNotifier`.

4. **Data Source and Repository**:
   - Added `ReciteRemoteDataSource` and `ReciteLocalDataSource` for managing reciter data.
   - Introduced `ReciteImpl` as the implementation of `ReciteRepository` for handling reciter-related operations.

5. **Hive Integration**:
   - Registered Hive adapters for `ReciterModel` and `MoshafModel` to support local data storage.
**Changes:**

1. **lib/src/pages/quran/widget/quran_background.dart**
   - Wrapped `Scaffold` in a `SafeArea` widget to ensure content is displayed within the safe area of the screen.
   - Adjusted the structure to consistently use `SafeArea` for both cases when `appBar` is present or not.

2. **lib/src/pages/quran/widget/side_menu.dart**
   - Imported `sizer` package for responsive layout adjustments.
   - Modified `width` to use `Sizer` package's percentage width (`18.w`).
   - Added `BoxConstraints` to set minimum and maximum width for better responsiveness.

3. **lib/src/pages/quran/page/surah_selection_screen.dart**
   - Added `AppBar` within `QuranBackground` with transparent background and responsive font size using `sizer` package.
   - Adjusted padding and grid layout within `QuranBackground` to use `Sizer` for dynamic sizing.
   - Moved the `SideMenu` widget inside the `quranState.when` method for better state management.

4. **lib/src/pages/quran/page/quran_player_screen.dart**
   - Tweaked the `SliderTheme` to remove unnecessary properties and adjusted `thumbShape` size.
   - Adjusted font sizes in `Row` displaying position and duration using `sizer` package.
   - Removed redundant `SizedBox` height adjustments.

5. **lib/src/pages/quran/page/reciter_selection_screen.dart**
   - Adjusted `sizeOfContainerReciter` for better responsive behavior.
   - Introduced navigation buttons for scrolling through the reciter list.
   - Enhanced `_reciterCard` to use `Sizer` for size adjustments.
   - Improved the `_buildReciterListShimmer` and grid layout for better responsiveness.

6. **lib/src/pages/quran/widget/surah_card.dart**
   - Adjusted `borderRadius` for `Container` to a more uniform value.
   - Updated text font size within `SurahCard` to use `sizer` package for responsiven
…ranFavoriteImpl`

- Add QuranFavoriteRepository interface for managing favorite reciters and surahs
- Implement QuranFavoriteImpl repository using QuranFavoriteLocalDataSource and ReciteLocalDataSource
- Create QuranFavoriteLocalDataSource for persisting favorite data using Hive
…avorite state

Provide methods to save and retrieve favorite reciters and surahs
- Updated `SurahCard` widget to support favorite functionality:
  - Converted `SurahCard` to `ConsumerStatefulWidget`.
  - Added favorite button with `onFavoriteTap` callback.
  - Introduced `_isFocused` state to manage favorite state UI.
  - Improved visual feedback for favorite state.

- Enhanced `SurahSelectionScreen`:
  - Added initialization to fetch favorite surahs on screen load.
  - Integrated `quranFavoriteNotifierProvider` to manage favorite surahs.
  - Added `reciterId` and `riwayatId` parameters to `SurahSelectionScreen`.

- Modified `ReciterSelectionScreen`:
  - Added `reciterId` and `riwayatId` parameters to navigate to `SurahSelectionScreen`.
  - Included `onSelected` callback in `ReciterListView` for selection feedback.

- Updated repository and data source implementations:
  - Modified `QuranFavoriteRepository` and `QuranFavoriteLocalDataSource` to use `riwayatId` instead of `riwayat`.
  - Enhanced methods to support the new favorite functionality.
  - Included logs for better debugging.

- Adjusted `QuranFavoriteNotifier`:
  - Added methods to save and fetch favorite surahs.
  - Included state management for favorite operations.

- Enhanced `ReciterListView`:
  - Added `onSelected` callback to manage reciter selection.

- Updated Hive data model:
  - Modified `QuranFavoriteLocalDataSource` to use `QuranReciterFavoriteModel` for managing favorite surahs.
…and prioritize favorite Surahs.

- Removed the shade effect from Surah cards when focused.
- Implemented a feature to remove bookmarks from Surahs.
- Added functionality to prioritize favorite Surahs by listing them at the top of the Surah selection screen.
- Added `audio_file_model.dart` to define the AudioFileModel with JSON serialization support using Dart Mappable.
- Updated `reciter_local_data_source.dart` to handle saving and retrieving audio files locally:
  - Added `saveAudioFile` method to save audio files to local storage.
  - Added `getAudioFilePath` method to retrieve file paths of locally stored audio files.
  - Imported necessary packages (`path`, `path_provider`, `dart:io`).
- Updated `reciter_remote_data_source.dart` to handle downloading audio files from remote sources:
  - Added `downloadAudioFile` method to download audio files using Dio.
- Added new exceptions in `recite_exception.dart` to handle audio file-related errors:
  - `FetchAudioFileFailedException`, `SaveAudioFileException`, `FetchAudioFileException`, and `AudioFileNotFoundInCacheException`.
- Add local audio file playback capability
- Implement surah download functionality
- Add checks for downloaded surah status
- Improve audio player state management
- Enhance connectivity handling for playback
- Refactor audio file downloading to use isolates
- Update UI to reflect download status and playback options
- Fix various bugs and improve error handling
- Implement debounce mechanism to prevent multiple page pushes when spamming in UI
- Enhance offline mode handling in QuranAudioPlayer
- Refactor audio source initialization for better reliability
- Add playlist refresh functionality after downloading new audio
- Improve state management for player controls (next/previous)
- Add downloadAllSuwar method to QuranAudioPlayer for batch downloading
- Update SurahSelectionScreen to use the new batch download functionality
- Refactor download button in SurahSelectionScreen to use whenOrNull for better null safety
- Pass ReciterModel and MoshafModel to SurahSelectionScreen for more context
- Remove local download methods from SurahSelectionScreen
- Update ReciterSelectionScreen to pass new required parameters to SurahSelectionScreen
- Add DownloadStatus enum to track download states
- Extend DownloadAudioQuranState to include download status
- Update DownloadStateNotifier with methods to set and reset download status
- Modify QuranAudioPlayer to handle batch downloads and update status
- Update SurahSelectionScreen to show download progress and status
- Add toast notifications for download completion and no new downloads
- Implement Riverpod listener for download status changes
- Add new localization strings for download status messages
- Disable download button while downloads are in progress
@YassinNouh21 YassinNouh21 self-assigned this Jul 4, 2024
@ghassenbenzahra123 ghassenbenzahra123 changed the title feat: Fownload the whole quran suwar and quran single surah feat: Download the whole quran suwar and quran single surah Jul 4, 2024
@YassinNouh21 YassinNouh21 deleted the branch feat/quran/quran_main July 13, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant