showTafsirOnTap method
-------- onTap
--------
عرض تفسير الآية عند النقر عليها
Shows Tafsir when an ayah is tapped
Implementation
Future<void> showTafsirOnTap({
required BuildContext context,
required int surahNum,
required int ayahNum,
required String ayahText,
required int pageIndex,
required String ayahTextN,
required int ayahUQNum,
required int ayahNumber,
bool? isDark,
}) async {
// شرح: هذا السطر لطباعة رسالة عند استدعاء الدالة للتأكد من تنفيذها
// Explanation: This line logs when the function is called for debugging
log('showTafsirOnTap called', name: 'TafsirUi');
// تحديد قيمة isDark مبدئيًا إذا لم يتم تمريرها
// Set default value for isDark if not passed
final bool isDarkMode = isDark ?? false;
// التحقق من صحة السياق
// Check context validity
BuildContext? validContext = _getValidContext(context);
if (validContext == null) {
log('لا يوجد سياق صالح لعرض التفسير، يُرجى التأكد من تمرير سياق من شاشة نشطة',
name: 'TafsirUi');
return;
}
log('تم العثور على سياق صالح، بدء عملية التفسير', name: 'TafsirUi');
// عرض النافذة المنبثقة فوراً مع تحميل البيانات داخلها
// Show bottom sheet immediately with data loading inside
try {
log('عرض نافذة التفسير مع تحميل البيانات بالتوازي', name: 'TafsirUi');
await showModalBottomSheet(
context: validContext,
isScrollControlled: true,
backgroundColor: Colors.transparent,
enableDrag: true,
isDismissible: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (BuildContext modalContext) {
// تهيئة بيانات التفسير داخل النافذة المنبثقة
// Initialize tafsir data inside the bottom sheet
return FutureBuilder<void>(
future: _initializeTafsirData(
ayahText: ayahText,
surahNum: surahNum,
ayahTextN: ayahTextN,
ayahUQNum: ayahUQNum,
pageIndex: pageIndex,
),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// عرض مؤشر التحميل أثناء تحميل البيانات
// Show loading indicator while data is loading
return SafeArea(
child: Container(
height: MediaQuery.of(modalContext).size.height * 0.9,
decoration: BoxDecoration(
color: isDarkMode
? const Color(0xff1E1E1E)
: const Color(0xfffaf7f3),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(16),
),
),
child: const Center(
child: CircularProgressIndicator(),
),
),
);
}
// عرض واجهة التفسير بعد تحميل البيانات
// Show tafsir interface after data loading
return SafeArea(
child: SizedBox(
height: MediaQuery.of(modalContext).size.height * 0.9,
child: Scaffold(
backgroundColor: Colors.transparent,
body: Column(
children: [
ShowTafseer(
context: modalContext,
ayahUQNumber: ayahUQNum,
ayahNumber: ayahNumber,
pageIndex: pageIndex,
isDark: isDarkMode,
tafsirStyle: TafsirStyle(
backgroundColor: isDarkMode
? const Color(0xff1E1E1E)
: const Color(0xfffaf7f3),
tafsirNameWidget: Text(
'التفسير',
style: QuranLibrary().naskhStyle.copyWith(
fontSize: 24,
color: isDarkMode
? Colors.white
: Colors.black,
),
),
fontSizeWidget: Icon(
Icons.text_format_outlined,
size: 34,
color: isDarkMode ? Colors.white : Colors.black,
),
),
),
],
),
),
),
);
},
);
},
);
log('تم عرض نافذة التفسير بنجاح', name: 'TafsirUi');
} catch (e) {
log('خطأ في عرض نافذة التفسير المنبثقة: $e', name: 'TafsirUi');
}
}