Last active
June 25, 2019 03:44
-
-
Save duytq94/c22e19d4d987a131f0af0f3672633d56 to your computer and use it in GitHub Desktop.
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
class TabIndicatorPainter extends CustomPainter { | |
Paint painter; | |
double xPos, radiusOval; | |
double radiusOvalOrigin = 20.0; | |
TabIndicatorPainter(double xPos, double radiusOval) { | |
painter = new Paint() | |
..color = Colors.white | |
..style = PaintingStyle.fill; | |
this.xPos = xPos; | |
this.radiusOval = radiusOval; | |
} | |
double processRadiusOval(double value) { | |
if (value <= 30.0) { | |
return value; | |
} else if (value <= 40.0) { | |
return value = radiusOvalOrigin + (40.0 - value); | |
} else if (value <= 45) { | |
return value = radiusOvalOrigin + (value - 40.0); | |
} else { | |
return value = radiusOvalOrigin + (50.0 - value); | |
} | |
} | |
double processRadiusOval2(double value) { | |
if (value <= 40.0) { | |
return 0.0; | |
} else if (value <= 45.0) { | |
return value = value - 40.0; | |
} else { | |
return value = (50.0 - value); | |
} | |
} | |
@override | |
void paint(Canvas canvas, Size size) { | |
canvas.drawOval( | |
new Rect.fromLTRB(xPos - processRadiusOval2(radiusOval), 0.0, xPos + processRadiusOval(radiusOval), 20.0), | |
painter); | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment