Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding shader #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/curved_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CurvedNavigationBar extends StatefulWidget {
final Curve animationCurve;
final Duration animationDuration;
final double height;
final Shader shader;

CurvedNavigationBar({
Key key,
Expand All @@ -25,6 +26,7 @@ class CurvedNavigationBar extends StatefulWidget {
this.animationCurve = Curves.easeOut,
this.animationDuration = const Duration(milliseconds: 600),
this.height = 75.0,
this.shader,
}) : assert(items != null),
assert(items.length >= 1),
assert(0 <= index && index < items.length),
Expand Down Expand Up @@ -127,7 +129,7 @@ class CurvedNavigationBarState extends State<CurvedNavigationBar>
bottom: 0 - (75.0 - widget.height),
child: CustomPaint(
painter: NavCustomPainter(
_pos, _length, widget.color, Directionality.of(context)),
_pos, _length, widget.color, widget.shader, Directionality.of(context)),
child: Container(
height: 75.0,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/src/nav_custom_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ class NavCustomPainter extends CustomPainter {
double loc;
double s;
Color color;
Shader shader;
TextDirection textDirection;

NavCustomPainter(
double startingLoc, int itemsLength, this.color, this.textDirection) {
double startingLoc, int itemsLength, this.color, this.shader, this.textDirection) {
final span = 1.0 / itemsLength;
s = 0.2;
double l = startingLoc + (span - s) / 2;
Expand All @@ -18,6 +19,7 @@ class NavCustomPainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color
..shader = shader
..style = PaintingStyle.fill;

final path = Path()
Expand Down