calculateDynamicLineHeight method
حساب ارتفاع السطر الديناميكي للصفحة Calculate dynamic line height for page
Implementation
double calculateDynamicLineHeight({
required double availableHeight,
required int pageIndex,
required bool hasHeader,
required bool hasBasmala,
}) {
// شرح: حساب المساحة المستخدمة للعناصر الإضافية
// Explanation: Calculate space used by additional elements
double usedSpace = 0;
if (hasHeader) {
usedSpace += 80; // مساحة البنر
}
if (hasBasmala) {
usedSpace += 50; // مساحة البسملة
}
// شرح: المساحة المتبقية للأسطر
// Explanation: Remaining space for lines
final remainingHeight = (availableHeight - usedSpace) * 0.95;
// شرح: الحصول على عدد الأسطر المتوقع
// Explanation: Get expected lines count
final expectedLines = getExpectedLinesCount(pageIndex);
// شرح: حساب ارتفاع السطر
// Explanation: Calculate line height
if (expectedLines > 0) {
return pageIndex == 0 && shouldShowBasmala()
? remainingHeight / expectedLines + 9.3
: pageIndex == 0 && surahNumber == 9
? remainingHeight / expectedLines + 5
: remainingHeight / expectedLines;
}
// شرح: ارتفاع افتراضي
// Explanation: Default height
return 40.0;
}