@moustafahelmi/react-native-quran-app 1.4.2 → 1.6.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/package.json +13 -5
- package/src/hooks/apis/useGetChapterByPage.ts +5 -5
- package/src/hooks/apis/useGetReciters.ts +6 -2
- package/src/layouts/quranPageLayout.tsx +25 -19
- package/src/types/index.ts +2 -0
- package/.bundle/config +0 -2
- package/.eslintrc.js +0 -4
- package/.prettierrc.js +0 -7
- package/.watchmanconfig +0 -1
- package/App.tsx +0 -23
- package/Gemfile +0 -9
- package/Gemfile.lock +0 -105
- package/MIGRATION.md +0 -163
- package/ReactotronConfig.js +0 -7
- package/__tests__/App.test.tsx +0 -17
- package/android/app/build.gradle +0 -118
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +0 -10
- package/android/app/src/debug/AndroidManifest.xml +0 -9
- package/android/app/src/main/AndroidManifest.xml +0 -25
- 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 +0 -22
- package/android/app/src/main/java/com/quranapp/MainApplication.kt +0 -43
- package/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -37
- 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 +0 -3
- package/android/app/src/main/res/values/styles.xml +0 -9
- package/android/build.gradle +0 -21
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/android/gradle.properties +0 -41
- package/android/gradlew +0 -249
- package/android/gradlew.bat +0 -92
- package/android/link-assets-manifest.json +0 -17
- package/android/settings.gradle +0 -4
- package/app.json +0 -4
- package/babel.config.js +0 -3
- package/index.js +0 -11
- package/ios/.xcode.env +0 -11
- package/ios/Podfile +0 -40
- package/ios/Podfile.lock +0 -1460
- package/ios/QuranApp/AppDelegate.h +0 -6
- package/ios/QuranApp/AppDelegate.mm +0 -31
- package/ios/QuranApp/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
- package/ios/QuranApp/Images.xcassets/Contents.json +0 -6
- package/ios/QuranApp/Info.plist +0 -57
- package/ios/QuranApp/LaunchScreen.storyboard +0 -47
- package/ios/QuranApp/PrivacyInfo.xcprivacy +0 -38
- package/ios/QuranApp/main.m +0 -10
- package/ios/QuranApp.xcodeproj/project.pbxproj +0 -729
- package/ios/QuranApp.xcodeproj/xcshareddata/xcschemes/QuranApp.xcscheme +0 -88
- package/ios/QuranApp.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/QuranAppTests/Info.plist +0 -24
- package/ios/QuranAppTests/QuranAppTests.m +0 -66
- package/ios/link-assets-manifest.json +0 -17
- package/jest.config.js +0 -3
- package/metro.config.js +0 -11
- package/react-native.config.js +0 -7
- 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/tsconfig.json +0 -3
- package/videos/1.gif +0 -0
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moustafahelmi/react-native-quran-app",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "React Native Quran
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"description": "React Native library for displaying Quran with Hafs recitation, audio playback, and customizable components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
|
-
"
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src/"
|
|
9
|
+
],
|
|
10
|
+
"keywords": ["react-native", "quran", "hafs", "islamic", "mobile", "library", "components"],
|
|
7
11
|
"author": "Moustafa Helmi",
|
|
8
12
|
"license": "MIT",
|
|
9
13
|
"repository": {
|
|
@@ -22,14 +26,16 @@
|
|
|
22
26
|
"@react-native-clipboard/clipboard": "^1.14.1",
|
|
23
27
|
"@react-native-community/slider": "^4.5.2",
|
|
24
28
|
"axios": "^1.6.8",
|
|
25
|
-
"react": "18.2.0",
|
|
26
|
-
"react-native": "0.74.0",
|
|
27
29
|
"react-native-dynamic-fonts": "^0.3.2",
|
|
28
30
|
"react-native-fs": "^2.20.0",
|
|
29
31
|
"react-native-quran-hafs": "^1.0.3",
|
|
30
32
|
"react-native-responsive-fontsize": "^0.5.1",
|
|
31
33
|
"react-native-track-player": "^4.1.1"
|
|
32
34
|
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"react": ">=18.0.0",
|
|
37
|
+
"react-native": ">=0.70.0"
|
|
38
|
+
},
|
|
33
39
|
"devDependencies": {
|
|
34
40
|
"@babel/core": "^7.20.0",
|
|
35
41
|
"@babel/preset-env": "^7.20.0",
|
|
@@ -44,6 +50,8 @@
|
|
|
44
50
|
"eslint": "^8.19.0",
|
|
45
51
|
"jest": "^29.6.3",
|
|
46
52
|
"prettier": "2.8.8",
|
|
53
|
+
"react": "18.2.0",
|
|
54
|
+
"react-native": "0.74.0",
|
|
47
55
|
"react-test-renderer": "18.2.0",
|
|
48
56
|
"reactotron-react-native": "^5.1.6",
|
|
49
57
|
"typescript": "5.0.4"
|
|
@@ -80,11 +80,11 @@ const useGetChapterByPage = ({
|
|
|
80
80
|
return downoladThePageFont(Number(item), () => {}, QURAN_FONTS_API);
|
|
81
81
|
});
|
|
82
82
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
83
|
+
await Promise.all(promises);
|
|
84
|
+
setIsLoading(false);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
setIsLoading(false);
|
|
87
|
+
}
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
const getTargetChapterPage = async () => {
|
|
@@ -8,15 +8,19 @@ import {I18nManager} from 'react-native';
|
|
|
8
8
|
const useGetReciters = ({
|
|
9
9
|
chapterId,
|
|
10
10
|
type,
|
|
11
|
+
skip = false,
|
|
11
12
|
}: {
|
|
12
13
|
chapterId: number;
|
|
13
14
|
type: QuranTypesEnums;
|
|
15
|
+
skip?: boolean;
|
|
14
16
|
}) => {
|
|
15
17
|
const [allReciters, setAllReciters] = useState<IReciter[]>([]);
|
|
16
18
|
const {getChapterAudionUrl} = useGetChapterAudio();
|
|
17
19
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
if (!skip) {
|
|
21
|
+
getReciters();
|
|
22
|
+
}
|
|
23
|
+
}, [skip]);
|
|
20
24
|
|
|
21
25
|
const getReciters = async () => {
|
|
22
26
|
const queryParams = {
|
|
@@ -27,6 +27,8 @@ const QuranPageLayout = ({
|
|
|
27
27
|
quranPageContainerStyle,
|
|
28
28
|
selectionColor,
|
|
29
29
|
autoCompleteAudioAfterPlayingVerse,
|
|
30
|
+
disableAudio = false,
|
|
31
|
+
showAudioPlayer = true,
|
|
30
32
|
}: IQuranPageLayout) => {
|
|
31
33
|
const flatlistRef = useRef<any>();
|
|
32
34
|
const {chapterLookUp} = useGetChapterLookup({
|
|
@@ -39,7 +41,7 @@ const QuranPageLayout = ({
|
|
|
39
41
|
type,
|
|
40
42
|
QURAN_FONTS_API: QURAN_FONTS_API,
|
|
41
43
|
});
|
|
42
|
-
const {allReciters} = useGetReciters({chapterId, type});
|
|
44
|
+
const {allReciters} = useGetReciters({chapterId, type, skip: disableAudio});
|
|
43
45
|
const audioPlayerRef = useRef<IAudioPlayerRef>();
|
|
44
46
|
const [selectedVerse, setSelectedVerse] = useState<ISurahVerse>(
|
|
45
47
|
{} as ISurahVerse,
|
|
@@ -65,8 +67,10 @@ const QuranPageLayout = ({
|
|
|
65
67
|
);
|
|
66
68
|
|
|
67
69
|
useEffect(() => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
if (!disableAudio) {
|
|
71
|
+
TrackPlayer.setupPlayer();
|
|
72
|
+
}
|
|
73
|
+
}, [disableAudio]);
|
|
70
74
|
useEffect(() => {
|
|
71
75
|
if (!isLoading && selectedBookedMarkedVerse) {
|
|
72
76
|
setSelectedVerse(selectedBookedMarkedVerse);
|
|
@@ -154,22 +158,24 @@ const QuranPageLayout = ({
|
|
|
154
158
|
}}
|
|
155
159
|
/>
|
|
156
160
|
)}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
setVersesBeforeAndAfterCurrentVerse
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
autoCompleteAudioAfterPlayingVerse
|
|
171
|
-
|
|
172
|
-
|
|
161
|
+
{!disableAudio && showAudioPlayer && (
|
|
162
|
+
<AudioPlayer
|
|
163
|
+
ref={audioPlayerRef}
|
|
164
|
+
chapterId={selectedVerse?.chapter_id ?? chapterId}
|
|
165
|
+
setSelectedVerse={setSelectedVerse}
|
|
166
|
+
selectedVerse={selectedVerse}
|
|
167
|
+
allReciter={allReciters}
|
|
168
|
+
versesBeforeAndAfterCurrentVerse={versesBeforeAndAfterCurrentVerse}
|
|
169
|
+
setVersesBeforeAndAfterCurrentVerse={
|
|
170
|
+
setVersesBeforeAndAfterCurrentVerse
|
|
171
|
+
}
|
|
172
|
+
originalVerse={originalVerse}
|
|
173
|
+
showSlider={showSlider}
|
|
174
|
+
autoCompleteAudioAfterPlayingVerse={
|
|
175
|
+
autoCompleteAudioAfterPlayingVerse
|
|
176
|
+
}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
173
179
|
</View>
|
|
174
180
|
</SafeAreaView>
|
|
175
181
|
);
|
package/src/types/index.ts
CHANGED
|
@@ -174,6 +174,8 @@ export interface IQuranPageLayout {
|
|
|
174
174
|
quranPageContainerStyle?: StyleProp<ViewStyle>;
|
|
175
175
|
selectionColor?: ColorValue;
|
|
176
176
|
autoCompleteAudioAfterPlayingVerse?: boolean;
|
|
177
|
+
disableAudio?: boolean;
|
|
178
|
+
showAudioPlayer?: boolean;
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
export enum QuranTypesEnums {
|
package/.bundle/config
DELETED
package/.eslintrc.js
DELETED
package/.prettierrc.js
DELETED
package/.watchmanconfig
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/App.tsx
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
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/ReactotronConfig.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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!
|
package/__tests__/App.test.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
});
|
package/android/app/build.gradle
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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
|
|
@@ -1,10 +0,0 @@
|
|
|
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:
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
xmlns:tools="http://schemas.android.com/tools">
|
|
4
|
-
|
|
5
|
-
<application
|
|
6
|
-
android:usesCleartextTraffic="true"
|
|
7
|
-
tools:targetApi="28"
|
|
8
|
-
tools:ignore="GoogleAppIndexingWarning"/>
|
|
9
|
-
</manifest>
|