Last active
October 6, 2019 23:04
-
-
Save nelsonjunior/d31db87549d25c440f8ba7cdd1b92d93 to your computer and use it in GitHub Desktop.
Revisions
-
nelsonjunior revised this gist
Oct 6, 2019 . 2 changed files with 29 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import 'dart:async'; import 'package:bloc_pattern/bloc_pattern.dart'; class AppBloc extends BlocBase { DateTime dataSelecionada = DateTime.now(); final StreamController<DateTime> _dataSelecionada$ = StreamController<DateTime>(); Stream<DateTime> get dataStream => _dataSelecionada$.stream; void dataAnterior() { dataSelecionada = dataSelecionada.subtract(Duration(days: 1)); _dataSelecionada$.sink.add(dataSelecionada); } void proximaData() { dataSelecionada = dataSelecionada.add(Duration(days: 1)); _dataSelecionada$.sink.add(dataSelecionada); } @override void dispose() { super.dispose(); _dataSelecionada$.close(); } } File renamed without changes. -
nelsonjunior created this gist
Oct 6, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,134 @@ import 'package:flutter/material.dart'; import 'package:ts_controle_ponto/app/app_bloc.dart'; import 'package:ts_controle_ponto/app/app_module.dart'; import 'package:ts_controle_ponto/app/shared/themes/colors.dart'; import 'package:ts_controle_ponto/app/shared/utils/data_utils.dart'; import 'package:vector_math/vector_math_64.dart' as math; class IndicadorJornada extends StatefulWidget { final double goalCompleted = 0.7; @override _IndicadorJornadaState createState() => _IndicadorJornadaState(); } class _IndicadorJornadaState extends State<IndicadorJornada> with SingleTickerProviderStateMixin { AnimationController _radialProgressAnimationController; Animation<double> _progressAnimation; final Duration fadeInDuration = Duration(milliseconds: 500); final Duration fillDuration = Duration(seconds: 2); double progressDegress = 0.0; @override void initState() { super.initState(); _radialProgressAnimationController = AnimationController(vsync: this, duration: Duration(seconds: 3)); _progressAnimation = Tween(begin: 0.0, end: 360.0).animate(CurvedAnimation( parent: _radialProgressAnimationController, curve: Curves.easeInOutSine)) ..addListener(() { setState(() { progressDegress = widget.goalCompleted * _progressAnimation.value; }); }); _radialProgressAnimationController.forward(); } @override void dispose() { super.dispose(); _radialProgressAnimationController.dispose(); } @override Widget build(BuildContext context) { return CustomPaint( child: Container( height: 200.0, width: 200.0, padding: EdgeInsets.symmetric(vertical: 40.0), child: AnimatedOpacity( opacity: progressDegress > 30.0 ? 1.0 : 0.0, duration: fadeInDuration, child: Column( children: <Widget>[ Text( 'HORAS', style: TextStyle(fontSize: 24.0, letterSpacing: 1.5), ), SizedBox( height: 4.0, ), Container( height: 5.0, width: 80.0, decoration: BoxDecoration( color: corPrincipal1, borderRadius: BorderRadius.all(Radius.circular(4.0))), ), SizedBox( height: 10.0, ), StreamBuilder<DateTime>( stream: AppModule.to.bloc<AppBloc>().dataStream, builder: (context, snapshot) { return Text( formatarHora.format(snapshot.data), style: TextStyle(fontSize: 40.0, fontWeight: FontWeight.bold), ); } ), Text( 'Jornada 8h/dia', style: TextStyle( fontSize: 14.0, color: Colors.blue, letterSpacing: 1.5), ), ], ), ), ), painter: RadialPainter(progressDegress), ); } } class RadialPainter extends CustomPainter { double progressInDegrees; RadialPainter(this.progressInDegrees); @override void paint(Canvas canvas, Size size) { Paint paint = Paint() ..color = Colors.black12 ..strokeCap = StrokeCap.round ..style = PaintingStyle.stroke ..strokeWidth = 10.0; Offset center = Offset(size.width / 2, size.height / 2); canvas.drawCircle(center, size.width / 2, paint); Paint progressPaint = Paint() ..shader = LinearGradient( colors: [Colors.blue, Colors.deepPurple, Colors.purpleAccent]) .createShader(Rect.fromCircle(center: center, radius: size.width / 2)) ..strokeCap = StrokeCap.round ..style = PaintingStyle.stroke ..strokeWidth = 15.0; canvas.drawArc( Rect.fromCircle(center: center, radius: size.width / 2), math.radians(-90), math.radians(progressInDegrees), false, progressPaint); } @override bool shouldRepaint(CustomPainter oldDelegate) { return true; } }