@moustafahelmi/react-native-quran-app 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bundle/config +2 -0
- package/.eslintrc.js +4 -0
- package/.prettierrc.js +7 -0
- package/.watchmanconfig +1 -0
- package/App.tsx +23 -0
- package/Gemfile +9 -0
- package/Gemfile.lock +105 -0
- package/MIGRATION.md +163 -0
- package/README.md +210 -0
- package/ReactotronConfig.js +7 -0
- package/__tests__/App.test.tsx +17 -0
- package/android/app/build.gradle +118 -0
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +10 -0
- package/android/app/src/debug/AndroidManifest.xml +9 -0
- package/android/app/src/main/AndroidManifest.xml +25 -0
- package/android/app/src/main/assets/fonts/Cairo.ttf +0 -0
- package/android/app/src/main/assets/fonts/QCF_BSML.ttf +0 -0
- package/android/app/src/main/assets/fonts/QCF_P001.ttf +0 -0
- package/android/app/src/main/java/com/quranapp/MainActivity.kt +22 -0
- package/android/app/src/main/java/com/quranapp/MainApplication.kt +43 -0
- package/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/values/strings.xml +3 -0
- package/android/app/src/main/res/values/styles.xml +9 -0
- package/android/build.gradle +21 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +41 -0
- package/android/gradlew +249 -0
- package/android/gradlew.bat +92 -0
- package/android/link-assets-manifest.json +17 -0
- package/android/settings.gradle +4 -0
- package/app.json +4 -0
- package/babel.config.js +3 -0
- package/index.js +11 -0
- package/ios/.xcode.env +11 -0
- package/ios/Podfile +40 -0
- package/ios/Podfile.lock +1460 -0
- package/ios/QuranApp/AppDelegate.h +6 -0
- package/ios/QuranApp/AppDelegate.mm +31 -0
- package/ios/QuranApp/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/ios/QuranApp/Images.xcassets/Contents.json +6 -0
- package/ios/QuranApp/Info.plist +57 -0
- package/ios/QuranApp/LaunchScreen.storyboard +47 -0
- package/ios/QuranApp/PrivacyInfo.xcprivacy +38 -0
- package/ios/QuranApp/main.m +10 -0
- package/ios/QuranApp.xcodeproj/project.pbxproj +729 -0
- package/ios/QuranApp.xcodeproj/xcshareddata/xcschemes/QuranApp.xcscheme +88 -0
- package/ios/QuranApp.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/QuranAppTests/Info.plist +24 -0
- package/ios/QuranAppTests/QuranAppTests.m +66 -0
- package/ios/link-assets-manifest.json +17 -0
- package/jest.config.js +3 -0
- package/metro.config.js +11 -0
- package/package.json +54 -0
- package/react-native.config.js +7 -0
- package/screenshots/1.png +0 -0
- package/screenshots/2.png +0 -0
- package/screenshots/3.png +0 -0
- package/screenshots/4.png +0 -0
- package/screenshots/5.png +0 -0
- package/src/assets/fonts/Cairo.ttf +0 -0
- package/src/assets/fonts/QCF_BSML.ttf +0 -0
- package/src/assets/fonts/QCF_P001.ttf +0 -0
- package/src/assets/images/bookmark.png +0 -0
- package/src/assets/images/close.png +0 -0
- package/src/assets/images/copy.png +0 -0
- package/src/assets/images/down-chevron.png +0 -0
- package/src/assets/images/mushafFrame.png +0 -0
- package/src/assets/images/pause.png +0 -0
- package/src/assets/images/play-button.png +0 -0
- package/src/assets/images/play.svg +16 -0
- package/src/assets/images/playNext.png +0 -0
- package/src/assets/images/surahNameFrame.png +0 -0
- package/src/common/chapters.ts +1346 -0
- package/src/common/constants.ts +27 -0
- package/src/common/images.ts +13 -0
- package/src/common/index.ts +8 -0
- package/src/common/juzs.ts +411 -0
- package/src/common/priorityPages.ts +46 -0
- package/src/common/themes.ts +7 -0
- package/src/components/index.ts +3 -0
- package/src/components/lists/index.ts +3 -0
- package/src/components/lists/pageVersesList.tsx +220 -0
- package/src/components/lists/verseLinesWordsList.tsx +90 -0
- package/src/components/modals/index.ts +3 -0
- package/src/components/modals/optionsModal.tsx +126 -0
- package/src/components/modals/recitersModal.tsx +118 -0
- package/src/components/sections/audioPlayer.tsx +185 -0
- package/src/components/sections/audioPlayerControls.tsx +100 -0
- package/src/components/sections/index.ts +4 -0
- package/src/components/sections/loader.tsx +33 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/quranHelpers.tsx +17 -0
- package/src/hooks/apis/index.ts +10 -0
- package/src/hooks/apis/useGetChapterAudio.ts +111 -0
- package/src/hooks/apis/useGetChapterByPage.ts +166 -0
- package/src/hooks/apis/useGetChapterLookup.ts +31 -0
- package/src/hooks/apis/useGetReciters.ts +44 -0
- package/src/hooks/controllers/index.ts +25 -0
- package/src/hooks/controllers/useAudioPlayerController.tsx +63 -0
- package/src/hooks/controllers/useOptionsModalController.ts +99 -0
- package/src/hooks/controllers/usePageFontFileController.ts +255 -0
- package/src/hooks/controllers/usePageLineController.ts +108 -0
- package/src/hooks/helpers/index.ts +6 -0
- package/src/hooks/helpers/useQuranFontPreloader.ts +225 -0
- package/src/hooks/index.ts +3 -0
- package/src/index.ts +5 -0
- package/src/layouts/bismillahText.tsx +18 -0
- package/src/layouts/index.ts +4 -0
- package/src/layouts/quranChapterHeader.tsx +49 -0
- package/src/layouts/quranPageLayout.tsx +178 -0
- package/src/types/global.d.ts +7 -0
- package/src/types/index.ts +212 -0
- package/src/utils/axiosInstance.ts +7 -0
- package/src/utils/fileHandlers.ts +96 -0
- package/src/utils/handleBeforeAndAfterCurrentVerse.ts +41 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/matrics.ts +37 -0
- package/tsconfig.json +3 -0
- package/videos/1.gif +0 -0
package/.bundle/config
ADDED
package/.eslintrc.js
ADDED
package/.prettierrc.js
ADDED
package/.watchmanconfig
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/App.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {I18nManager} from 'react-native';
|
|
2
|
+
import {QuranPageLayout, QuranTypesEnums} from './src';
|
|
3
|
+
import {IMAGES} from './src/common';
|
|
4
|
+
const App = () => {
|
|
5
|
+
I18nManager.allowRTL(false);
|
|
6
|
+
I18nManager.forceRTL(false);
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<QuranPageLayout
|
|
10
|
+
chapterId={2}
|
|
11
|
+
type={QuranTypesEnums.chapter}
|
|
12
|
+
QURAN_FONTS_API="https://meccamuqra-public-mixed.b-cdn.net/meccamuqra/fonts/"
|
|
13
|
+
backgroundImage={IMAGES.mushafFrame}
|
|
14
|
+
surahNameFrameImage={IMAGES.surahNameFrame}
|
|
15
|
+
autoCompleteAudioAfterPlayingVerse
|
|
16
|
+
onBookMarkedVerse={verse => {
|
|
17
|
+
console.log(verse);
|
|
18
|
+
}}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default App;
|
package/Gemfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
|
4
|
+
ruby ">= 2.6.10"
|
|
5
|
+
|
|
6
|
+
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
|
|
7
|
+
# bound in the template on Cocoapods with next React Native release.
|
|
8
|
+
gem 'cocoapods', '>= 1.13', '< 1.15'
|
|
9
|
+
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
|
package/Gemfile.lock
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: https://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
CFPropertyList (3.0.7)
|
|
5
|
+
base64
|
|
6
|
+
nkf
|
|
7
|
+
rexml
|
|
8
|
+
activesupport (6.1.7.7)
|
|
9
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
10
|
+
i18n (>= 1.6, < 2)
|
|
11
|
+
minitest (>= 5.1)
|
|
12
|
+
tzinfo (~> 2.0)
|
|
13
|
+
zeitwerk (~> 2.3)
|
|
14
|
+
addressable (2.8.6)
|
|
15
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
16
|
+
algoliasearch (1.27.5)
|
|
17
|
+
httpclient (~> 2.8, >= 2.8.3)
|
|
18
|
+
json (>= 1.5.1)
|
|
19
|
+
atomos (0.1.3)
|
|
20
|
+
base64 (0.2.0)
|
|
21
|
+
claide (1.1.0)
|
|
22
|
+
cocoapods (1.14.3)
|
|
23
|
+
addressable (~> 2.8)
|
|
24
|
+
claide (>= 1.0.2, < 2.0)
|
|
25
|
+
cocoapods-core (= 1.14.3)
|
|
26
|
+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
|
27
|
+
cocoapods-downloader (>= 2.1, < 3.0)
|
|
28
|
+
cocoapods-plugins (>= 1.0.0, < 2.0)
|
|
29
|
+
cocoapods-search (>= 1.0.0, < 2.0)
|
|
30
|
+
cocoapods-trunk (>= 1.6.0, < 2.0)
|
|
31
|
+
cocoapods-try (>= 1.1.0, < 2.0)
|
|
32
|
+
colored2 (~> 3.1)
|
|
33
|
+
escape (~> 0.0.4)
|
|
34
|
+
fourflusher (>= 2.3.0, < 3.0)
|
|
35
|
+
gh_inspector (~> 1.0)
|
|
36
|
+
molinillo (~> 0.8.0)
|
|
37
|
+
nap (~> 1.0)
|
|
38
|
+
ruby-macho (>= 2.3.0, < 3.0)
|
|
39
|
+
xcodeproj (>= 1.23.0, < 2.0)
|
|
40
|
+
cocoapods-core (1.14.3)
|
|
41
|
+
activesupport (>= 5.0, < 8)
|
|
42
|
+
addressable (~> 2.8)
|
|
43
|
+
algoliasearch (~> 1.0)
|
|
44
|
+
concurrent-ruby (~> 1.1)
|
|
45
|
+
fuzzy_match (~> 2.0.4)
|
|
46
|
+
nap (~> 1.0)
|
|
47
|
+
netrc (~> 0.11)
|
|
48
|
+
public_suffix (~> 4.0)
|
|
49
|
+
typhoeus (~> 1.0)
|
|
50
|
+
cocoapods-deintegrate (1.0.5)
|
|
51
|
+
cocoapods-downloader (2.1)
|
|
52
|
+
cocoapods-plugins (1.0.0)
|
|
53
|
+
nap
|
|
54
|
+
cocoapods-search (1.0.1)
|
|
55
|
+
cocoapods-trunk (1.6.0)
|
|
56
|
+
nap (>= 0.8, < 2.0)
|
|
57
|
+
netrc (~> 0.11)
|
|
58
|
+
cocoapods-try (1.2.0)
|
|
59
|
+
colored2 (3.1.2)
|
|
60
|
+
concurrent-ruby (1.2.3)
|
|
61
|
+
escape (0.0.4)
|
|
62
|
+
ethon (0.16.0)
|
|
63
|
+
ffi (>= 1.15.0)
|
|
64
|
+
ffi (1.16.3)
|
|
65
|
+
fourflusher (2.3.1)
|
|
66
|
+
fuzzy_match (2.0.4)
|
|
67
|
+
gh_inspector (1.1.3)
|
|
68
|
+
httpclient (2.8.3)
|
|
69
|
+
i18n (1.14.4)
|
|
70
|
+
concurrent-ruby (~> 1.0)
|
|
71
|
+
json (2.7.2)
|
|
72
|
+
minitest (5.22.3)
|
|
73
|
+
molinillo (0.8.0)
|
|
74
|
+
nanaimo (0.3.0)
|
|
75
|
+
nap (1.1.0)
|
|
76
|
+
netrc (0.11.0)
|
|
77
|
+
nkf (0.2.0)
|
|
78
|
+
public_suffix (4.0.7)
|
|
79
|
+
rexml (3.2.6)
|
|
80
|
+
ruby-macho (2.5.1)
|
|
81
|
+
typhoeus (1.4.1)
|
|
82
|
+
ethon (>= 0.9.0)
|
|
83
|
+
tzinfo (2.0.6)
|
|
84
|
+
concurrent-ruby (~> 1.0)
|
|
85
|
+
xcodeproj (1.24.0)
|
|
86
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
|
87
|
+
atomos (~> 0.1.3)
|
|
88
|
+
claide (>= 1.0.2, < 2.0)
|
|
89
|
+
colored2 (~> 3.1)
|
|
90
|
+
nanaimo (~> 0.3.0)
|
|
91
|
+
rexml (~> 3.2.4)
|
|
92
|
+
zeitwerk (2.6.13)
|
|
93
|
+
|
|
94
|
+
PLATFORMS
|
|
95
|
+
ruby
|
|
96
|
+
|
|
97
|
+
DEPENDENCIES
|
|
98
|
+
activesupport (>= 6.1.7.5, < 7.1.0)
|
|
99
|
+
cocoapods (>= 1.13, < 1.15)
|
|
100
|
+
|
|
101
|
+
RUBY VERSION
|
|
102
|
+
ruby 2.6.10p210
|
|
103
|
+
|
|
104
|
+
BUNDLED WITH
|
|
105
|
+
1.17.2
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Migration Guide
|
|
2
|
+
|
|
3
|
+
## Upgrading to v1.4.0
|
|
4
|
+
|
|
5
|
+
Version 1.4.0 adds powerful font preloading capabilities while maintaining full backward compatibility.
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
**None!** All existing code continues to work without modifications.
|
|
10
|
+
|
|
11
|
+
### New Features
|
|
12
|
+
|
|
13
|
+
#### 1. Background Font Preloading
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { useQuranFontPreloader, PRIORITY_PAGES } from 'react-native-quran-hafs';
|
|
17
|
+
|
|
18
|
+
// Add to your Surah list screen
|
|
19
|
+
const { isPreloading, progress } = useQuranFontPreloader({
|
|
20
|
+
pages: PRIORITY_PAGES,
|
|
21
|
+
quranFontApi: YOUR_FONT_API,
|
|
22
|
+
autoStart: true,
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 2. Batch Font Downloads
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { downloadMultiplePageFonts } from 'react-native-quran-hafs';
|
|
30
|
+
|
|
31
|
+
// Download multiple pages at once
|
|
32
|
+
await downloadMultiplePageFonts([1, 2, 3, 4, 5], FONT_API);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### 3. Cache Management
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import {
|
|
39
|
+
getFontCacheStats,
|
|
40
|
+
clearFontCache,
|
|
41
|
+
isFontCached
|
|
42
|
+
} from 'react-native-quran-hafs';
|
|
43
|
+
|
|
44
|
+
// Check what's cached
|
|
45
|
+
const stats = await getFontCacheStats();
|
|
46
|
+
|
|
47
|
+
// Clear cache if needed
|
|
48
|
+
await clearFontCache();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Recommended Upgrade Path
|
|
52
|
+
|
|
53
|
+
1. **Install v1.4.0**
|
|
54
|
+
```bash
|
|
55
|
+
npm install react-native-quran-hafs@1.4.0
|
|
56
|
+
# or
|
|
57
|
+
yarn add react-native-quran-hafs@1.4.0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. **Test Existing Functionality**
|
|
61
|
+
Ensure your current implementation still works.
|
|
62
|
+
|
|
63
|
+
3. **Add Preloading** (Optional but Recommended)
|
|
64
|
+
Add the `useQuranFontPreloader` hook to your Surah list screen.
|
|
65
|
+
|
|
66
|
+
4. **Monitor Performance**
|
|
67
|
+
Check console logs for preload progress and cache hits.
|
|
68
|
+
|
|
69
|
+
### Performance Tips
|
|
70
|
+
|
|
71
|
+
- Start with `PRIORITY_PAGES` (53 pages) - covers 80% of use cases
|
|
72
|
+
- Preload on WiFi-only if concerned about data usage
|
|
73
|
+
- Cache persists between app launches
|
|
74
|
+
- Consider adding a "Download Quran" button in settings for `ALL_QURAN_PAGES`
|
|
75
|
+
|
|
76
|
+
### Performance Improvements
|
|
77
|
+
|
|
78
|
+
#### Before v1.4.0
|
|
79
|
+
- **First Load**: 15-30 seconds (downloads fonts on-demand)
|
|
80
|
+
- **Subsequent Loads**: 15-30 seconds for different pages
|
|
81
|
+
- **User Experience**: Long waits with loading spinners
|
|
82
|
+
|
|
83
|
+
#### After v1.4.0 (With Preloading)
|
|
84
|
+
- **Background Preload**: 30-60 seconds (silent, one-time)
|
|
85
|
+
- **First Load**: < 1 second (fonts already cached)
|
|
86
|
+
- **Subsequent Loads**: < 1 second (fonts already cached)
|
|
87
|
+
- **User Experience**: Instant loading
|
|
88
|
+
|
|
89
|
+
### Network Usage
|
|
90
|
+
- **Priority Pages**: ~10MB one-time download
|
|
91
|
+
- **All Pages**: ~150MB one-time download
|
|
92
|
+
- **Subsequent Opens**: 0KB (cached)
|
|
93
|
+
|
|
94
|
+
### Example Implementation
|
|
95
|
+
|
|
96
|
+
Here's a complete example of integrating font preloading into your app:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import React from 'react';
|
|
100
|
+
import { View, Text, FlatList, TouchableOpacity } from 'react-native';
|
|
101
|
+
import {
|
|
102
|
+
useQuranFontPreloader,
|
|
103
|
+
PRIORITY_PAGES,
|
|
104
|
+
QuranChapters
|
|
105
|
+
} from 'react-native-quran-hafs';
|
|
106
|
+
|
|
107
|
+
function SurahListScreen({ navigation }) {
|
|
108
|
+
const { isPreloading, progress, isCompleted } = useQuranFontPreloader({
|
|
109
|
+
pages: PRIORITY_PAGES,
|
|
110
|
+
quranFontApi: 'https://raw.githubusercontent.com/quran/quran.com-images/master/fonts/',
|
|
111
|
+
autoStart: true,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<View>
|
|
116
|
+
{isPreloading && (
|
|
117
|
+
<View style={{ padding: 10, backgroundColor: '#f0f0f0' }}>
|
|
118
|
+
<Text>📥 Preparing Quran pages: {progress.percentage}%</Text>
|
|
119
|
+
<Text style={{ fontSize: 12, color: '#666' }}>
|
|
120
|
+
{progress.current} of {progress.total} pages ready
|
|
121
|
+
</Text>
|
|
122
|
+
</View>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
<FlatList
|
|
126
|
+
data={QuranChapters}
|
|
127
|
+
renderItem={({ item }) => (
|
|
128
|
+
<TouchableOpacity
|
|
129
|
+
onPress={() => navigation.navigate('Quran', { chapterId: item.id })}
|
|
130
|
+
>
|
|
131
|
+
<Text>{item.name_arabic}</Text>
|
|
132
|
+
</TouchableOpacity>
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
</View>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Support
|
|
141
|
+
|
|
142
|
+
If you encounter issues during migration:
|
|
143
|
+
|
|
144
|
+
1. **Check Console Logs**: Look for font download messages with 📥, ✅, and ❌ emojis
|
|
145
|
+
2. **Verify Exports**: Ensure new functions are imported correctly
|
|
146
|
+
3. **Clear Cache**: Try clearing Metro cache: `npx react-native start --reset-cache`
|
|
147
|
+
4. **Check Network**: Ensure device/emulator has internet access for downloads
|
|
148
|
+
|
|
149
|
+
For bugs or questions, please open an issue on GitHub: https://github.com/mohamedshawky982/react-native-quran-hafs/issues
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Summary
|
|
154
|
+
|
|
155
|
+
Version 1.4.0 brings significant performance improvements through intelligent font preloading:
|
|
156
|
+
|
|
157
|
+
✅ **Backward Compatible**: All existing code works without changes
|
|
158
|
+
✅ **Easy to Adopt**: Single hook for complete preloading functionality
|
|
159
|
+
✅ **Performance Boost**: 15-30s → <1s load times
|
|
160
|
+
✅ **Flexible**: Works with custom page lists and configurations
|
|
161
|
+
✅ **Smart Caching**: Persistent cache across app launches
|
|
162
|
+
|
|
163
|
+
**Recommended Action**: Add `useQuranFontPreloader` with `PRIORITY_PAGES` to your main Quran list screen for instant improvements!
|
package/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Package Title
|
|
2
|
+
|
|
3
|
+
react-native-quran-hafs
|
|
4
|
+
|
|
5
|
+
# Package description
|
|
6
|
+
|
|
7
|
+
It's a simple package allowing you to display the quran as mushaf
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Display the quran like mushaf.
|
|
12
|
+
- Selected a single verse to copy or bookmark it.
|
|
13
|
+
- Use this method [_renderChapterName(chapterId)] to render the surah name like mushaf.
|
|
14
|
+
- Use this method [_renderChapterAyahs(chapterId)] to render the number of surah verses(Ayahs).
|
|
15
|
+
- Scroll to a specific verse(Ayah) page.
|
|
16
|
+
- Support RTL Or LTR.
|
|
17
|
+
- **NEW in v1.4.0:** Background font preloading for instant page loads
|
|
18
|
+
- **NEW in v1.4.0:** Batch font downloads with progress tracking
|
|
19
|
+
- **NEW in v1.4.0:** Font cache management utilities
|
|
20
|
+
|
|
21
|
+
## 🚀 Font Preloading (New in v1.4.0)
|
|
22
|
+
|
|
23
|
+
Dramatically improve loading performance by preloading Quran fonts in the background!
|
|
24
|
+
|
|
25
|
+
### Quick Start
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { useQuranFontPreloader, PRIORITY_PAGES } from 'react-native-quran-hafs';
|
|
29
|
+
|
|
30
|
+
function QuranListScreen() {
|
|
31
|
+
const { isPreloading, progress } = useQuranFontPreloader({
|
|
32
|
+
pages: PRIORITY_PAGES,
|
|
33
|
+
quranFontApi: 'https://raw.githubusercontent.com/quran/quran.com-images/master/fonts/',
|
|
34
|
+
autoStart: true,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View>
|
|
39
|
+
{isPreloading && (
|
|
40
|
+
<Text>Preparing Quran: {progress.percentage}%</Text>
|
|
41
|
+
)}
|
|
42
|
+
{/* Your Surah list */}
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Advanced Usage
|
|
49
|
+
|
|
50
|
+
#### Batch Download Specific Pages
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { downloadMultiplePageFonts } from 'react-native-quran-hafs';
|
|
54
|
+
|
|
55
|
+
const pages = [1, 2, 293, 294, 295]; // Al-Fatihah + start of Al-Kahf
|
|
56
|
+
|
|
57
|
+
await downloadMultiplePageFonts(
|
|
58
|
+
pages,
|
|
59
|
+
'https://raw.githubusercontent.com/quran/quran.com-images/master/fonts/',
|
|
60
|
+
(current, total, page) => {
|
|
61
|
+
console.log(`Downloaded ${current}/${total} - Page ${page}`);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Check Cache Status
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { isFontCached, getFontCacheStats } from 'react-native-quran-hafs';
|
|
70
|
+
|
|
71
|
+
// Check single page
|
|
72
|
+
const isCached = await isFontCached(1); // true/false
|
|
73
|
+
|
|
74
|
+
// Get cache statistics
|
|
75
|
+
const stats = await getFontCacheStats();
|
|
76
|
+
console.log(`Cached: ${stats.totalCached} fonts`);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Clear Cache
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { clearFontCache } from 'react-native-quran-hafs';
|
|
83
|
+
|
|
84
|
+
// Clear all fonts
|
|
85
|
+
await clearFontCache();
|
|
86
|
+
|
|
87
|
+
// Clear specific pages
|
|
88
|
+
await clearFontCache([1, 2, 3]);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Priority Pages
|
|
92
|
+
|
|
93
|
+
Pre-defined page groups for common use cases:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import {
|
|
97
|
+
PRIORITY_PAGES, // 53 most-read pages
|
|
98
|
+
JUZ_30_PAGES, // Juz 30 (pages 582-604)
|
|
99
|
+
AL_FATIHAH_PAGES, // Al-Fatihah (pages 1-2)
|
|
100
|
+
AL_KAHF_PAGES, // Al-Kahf (pages 293-304)
|
|
101
|
+
YASIN_PAGES, // Yasin (pages 440-445)
|
|
102
|
+
AL_MULK_PAGES, // Al-Mulk (pages 562-564)
|
|
103
|
+
AR_RAHMAN_PAGES, // Ar-Rahman (pages 531-534)
|
|
104
|
+
ALL_QURAN_PAGES, // All 604 pages
|
|
105
|
+
} from 'react-native-quran-hafs';
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
<!--  -->
|
|
109
|
+
<picture>
|
|
110
|
+
<img src="https://drive.google.com/drive/folders/13t9agWELZdZ_nMzAU82mrisX9pRt6Q3q" width="30%" height="20%" />
|
|
111
|
+
</picture>
|
|
112
|
+
<picture>
|
|
113
|
+
<img src="./screenshots/2.png" width="30%" height="20%" />
|
|
114
|
+
</picture>
|
|
115
|
+
<picture>
|
|
116
|
+
<img src="./screenshots/3.png" width="30%" height="20%" />
|
|
117
|
+
</picture>
|
|
118
|
+
<picture>
|
|
119
|
+
<img src="./screenshots/4.png" width="30%" height="20%" />
|
|
120
|
+
</picture>
|
|
121
|
+
<picture>
|
|
122
|
+
<img src="./screenshots/5.png" width="30%" height="20%" />
|
|
123
|
+
</picture>
|
|
124
|
+
|
|
125
|
+
## Preinstallation
|
|
126
|
+
|
|
127
|
+
- Install this font family [QCF_BSML](https://github.com/quran/quran.com-images/blob/master/res/fonts/QCF_BSML.TTF) and change its extention to be .ttf not .TTF
|
|
128
|
+
|
|
129
|
+
- install these packages:
|
|
130
|
+
|
|
131
|
+
- @react-native-clipboard/clipboard.
|
|
132
|
+
- @react-native-community/slider.
|
|
133
|
+
- axios.
|
|
134
|
+
- react-native-dynamic-fonts.
|
|
135
|
+
- react-native-fs.
|
|
136
|
+
- react-native-responsive-fontsize.
|
|
137
|
+
- react-native-track-player.
|
|
138
|
+
|
|
139
|
+
- Upload the [fonts](https://github.com/quran/quran.com-images/tree/master/res/fonts) files as it is to you server so it can be easily downloaded
|
|
140
|
+
|
|
141
|
+
- The fonts url example https://your-domain/fonts/
|
|
142
|
+
|
|
143
|
+
## How to install and run
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm install react-native-quran-hafs
|
|
147
|
+
cd ios
|
|
148
|
+
pod install
|
|
149
|
+
cd ..
|
|
150
|
+
npm run ios
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Apis
|
|
154
|
+
|
|
155
|
+
| Option | Description | Type | Required |
|
|
156
|
+
| ------------------------- | ------------------------------------------------------------------------------------- | ---------------------------- | -------- |
|
|
157
|
+
| chapterId | The surah or juz id | number | true |
|
|
158
|
+
| type | It's a type of what you want to display (surah or juz) | QuranTypesEnums | true |
|
|
159
|
+
| QURAN_FONTS_API | Fonts url uploaded to your server | string | true |
|
|
160
|
+
| backgroundImage | The background of mushaf screen | ImageSourcePropType | false |
|
|
161
|
+
| surahNameFrameImage | The frame of surah name | ImageSourcePropType | false |
|
|
162
|
+
| onBookMarkedVerse | Callback funtion that return verse as ISurahVerse | (verse: ISurahVerse) => void | false |
|
|
163
|
+
| selectedBookedMarkedVerse | The verse object returned by onBookMarkedVerse function to scroll to passed ayah page | ISurahVerse | false |
|
|
164
|
+
| resizeImageBackgroundMode | It's a resize mode of mushaf background image | ImageResizeMode | false |
|
|
165
|
+
| selectionColor | It's a color when select a specific ayah | ColorValue | false |
|
|
166
|
+
|
|
167
|
+
## Usage Example
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
import {QuranPageLayout, QuranTypesEnums} from 'react-native-quran-hafs';
|
|
171
|
+
const App = () => {
|
|
172
|
+
return (
|
|
173
|
+
<QuranPageLayout
|
|
174
|
+
chapterId={1}
|
|
175
|
+
type={QuranTypesEnums.chapter} // QuranTypesEnums.juz
|
|
176
|
+
QURAN_FONTS_API="https://your-domain/fonts/"
|
|
177
|
+
onBookMarkedVerse={verse => console.log(verse)}
|
|
178
|
+
/>
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
export default App;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## How to:
|
|
185
|
+
|
|
186
|
+
- Automatic scrolling to specific verse:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
<QuranPageLayout
|
|
190
|
+
chapterId={67}
|
|
191
|
+
type={QuranTypesEnums.chapter}
|
|
192
|
+
QURAN_FONTS_API="https://your-domain/fonts/"
|
|
193
|
+
selectedBookedMarkedVerse={{
|
|
194
|
+
chapter_code_v1: 194,
|
|
195
|
+
chapter_id: 67,
|
|
196
|
+
id: 5263,
|
|
197
|
+
page_number: 563,
|
|
198
|
+
text_uthmani:
|
|
199
|
+
'أَفَمَن يَمْشِى مُكِبًّا عَلَىٰ وَجْهِهِۦٓ أَهْدَىٰٓ أَمَّن يَمْشِى سَوِيًّا عَلَىٰ صِرَٰطٍ مُّسْتَقِيمٍ',
|
|
200
|
+
verse_font_famliy: 'QCF_P563',
|
|
201
|
+
verse_key: '67:22',
|
|
202
|
+
verse_number: 22,
|
|
203
|
+
}}
|
|
204
|
+
onBookMarkedVerse={verse => {
|
|
205
|
+
console.log(verse);
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+

|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Reactotron from 'reactotron-react-native';
|
|
2
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
|
+
|
|
4
|
+
Reactotron.setAsyncStorageHandler(AsyncStorage)
|
|
5
|
+
.configure() // controls connection & communication settings
|
|
6
|
+
.useReactNative() // add all built-in react native plugins
|
|
7
|
+
.connect(); // let's connect!
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @format
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import 'react-native';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import App from '../App';
|
|
8
|
+
|
|
9
|
+
// Note: import explicitly to use the types shipped with jest.
|
|
10
|
+
import {it} from '@jest/globals';
|
|
11
|
+
|
|
12
|
+
// Note: test renderer must be required after react-native.
|
|
13
|
+
import renderer from 'react-test-renderer';
|
|
14
|
+
|
|
15
|
+
it('renders correctly', () => {
|
|
16
|
+
renderer.create(<App />);
|
|
17
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
apply plugin: "com.android.application"
|
|
2
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
3
|
+
apply plugin: "com.facebook.react"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is the configuration block to customize your React Native Android app.
|
|
7
|
+
* By default you don't need to apply any configuration, just uncomment the lines you need.
|
|
8
|
+
*/
|
|
9
|
+
react {
|
|
10
|
+
/* Folders */
|
|
11
|
+
// The root of your project, i.e. where "package.json" lives. Default is '..'
|
|
12
|
+
// root = file("../")
|
|
13
|
+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
|
|
14
|
+
// reactNativeDir = file("../node_modules/react-native")
|
|
15
|
+
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
|
|
16
|
+
// codegenDir = file("../node_modules/@react-native/codegen")
|
|
17
|
+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
|
|
18
|
+
// cliFile = file("../node_modules/react-native/cli.js")
|
|
19
|
+
|
|
20
|
+
/* Variants */
|
|
21
|
+
// The list of variants to that are debuggable. For those we're going to
|
|
22
|
+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
|
|
23
|
+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
|
|
24
|
+
// debuggableVariants = ["liteDebug", "prodDebug"]
|
|
25
|
+
|
|
26
|
+
/* Bundling */
|
|
27
|
+
// A list containing the node command and its flags. Default is just 'node'.
|
|
28
|
+
// nodeExecutableAndArgs = ["node"]
|
|
29
|
+
//
|
|
30
|
+
// The command to run when bundling. By default is 'bundle'
|
|
31
|
+
// bundleCommand = "ram-bundle"
|
|
32
|
+
//
|
|
33
|
+
// The path to the CLI configuration file. Default is empty.
|
|
34
|
+
// bundleConfig = file(../rn-cli.config.js)
|
|
35
|
+
//
|
|
36
|
+
// The name of the generated asset file containing your JS bundle
|
|
37
|
+
// bundleAssetName = "MyApplication.android.bundle"
|
|
38
|
+
//
|
|
39
|
+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
|
|
40
|
+
// entryFile = file("../js/MyApplication.android.js")
|
|
41
|
+
//
|
|
42
|
+
// A list of extra flags to pass to the 'bundle' commands.
|
|
43
|
+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
|
|
44
|
+
// extraPackagerArgs = []
|
|
45
|
+
|
|
46
|
+
/* Hermes Commands */
|
|
47
|
+
// The hermes compiler command to run. By default it is 'hermesc'
|
|
48
|
+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
|
|
49
|
+
//
|
|
50
|
+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
|
51
|
+
// hermesFlags = ["-O", "-output-source-map"]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
|
|
56
|
+
*/
|
|
57
|
+
def enableProguardInReleaseBuilds = false
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The preferred build flavor of JavaScriptCore (JSC)
|
|
61
|
+
*
|
|
62
|
+
* For example, to use the international variant, you can use:
|
|
63
|
+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
|
|
64
|
+
*
|
|
65
|
+
* The international variant includes ICU i18n library and necessary data
|
|
66
|
+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
|
|
67
|
+
* give correct results when using with locales other than en-US. Note that
|
|
68
|
+
* this variant is about 6MiB larger per architecture than default.
|
|
69
|
+
*/
|
|
70
|
+
def jscFlavor = 'org.webkit:android-jsc:+'
|
|
71
|
+
|
|
72
|
+
android {
|
|
73
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
74
|
+
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
75
|
+
compileSdk rootProject.ext.compileSdkVersion
|
|
76
|
+
|
|
77
|
+
namespace "com.quranapp"
|
|
78
|
+
defaultConfig {
|
|
79
|
+
applicationId "com.quranapp"
|
|
80
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
81
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
82
|
+
versionCode 1
|
|
83
|
+
versionName "1.0"
|
|
84
|
+
}
|
|
85
|
+
signingConfigs {
|
|
86
|
+
debug {
|
|
87
|
+
storeFile file('debug.keystore')
|
|
88
|
+
storePassword 'android'
|
|
89
|
+
keyAlias 'androiddebugkey'
|
|
90
|
+
keyPassword 'android'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
buildTypes {
|
|
94
|
+
debug {
|
|
95
|
+
signingConfig signingConfigs.debug
|
|
96
|
+
}
|
|
97
|
+
release {
|
|
98
|
+
// Caution! In production, you need to generate your own keystore file.
|
|
99
|
+
// see https://reactnative.dev/docs/signed-apk-android.
|
|
100
|
+
signingConfig signingConfigs.debug
|
|
101
|
+
minifyEnabled enableProguardInReleaseBuilds
|
|
102
|
+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
dependencies {
|
|
108
|
+
// The version of react-native is set by the React Native Gradle Plugin
|
|
109
|
+
implementation("com.facebook.react:react-android")
|
|
110
|
+
|
|
111
|
+
if (hermesEnabled.toBoolean()) {
|
|
112
|
+
implementation("com.facebook.react:hermes-android")
|
|
113
|
+
} else {
|
|
114
|
+
implementation jscFlavor
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
# By default, the flags in this file are appended to flags specified
|
|
3
|
+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
|
|
4
|
+
# You can edit the include path and order by changing the proguardFiles
|
|
5
|
+
# directive in build.gradle.
|
|
6
|
+
#
|
|
7
|
+
# For more details, see
|
|
8
|
+
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
9
|
+
|
|
10
|
+
# Add any project specific keep options here:
|