setTopSliderHeight method
Implementation
Future<void> setTopSliderHeight(double heightPercentage) async {
// التأكد من أن القيمة ضمن النطاق المسموح
// Ensure value is within allowed range
final clampedHeight = heightPercentage.clamp(0.1, 0.85);
// إذا كانت القيمة هي نفسها القيمة الحالية، لا داعي للأنيميشن
// If value is same as current, no need for animation
if ((topSliderHeight.value - clampedHeight).abs() < 0.01) {
log('Top slider height already at target: $clampedHeight',
name: 'SliderController');
return;
}
log('Animating top slider height to: $clampedHeight',
name: 'SliderController');
// إعداد الأنيميشن من القيمة الحالية إلى القيمة الجديدة
// Setup animation from current value to new value
topHeightAnimation = Tween<double>(
begin: topSliderHeight.value,
end: clampedHeight,
).animate(CurvedAnimation(
parent: topHeightController,
curve: Curves.easeInOut,
));
// إزالة listeners السابقة لتجنب memory leaks
// Remove previous listeners to avoid memory leaks
topHeightController.removeListener(() {});
// إضافة listener جديد
// Add new listener
topHeightAnimation.addListener(() {
topSliderHeight.value = topHeightAnimation.value;
});
// تشغيل الأنيميشن
// Run animation
topHeightController.reset();
await topHeightController.forward();
}