mirror of
https://github.com/hamaluik/timecop.git
synced 2025-08-06 14:59:00 +08:00
made all charts reactive to filters
This commit is contained in:
@ -50,7 +50,6 @@ class _ReportsScreenState extends State<ReportsScreen> {
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
switch(index) {
|
||||
case 0: return ProjectBreakdown(
|
||||
context: context,
|
||||
startDate: _startDate,
|
||||
endDate: _endDate,
|
||||
);
|
||||
|
@ -25,19 +25,15 @@ import 'package:timecop/models/project.dart';
|
||||
import 'package:timecop/models/timer_entry.dart';
|
||||
|
||||
class ProjectBreakdown extends StatefulWidget {
|
||||
final BuildContext context;
|
||||
final DateTime startDate;
|
||||
final DateTime endDate;
|
||||
ProjectBreakdown({Key key, @required this.context, @required this.startDate, @required this.endDate}) : super(key: key);
|
||||
ProjectBreakdown({Key key, @required this.startDate, @required this.endDate}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ProjectBreakdownState createState() => _ProjectBreakdownState(context, startDate, endDate);
|
||||
_ProjectBreakdownState createState() => _ProjectBreakdownState();
|
||||
}
|
||||
|
||||
class _ProjectBreakdownState extends State<ProjectBreakdown> {
|
||||
final DateTime startDate;
|
||||
final DateTime endDate;
|
||||
final LinkedHashMap<int, double> _projectHours;
|
||||
int _touchedIndex = -1;
|
||||
|
||||
static LinkedHashMap<int, double> calculateData(BuildContext context, DateTime startDate, DateTime endDate) {
|
||||
@ -60,9 +56,6 @@ class _ProjectBreakdownState extends State<ProjectBreakdown> {
|
||||
return projectHours;
|
||||
}
|
||||
|
||||
_ProjectBreakdownState(BuildContext context, this.startDate, this.endDate, {Key key})
|
||||
: this._projectHours = calculateData(context, startDate, endDate);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -73,10 +66,10 @@ class _ProjectBreakdownState extends State<ProjectBreakdown> {
|
||||
Widget build(BuildContext context) {
|
||||
final ProjectsBloc projects = BlocProvider.of<ProjectsBloc>(context);
|
||||
|
||||
LinkedHashMap<int, double> _projectHours = calculateData(context, widget.startDate, widget.endDate);
|
||||
if(_projectHours.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
final double totalHours = _projectHours.values.fold(0.0, (double sum, double v) => sum + v);
|
||||
|
||||
return Padding(
|
||||
|
@ -34,14 +34,10 @@ class WeeklyTotals extends StatefulWidget {
|
||||
WeeklyTotals({Key key, @required this.context, @required this.startDate, @required this.endDate}) : super(key: key);
|
||||
|
||||
@override
|
||||
_WeeklyTotalsState createState() => _WeeklyTotalsState(context, startDate, endDate);
|
||||
_WeeklyTotalsState createState() => _WeeklyTotalsState();
|
||||
}
|
||||
|
||||
class _WeeklyTotalsState extends State<WeeklyTotals> {
|
||||
final DateTime startDate;
|
||||
final DateTime endDate;
|
||||
final LinkedHashMap<int, LinkedHashMap<int, double>> _projectWeeklyHours;
|
||||
|
||||
static DateFormat _dateFormat = DateFormat.MMMd();
|
||||
|
||||
static LinkedHashMap<int, LinkedHashMap<int, double>> calculateData(BuildContext context, DateTime startDate, DateTime endDate) {
|
||||
@ -70,20 +66,18 @@ class _WeeklyTotalsState extends State<WeeklyTotals> {
|
||||
|
||||
return projectWeeklyHours;
|
||||
}
|
||||
|
||||
_WeeklyTotalsState(BuildContext context, this.startDate, this.endDate, {Key key})
|
||||
: this._projectWeeklyHours = calculateData(context, startDate, endDate);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ProjectsBloc projects = BlocProvider.of<ProjectsBloc>(context);
|
||||
DateTime firstDate = startDate;
|
||||
DateTime firstDate = widget.startDate;
|
||||
if(firstDate == null) {
|
||||
final TimersBloc timers = BlocProvider.of<TimersBloc>(context);
|
||||
firstDate = timers.state.timers.map((timer) => timer.startTime).fold(DateTime.now(), (DateTime a, DateTime b) => a.isBefore(b) ? a : b);
|
||||
}
|
||||
firstDate = firstDate.startOfWeek();
|
||||
|
||||
LinkedHashMap<int, LinkedHashMap<int, double>> _projectWeeklyHours = calculateData(context, widget.startDate, widget.endDate);
|
||||
double maxY = _projectWeeklyHours
|
||||
.values
|
||||
.fold(0, (double omax, LinkedHashMap<int, double> weeks) =>
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: timecop
|
||||
description: A time tracking app that respects your privacy and gets the job done without getting too fancy.
|
||||
version: 1.3.1+17
|
||||
version: 1.3.1+18
|
||||
|
||||
environment:
|
||||
sdk: ">=2.6.0 <3.0.0"
|
||||
|
Reference in New Issue
Block a user