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: Add Switching Between Quran Warsh and Hafs #1328

Merged
merged 24 commits into from
Oct 7, 2024

Conversation

YassinNouh21
Copy link
Contributor

@YassinNouh21 YassinNouh21 commented Sep 17, 2024

Pull Request: Add Feature for Switching Between Quran Warsh and Hafs

Overview

This PR introduces functionality to switch between two versions of the Quran: Warsh and Hafs. The feature enhances user experience by allowing readers to select their preferred recitation style easily.

Changes Made

New Features

  • MoshafType Enum: An enum representing the two types of Quran recitations (Warsh and Hafs).
  • Moshaf Selector Widget: A new widget (MoshafSelector) that allows users to switch between the two recitations.
  • State Management for Moshaf: Added MoshafTypeNotifier to manage the selected recitation type and its associated state.
  • Download Logic Update: Updated download logic to handle different versions of the Quran based on the selected recitation.

Code Changes

  • Constants: Added constants for local version tracking of both recitations.
  • Localization: Added localization strings for switching the Quran type.
  • UI Adjustments: Integrated the Moshaf selector in the Quran reading screen for easy access.
  • Testing: Updated unit tests to ensure functionality for downloading and managing recitation types.

Testing

  • Unit Tests: Added tests to verify the functionality of the new Moshaf switching feature.
  • Integration Tests: Tested the UI components to ensure proper rendering and functionality in the Quran reading screen.

quran_switcher

- Introduced `MoshafType` as a parameter in various functions to support multiple Quran versions.
- Updated `DownloadQuranLocalDataSource` to handle versioning based on `MoshafType`.
- Enhanced `DownloadQuranState` with states for checking downloads and handling errors.
- Refactored Notifiers and Repositories to include `MoshafType` in state management.
- Improved the UI with a new `DownloadQuranDialog` for better user interaction during downloads.
- Cleaned up redundant code and improved error handling across the application.
@YassinNouh21 YassinNouh21 marked this pull request as draft September 17, 2024 19:21
- Updated `download_quran_popup.dart` to streamline dialog handling and improve state management.
- Changed `getLocalQuranVersion` in `quran_download_repository.dart` to return an `Option<String>` for better null safety.
- Enhanced `download_quran_notifier.dart` for more efficient state transitions and error handling.
- Refactored local data operations in `download_quran_local_data_source.dart` to utilize `Option` for version management.
- Improved moshaf switching logic in `moshaf_type_notifier.dart` and related UI components.
- Removed unnecessary dialog calls in `quran_reading_screen.dart` to prevent duplicate dialogs.
- Introduced `isFirstTime` property in `MoshafState` to track first-time usage.
- Updated `download_quran_notifier.dart` to prompt downloads for first-time users.
- Enhanced `moshaf_type_notifier.dart` to initialize `isFirstTime` from shared preferences.
- Added `setNotFirstTime` method to update the state after the first download.
- Defined a constant for first-time usage in `constants.dart`.
@YassinNouh21 YassinNouh21 self-assigned this Sep 21, 2024
@YassinNouh21 YassinNouh21 changed the title Feat/quran/switch moshaf feat: Add Switching Between Quran Warsh and Hafs Sep 21, 2024
@YassinNouh21 YassinNouh21 marked this pull request as ready for review September 21, 2024 18:42
- Refactor DownloadQuranRemoteDataSource to initialize cancelToken properly
- Add checks to prevent updating progress after cancellation
- Implement _isCancelled flag in DownloadQuranNotifier to manage cancellation state
- Ensure download cancellation is properly handled throughout the download process
…wnload method

- Updated cancelDownload method to accept a CancelToken.
- Enhanced download handling to ensure proper cancellation of ongoing downloads.
- Improved cleanup logic upon cancellation to remove downloaded files.
- Introduced `CancelDownloadException` to manage download cancellations gracefully.
- Updated `download_quran_popup.dart` to display an empty container when a download is canceled.
- Enhanced error handling in `download_quran_remote_data_source.dart` to throw `CancelDownloadException` on cancellation.
- Modified `download_quran_notifier.dart` to prevent state updates when a `CancelDownloadException` is caught, ensuring a smoother user experience.
- Updated unit tests in `download_quran_remote_data_source_test.dart` to verify that cancellation throws the new `CancelDownloadException`.

This change improves the app's responsiveness and user feedback during the Quran download process by clearly handling cancellation scenarios.
Copy link
Contributor

@ghassenbenzahra123 ghassenbenzahra123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ghassenbenzahra123 ghassenbenzahra123 merged commit 903a24f into main Oct 7, 2024
1 check passed
@ghassenbenzahra123 ghassenbenzahra123 deleted the feat/quran/switch_moshaf branch October 7, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants