Skip to content

Commit

Permalink
Changed FAB to look more like new Gmail
Browse files Browse the repository at this point in the history
  • Loading branch information
iampawan committed Mar 15, 2019
1 parent 502e366 commit 64bcea2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
72 changes: 57 additions & 15 deletions lib/ui/common/email_fab.dart
Expand Up @@ -10,23 +10,65 @@ class EmailFAB extends StatelessWidget {
return FloatingActionButton(
backgroundColor:
Theme.of(context).brightness == Brightness.dark ? null : Colors.white,
child: ShaderMask(
shaderCallback: (Rect bounds) {
return RadialGradient(
center: Alignment.center,
radius: 1.0,
colors: <Color>[
Colors.yellowAccent,
Colors.blueAccent,
Colors.redAccent,
Colors.greenAccent,
],
tileMode: TileMode.mirror,
).createShader(bounds);
},
child: Icon(Icons.add, size: 40.0),
// child: ShaderMask(
// shaderCallback: (Rect bounds) {
// return RadialGradient(
// center: Alignment.center,
// radius: 1.0,
// colors: <Color>[
// Colors.yellowAccent,
// Colors.blueAccent,
// Colors.redAccent,
// Colors.greenAccent,
// ],
// tileMode: TileMode.mirror,
// ).createShader(bounds);
// },
// child: Icon(Icons.add, size: 40.0),
// ),
child: CustomPaint(
child: Container(),
foregroundPainter: FloatingPainter(),
),
onPressed: () {},
);
}
}

class FloatingPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint amberPaint = Paint()
..color = Colors.amber
..strokeWidth = 5;

Paint greenPaint = Paint()
..color = Colors.green
..strokeWidth = 5;

Paint bluePaint = Paint()
..color = Colors.blue
..strokeWidth = 5;

Paint redPaint = Paint()
..color = Colors.red
..strokeWidth = 5;

canvas.drawLine(Offset(size.width * 0.27, size.height * 0.5),
Offset(size.width * 0.5, size.height * 0.5), amberPaint);
canvas.drawLine(
Offset(size.width * 0.5, size.height * 0.5),
Offset(size.width * 0.5, size.height - (size.height * 0.27)),
greenPaint);
canvas.drawLine(Offset(size.width * 0.5, size.height * 0.5),
Offset(size.width - (size.width * 0.27), size.height * 0.5), bluePaint);
canvas.drawLine(Offset(size.width * 0.5, size.height * 0.5),
Offset(size.width * 0.5, size.height * 0.27), redPaint);
}

@override
bool shouldRepaint(FloatingPainter oldDelegate) => false;

@override
bool shouldRebuildSemantics(FloatingPainter oldDelegate) => false;
}
4 changes: 2 additions & 2 deletions pubspec.lock
Expand Up @@ -108,7 +108,7 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.4.0"
quiver:
dependency: transitive
description:
Expand Down Expand Up @@ -185,4 +185,4 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.1.1-dev.0.0 <3.0.0"
dart: ">=2.1.0 <3.0.0"

0 comments on commit 64bcea2

Please sign in to comment.