curved_navigation_bar
curved_navigation_bar copied to clipboard
Add Props to accept the curve border and shadow
Hi recently i used your package, but it doesnt have the prop to accept border customization around the NavCustomPainter. in next updation add this feature.
class NavCustomPainter extends CustomPainter { late double loc; late double s; Color color; Color borderColor; // Border color double borderWidth; // Border width Color shadowColor; // Shadow color double shadowBlurRadius; // Shadow blur radius Offset shadowOffset; // Shadow offset TextDirection textDirection;
NavCustomPainter( double startingLoc, int itemsLength, this.color, this.textDirection, { this.borderColor = Colors.black, this.borderWidth = 2.0, this.shadowColor = Colors.black54, this.shadowBlurRadius = 6.0, this.shadowOffset = const Offset(0, 4), }) { final span = 1.0 / itemsLength; s = 0.2; double l = startingLoc + (span - s) / 2; loc = textDirection == TextDirection.rtl ? 0.8 - l : l; }
@override void paint(Canvas canvas, Size size) { // Create the fill paint final fillPaint = Paint() ..color = color ..style = PaintingStyle.fill;
// Create the border paint
final borderPaint = Paint()
..color = borderColor
..style = PaintingStyle.stroke
..strokeWidth = borderWidth;
final path = Path()
..moveTo(0, 0)
..lineTo((loc - 0.1) * size.width, 0)
..cubicTo(
(loc + s * 0.20) * size.width,
size.height * 0.05,
loc * size.width,
size.height * 0.60,
(loc + s * 0.50) * size.width,
size.height * 0.60,
)
..cubicTo(
(loc + s) * size.width,
size.height * 0.60,
(loc + s - s * 0.20) * size.width,
size.height * 0.05,
(loc + s + 0.1) * size.width,
0,
)
..lineTo(size.width, 0)
..lineTo(size.width, size.height)
..lineTo(0, size.height)
..close();
// Add shadow before drawing the shape
canvas.drawShadow(path, shadowColor, shadowBlurRadius, true);
// Draw the filled shape
canvas.drawPath(path, fillPaint);
// Draw the border
canvas.drawPath(path, borderPaint);
}
@override bool shouldRepaint(CustomPainter oldDelegate) { return this != oldDelegate; } }