// lib/presentation/widgets/onboarding_indicator_painter.dart import 'dart:math'; import 'package:flutter/material.dart'; import 'package:proxibuy/core/config/app_colors.dart'; class OnboardingIndicatorPainter extends CustomPainter { final int pageCount; final int currentPage; final Color activeColor; final Color inactiveColor; final double strokeWidth; OnboardingIndicatorPainter({ required this.pageCount, required this.currentPage, this.activeColor = AppColors.primary, this.inactiveColor = AppColors.unselected, this.strokeWidth = 6.0, }); @override void paint(Canvas canvas, Size size) { final center = Offset(size.width / 2, size.height / 2); final radius = min(size.width, size.height) / 2; // ================== شروع تغییرات ================== // 1. تعریف اندازه فاصله بین قوس‌ها (بر حسب درجه) // این عدد را می‌توانید برای کم و زیاد کردن فاصله تغییر دهید const double gapInDegrees = 30.0; const double gapInRadians = gapInDegrees * (pi / 180); // 2. محاسبه طول جدید هر قوس (۹۰ درجه منهای اندازه فاصله) const double arcAngle = (pi / 2) - gapInRadians; // =================== پایان تغییرات =================== final startAngles = [-pi / 2, 0.0, pi / 2, pi]; for (int i = 0; i < pageCount; i++) { final paint = Paint() ..color = (i == currentPage) ? activeColor : inactiveColor ..style = PaintingStyle.stroke ..strokeWidth = strokeWidth ..strokeCap = StrokeCap.round; // StrokeCap.round لبه‌های خط را گرد می‌کند که زیباتر است // 3. محاسبه نقطه شروع جدید (با افزودن نصف فاصله برای وسط‌چین شدن) final correctedStartAngle = startAngles[i] + (gapInRadians / 2); canvas.drawArc( Rect.fromCircle(center: center, radius: radius), correctedStartAngle, // استفاده از نقطه شروع اصلاح شده arcAngle, // استفاده از طول قوس جدید false, paint, ); } } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return true; } }