2021-05-25 21:53:54 +00:00
|
|
|
part of 'pre_styled_buttons.dart';
|
|
|
|
|
|
|
|
class _BrandFlashButton extends StatefulWidget {
|
|
|
|
_BrandFlashButton({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_BrandFlashButtonState createState() => _BrandFlashButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _BrandFlashButtonState extends State<_BrandFlashButton>
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
late AnimationController _animationController;
|
|
|
|
late Animation _colorTween;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_animationController =
|
|
|
|
AnimationController(vsync: this, duration: Duration(milliseconds: 600));
|
|
|
|
_colorTween = ColorTween(
|
|
|
|
begin: BrandColors.black,
|
|
|
|
end: BrandColors.primary,
|
|
|
|
).animate(_animationController);
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_animationController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
late bool wasPrevStateIsEmpty;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var hasNoJobs = context.watch<JobsCubit>().state.isEmpty;
|
|
|
|
wasPrevStateIsEmpty = hasNoJobs;
|
|
|
|
var icon = hasNoJobs ? Ionicons.flash_outline : Ionicons.flash;
|
|
|
|
|
|
|
|
return BlocListener<JobsCubit, JobsState>(
|
|
|
|
listener: (context, state) {
|
|
|
|
if (wasPrevStateIsEmpty && state.jobList.isNotEmpty) {
|
|
|
|
wasPrevStateIsEmpty = false;
|
|
|
|
_animationController.forward();
|
|
|
|
} else if (!wasPrevStateIsEmpty && state.jobList.isEmpty) {
|
|
|
|
_animationController.reverse();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
showCupertinoModalBottomSheet(
|
2021-06-08 18:52:44 +00:00
|
|
|
barrierColor: Colors.black45,
|
2021-05-25 21:53:54 +00:00
|
|
|
expand: false,
|
|
|
|
context: context,
|
2021-06-08 18:52:44 +00:00
|
|
|
shadow: BoxShadow(color: Colors.transparent),
|
|
|
|
backgroundColor: Colors.transparent,
|
2021-05-25 21:53:54 +00:00
|
|
|
builder: (context) => BrandBottomSheet(
|
|
|
|
child: JobsContent(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
icon: AnimatedBuilder(
|
|
|
|
animation: _colorTween,
|
|
|
|
builder: (context, child) {
|
|
|
|
return Icon(
|
|
|
|
icon,
|
|
|
|
color: _colorTween.value,
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|