Skip to content

Commit 803f3ea

Browse files
committed
[CODE] added some customizations, renamed some variables, added some documentation
1 parent fb71e28 commit 803f3ea

15 files changed

+90
-44
lines changed

.flutter-plugins

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is a generated file; do not edit or check into version control.
2-
path_provider=C:\\Users\\ASUS\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider-2.1.5\\
3-
path_provider_android=C:\\Users\\ASUS\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_android-2.2.15\\
4-
path_provider_foundation=C:\\Users\\ASUS\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_foundation-2.4.1\\
5-
path_provider_linux=C:\\Users\\ASUS\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_linux-2.2.1\\
6-
path_provider_windows=C:\\Users\\ASUS\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_windows-2.3.0\\
2+
path_provider=/Users/helal/.pub-cache/hosted/pub.dev/path_provider-2.1.5/
3+
path_provider_android=/Users/helal/.pub-cache/hosted/pub.dev/path_provider_android-2.2.15/
4+
path_provider_foundation=/Users/helal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/
5+
path_provider_linux=/Users/helal/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/
6+
path_provider_windows=/Users/helal/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/

.flutter-plugins-dependencies

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\ASUS\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\ASUS\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.15\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\ASUS\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\ASUS\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\ASUS\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2025-02-19 16:57:31.545966","version":"3.27.2","swift_package_manager_enabled":false}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/helal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/helal/.pub-cache/hosted/pub.dev/path_provider_android-2.2.15/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/helal/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/helal/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/helal/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2025-02-25 03:08:58.102903","version":"3.27.4","swift_package_manager_enabled":false}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ QuranLibraryScreen(
9898
final jozzs = QuranLibrary().allJoz;
9999
final hizbs = QuranLibrary().allHizb;
100100
final surahs = QuranLibrary().getAllSurahs();
101+
final ayahsOnPage = QuranLibrary().getAyahsByPage();
101102
102103
/// [getSurahInfo] تتيح لك الحصول على سورة مع جميع بياناتها عند تمرير رقم السورة لها.
103104
///

android/local.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sdk.dir=C:\\Users\\ASUS\\AppData\\Local\\Android\\sdk
2-
flutter.sdk=C:\\src\\flutter
1+
sdk.dir=/Users/helal/Development/Android/sdk
2+
flutter.sdk=/Users/helal/Development/flutter

lib/data/models/quran_fonts_models/ayah_model.dart

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class AyahFontsModel {
1818
/// The text of the Ayah (verse) in the Quran.
1919
final String text;
2020

21+
/// Custom text color for the Ayah.
22+
Color? singleAyahTextColor;
23+
2124
/// The text of the Ayah in Emlaey script.
2225
final String ayaTextEmlaey;
2326

@@ -57,6 +60,7 @@ class AyahFontsModel {
5760
required this.ayahUQNumber,
5861
required this.ayahNumber,
5962
required this.text,
63+
required this.singleAyahTextColor,
6064
required this.ayaTextEmlaey,
6165
required this.codeV2,
6266
required this.juz,
@@ -70,6 +74,7 @@ class AyahFontsModel {
7074
ayahUQNumber: json['number'],
7175
ayahNumber: json['numberInSurah'],
7276
text: json['text'],
77+
singleAyahTextColor: json['singleAyahTextColor'],
7378
ayaTextEmlaey: json['aya_text_emlaey'],
7479
codeV2: json['code_v2'],
7580
juz: json['juz'],
@@ -84,6 +89,7 @@ class AyahFontsModel {
8489
ayahUQNumber: 0,
8590
ayahNumber: 0,
8691
text: '',
92+
singleAyahTextColor: null,
8793
ayaTextEmlaey: '',
8894
codeV2: '',
8995
juz: 0,

lib/data/repositories/quran_repository.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class QuranRepository {
9090
/// [bookmarks] - A list of [BookmarkModel] instances to be saved.
9191
saveBookmarks(List<BookmarkModel> bookmarks) => GetStorage().write(
9292
_StorageConstants().bookmarks,
93-
bookmarks.map((bookmark) => json.encode(bookmark._toJson())).toList(),
93+
bookmarks.map((bookmark) => jsonEncode(bookmark._toJson())).toList(),
9494
);
9595

9696
/// Retrieves a list of bookmarks.
@@ -114,7 +114,7 @@ class QuranRepository {
114114
} else if (bookmark is String) {
115115
// Decode JSON string and cast to Map<String, dynamic>
116116
return BookmarkModel._fromJson(
117-
Map<String, dynamic>.from(json.decode(bookmark)),
117+
Map<String, dynamic>.from(jsonDecode(bookmark)),
118118
);
119119
} else {
120120
throw Exception("Unexpected bookmark type: ${bookmark.runtimeType}");

lib/presentation/controllers/quran/quran_ctrl.dart

+13-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class QuranCtrl extends GetxController {
1717
int lastPage = 1;
1818
int? initialPage;
1919
RxList<AyahModel> ayahsList = <AyahModel>[].obs;
20-
final selectedAyahIndexes = <int>[].obs;
20+
21+
/// List of selected ayahs by their unique number
22+
final selectedAyahsByUnequeNumber = <int>[].obs;
2123
bool isAyahSelected = false;
2224
RxDouble scaleFactor = 1.0.obs;
2325
RxDouble baseScaleFactor = 1.0.obs;
@@ -33,7 +35,7 @@ class QuranCtrl extends GetxController {
3335
staticPages.close();
3436
quranStops.close();
3537
surahsStart.close();
36-
selectedAyahIndexes.close();
38+
selectedAyahsByUnequeNumber.close();
3739
surahs.close();
3840
ayahs.close();
3941
ayahsList.close();
@@ -283,19 +285,20 @@ class QuranCtrl extends GetxController {
283285

284286
PageController get pageController => _pageController;
285287

286-
void toggleAyahSelection(int index) {
287-
if (selectedAyahIndexes.contains(index)) {
288-
selectedAyahIndexes.remove(index);
288+
/// Toggle the selection of an ayah by its unique number
289+
void toggleAyahSelection(int ayahUnequeNumber) {
290+
if (selectedAyahsByUnequeNumber.contains(ayahUnequeNumber)) {
291+
selectedAyahsByUnequeNumber.remove(ayahUnequeNumber);
289292
} else {
290-
selectedAyahIndexes.clear();
291-
selectedAyahIndexes.add(index);
292-
selectedAyahIndexes.refresh();
293+
selectedAyahsByUnequeNumber.clear();
294+
selectedAyahsByUnequeNumber.add(ayahUnequeNumber);
295+
selectedAyahsByUnequeNumber.refresh();
293296
}
294-
selectedAyahIndexes.refresh();
297+
selectedAyahsByUnequeNumber.refresh();
295298
}
296299

297300
void clearSelection() {
298-
selectedAyahIndexes.clear();
301+
selectedAyahsByUnequeNumber.clear();
299302
}
300303

301304
Widget textScale(dynamic widget1, dynamic widget2) {

lib/presentation/pages/quran_library_screen.dart

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class QuranLibraryScreen extends StatelessWidget {
2222
this.appBar,
2323
this.ayahIconColor,
2424
this.ayahSelectedBackgroundColor,
25+
this.ayahSelectedFontColor,
2526
this.bannerStyle,
2627
this.basmalaStyle,
2728
this.backgroundColor,
@@ -44,6 +45,7 @@ class QuranLibraryScreen extends StatelessWidget {
4445
this.surahNameStyle,
4546
this.surahNumber,
4647
this.textColor,
48+
this.singleAyahTextColors,
4749
this.topTitleChild,
4850
this.useDefaultAppBar = true,
4951
this.withPageView = true,
@@ -63,6 +65,7 @@ class QuranLibraryScreen extends StatelessWidget {
6365
///
6466
/// [ayahSelectedBackgroundColor] You can pass the color of the Ayah selected background
6567
final Color? ayahSelectedBackgroundColor;
68+
final Color? ayahSelectedFontColor;
6669

6770
/// تغيير نمط البسملة بواسطة هذه الفئة [BasmalaStyle]
6871
///
@@ -197,6 +200,7 @@ class QuranLibraryScreen extends StatelessWidget {
197200
///
198201
/// [textColor] You can pass the color of the Quran text
199202
final Color? textColor;
203+
final List<Color?>? singleAyahTextColors;
200204

201205
/// متغير لتعطيل أو تمكين شريط التطبيقات الافتراضية [useDefaultAppBar]
202206
///
@@ -340,7 +344,7 @@ class QuranLibraryScreen extends StatelessWidget {
340344
child: _QuranFontsPage(
341345
pageIndex: pageIndex,
342346
bookmarkList: bookmarkList,
343-
textColor: textColor,
347+
textColor: ayahSelectedFontColor ?? textColor,
344348
ayahIconColor: ayahIconColor,
345349
showAyahBookmarkedIcon: showAyahBookmarkedIcon,
346350
bookmarks: bookmarkCtrl.bookmarks,
@@ -400,7 +404,7 @@ class QuranLibraryScreen extends StatelessWidget {
400404
child: _QuranTextScale(
401405
pageIndex: pageIndex,
402406
bookmarkList: bookmarkList,
403-
textColor: textColor,
407+
textColor: ayahSelectedFontColor ?? textColor,
404408
ayahIconColor: ayahIconColor,
405409
showAyahBookmarkedIcon: showAyahBookmarkedIcon,
406410
bookmarks: bookmarkCtrl.bookmarks,

lib/presentation/widgets/custom_span.dart

+23-11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ TextSpan _span({
1818
required List<int> bookmarksAyahs,
1919
Color? bookmarksColor,
2020
Color? ayahSelectedBackgroundColor,
21+
Color? ayahSelectedFontColor,
2122
}) {
2223
// if (bookmarkList!.isEmpty) {
2324
// bookmarkList = bookmarks as List<BookmarkModel>;
@@ -49,9 +50,11 @@ TextSpan _span({
4950
height: 2,
5051
letterSpacing:
5152
pageIndex == 54 || pageIndex == 75 || pageIndex == 539 ? 0 : 30,
52-
color: quranCtrl.state.fontsSelected2.value == 1
53-
? textColor ?? Colors.transparent
54-
: null,
53+
color: isSelected && null != ayahSelectedFontColor
54+
? ayahSelectedFontColor
55+
: quranCtrl.state.fontsSelected2.value == 1
56+
? textColor ?? Colors.transparent
57+
: null,
5558
backgroundColor:
5659
bookmarkCtrl.hasBookmark(surahNum, ayahUQNum, bookmarkList)
5760
? bookmarksColor
@@ -80,9 +83,11 @@ TextSpan _span({
8083
height: 2,
8184
letterSpacing: 0,
8285
// wordSpacing: wordSpacing + 10,
83-
color: quranCtrl.state.fontsSelected2.value == 1
84-
? textColor ?? Colors.transparent
85-
: null,
86+
color: isSelected && null != ayahSelectedFontColor
87+
? ayahSelectedFontColor
88+
: quranCtrl.state.fontsSelected2.value == 1
89+
? textColor ?? Colors.transparent
90+
: null,
8691
backgroundColor:
8792
bookmarkCtrl.hasBookmark(surahNum, ayahUQNum, bookmarkList)
8893
? bookmarksColor
@@ -112,9 +117,11 @@ TextSpan _span({
112117
fontSize: fontSize,
113118
height: 2,
114119
letterSpacing: 0,
115-
color: quranCtrl.state.fontsSelected2.value == 1
116-
? textColor ?? Colors.transparent
117-
: null,
120+
color: isSelected && null != ayahSelectedFontColor
121+
? ayahSelectedFontColor
122+
: quranCtrl.state.fontsSelected2.value == 1
123+
? textColor ?? Colors.transparent
124+
: null,
118125
backgroundColor:
119126
bookmarkCtrl.hasBookmark(surahNum, ayahUQNum, bookmarkList)
120127
? bookmarksColor
@@ -217,6 +224,7 @@ TextSpan _customSpan({
217224
required List<int> bookmarksAyahs,
218225
Color? bookmarksColor,
219226
Color? ayahSelectedBackgroundColor,
227+
Color? ayahSelectedFontColor,
220228
String? languageCode,
221229
}) {
222230
final allBookmarks = bookmarks.values.expand((list) => list).toList();
@@ -230,7 +238,9 @@ TextSpan _customSpan({
230238
fontFamily: 'hafs',
231239
fontSize: fontSize,
232240
height: 2,
233-
color: textColor ?? Colors.black,
241+
color: isSelected && null != ayahSelectedFontColor
242+
? ayahSelectedFontColor
243+
: textColor ?? Colors.black,
234244
backgroundColor:
235245
bookmarkCtrl.hasBookmark(surahNum, ayahUQNum, bookmarkList)
236246
? bookmarksColor
@@ -272,7 +282,9 @@ TextSpan _customSpan({
272282
fontFamily: 'hafs',
273283
fontSize: fontSize,
274284
height: 2,
275-
color: ayahIconColor,
285+
color: isSelected && null != ayahSelectedFontColor
286+
? ayahSelectedFontColor
287+
: ayahIconColor,
276288
backgroundColor: bookmarkCtrl.hasBookmark(
277289
surahNum, ayahUQNum, bookmarkList)
278290
? bookmarksColor

lib/presentation/widgets/quran_fonts_page.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class _QuranFontsPage extends StatelessWidget {
1919
final Map<int, List<BookmarkModel>> bookmarks;
2020
final List<int> bookmarksAyahs;
2121
final Color? ayahSelectedBackgroundColor;
22+
final Color? ayahSelectedFontColor;
2223
final bool isDark;
2324
final bool showAyahBookmarkedIcon;
2425
final Widget? circularProgressWidget;
@@ -40,6 +41,7 @@ class _QuranFontsPage extends StatelessWidget {
4041
required this.bookmarks,
4142
required this.bookmarksAyahs,
4243
this.ayahSelectedBackgroundColor,
44+
this.ayahSelectedFontColor,
4345
this.onPagePress,
4446
this.isDark = false,
4547
this.circularProgressWidget,
@@ -270,7 +272,7 @@ class _QuranFontsPage extends StatelessWidget {
270272
],
271273
),
272274
children: List.generate(ayahs.length, (ayahIndex) {
273-
quranCtrl.state.isSelected = quranCtrl.selectedAyahIndexes
275+
quranCtrl.state.isSelected = quranCtrl.selectedAyahsByUnequeNumber
274276
.contains(ayahs[ayahIndex].ayahUQNumber);
275277
final allBookmarks = bookmarks.values.expand((list) => list).toList();
276278
bool isFirstAyah = ayahIndex == 0 &&
@@ -336,6 +338,7 @@ class _QuranFontsPage extends StatelessWidget {
336338
bookmarksAyahs: bookmarksAyahs,
337339
bookmarksColor: bookmarksColor,
338340
ayahSelectedBackgroundColor: ayahSelectedBackgroundColor,
341+
ayahSelectedFontColor: ayahSelectedFontColor,
339342
);
340343
}),
341344
),

lib/presentation/widgets/quran_library_search_screen.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ class QuranLibrarySearchScreen extends StatelessWidget {
1111
/// The [isDark] parameter allows you to set the screen's color scheme.
1212
/// If [isDark] is `true`, the screen will be dark. If it is `false` or null,
1313
/// the screen will be light.
14-
const QuranLibrarySearchScreen({super.key, this.isDark = false});
14+
const QuranLibrarySearchScreen(
15+
{super.key, this.isDark = false, this.textController});
1516

1617
/// Whether the screen should be dark or not.
1718
///
1819
/// If [isDark] is `true`, the screen will be dark. If it is `false` or null,
1920
/// the screen will be light.
2021
final bool isDark;
22+
final TextEditingController? textController;
2123

2224
@override
2325
Widget build(BuildContext context) {
@@ -51,6 +53,7 @@ class QuranLibrarySearchScreen extends StatelessWidget {
5153
children: [
5254
GetBuilder<QuranCtrl>(
5355
builder: (quranCtrl) => TextField(
56+
controller: textController,
5457
onChanged: (txt) {
5558
final searchResult = QuranLibrary().search(txt);
5659
quranCtrl.ayahsList.value = [...searchResult];

lib/presentation/widgets/quran_line.dart

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class QuranLine extends StatelessWidget {
88
this.bookmarksColor,
99
this.textColor,
1010
this.ayahSelectedBackgroundColor,
11+
this.ayahSelectedFontColor,
1112
this.bookmarkList,
1213
this.onPagePress,
1314
required this.pageIndex});
@@ -24,6 +25,7 @@ class QuranLine extends StatelessWidget {
2425
final Color? bookmarksColor;
2526
final Color? textColor;
2627
final Color? ayahSelectedBackgroundColor;
28+
final Color? ayahSelectedFontColor;
2729
final List? bookmarkList;
2830
final int pageIndex;
2931

@@ -45,8 +47,8 @@ class QuranLine extends StatelessWidget {
4547
child: RichText(
4648
text: TextSpan(
4749
children: line.ayahs.reversed.map((ayah) {
48-
quranCtrl.isAyahSelected =
49-
quranCtrl.selectedAyahIndexes.contains(ayah.ayahUQNumber);
50+
quranCtrl.isAyahSelected = quranCtrl.selectedAyahsByUnequeNumber
51+
.contains(ayah.ayahUQNumber);
5052
final allBookmarks =
5153
bookmarks.values.expand((list) => list).toList();
5254
// final String lastCharacter =
@@ -118,7 +120,10 @@ class QuranLine extends StatelessWidget {
118120
child: Text(
119121
ayah.text,
120122
style: TextStyle(
121-
color: textColor ?? Colors.black,
123+
color: quranCtrl.isAyahSelected &&
124+
null != ayahSelectedFontColor
125+
? ayahSelectedFontColor ?? textColor
126+
: Colors.black,
122127
fontSize: 23.55,
123128
fontFamily: "hafs",
124129
height: 1.7,

lib/presentation/widgets/quran_line_page.dart

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class _QuranLinePage extends StatelessWidget {
1515
final Color? textColor;
1616
final List? bookmarkList;
1717
final Color? ayahSelectedBackgroundColor;
18+
final Color? ayahSelectedFontColor;
1819
final VoidCallback? onPagePress;
1920
final List<String> newSurahs;
2021
final String? languageCode;
@@ -37,6 +38,7 @@ class _QuranLinePage extends StatelessWidget {
3738
this.textColor,
3839
this.bookmarkList,
3940
this.ayahSelectedBackgroundColor,
41+
this.ayahSelectedFontColor,
4042
this.onPagePress,
4143
required this.newSurahs,
4244
this.languageCode,
@@ -153,6 +155,7 @@ class _QuranLinePage extends StatelessWidget {
153155
pageIndex: pageIndex,
154156
ayahSelectedBackgroundColor:
155157
ayahSelectedBackgroundColor,
158+
ayahSelectedFontColor: ayahSelectedFontColor,
156159
onPagePress: onPagePress,
157160
),
158161
),
@@ -284,6 +287,7 @@ class _QuranLinePage extends StatelessWidget {
284287
pageIndex: pageIndex,
285288
ayahSelectedBackgroundColor:
286289
ayahSelectedBackgroundColor,
290+
ayahSelectedFontColor: ayahSelectedFontColor,
287291
onPagePress: onPagePress,
288292
),
289293
),

0 commit comments

Comments
 (0)