Created
June 15, 2021 09:26
-
-
Save PreyeaRegmi/17d82d0162dcf73cc7eefaef74ba6f20 to your computer and use it in GitHub Desktop.
The paint method of "CurvePageSwitcher" to draw tab selection arc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The paint method of "CurvePageSwitcher" to draw tab selection arc | |
void _drawSwipeAbleArc(Canvas canvas, Size size) { | |
Path path = Path(); | |
path.moveTo(-2, size.height - archBottomOffset); | |
path.cubicTo( | |
-2, | |
size.height - archBottomOffset, | |
size.width / 2, | |
size.height - arcHeight - archBottomOffset, | |
size.width + 2, | |
size.height - archBottomOffset); | |
path.moveTo(size.width + 2, size.height - archBottomOffset); | |
path.close(); | |
double left, right; | |
if (showLeftAsFirstPage) { | |
left = size.width / 2 - size.width / 2 * animation.value; | |
right = size.width / 2; | |
swipeArcPaint.color = Colors.green; | |
} else { | |
left = size.width / 2; | |
right = size.width * animation.value; | |
swipeArcPaint.color = Colors.deepPurple; | |
} | |
canvas.clipRect(Rect.fromLTRB(left, 0, right, size.height)); | |
canvas.drawPath(path, swipeArcPaint); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment