-
Notifications
You must be signed in to change notification settings - Fork 0
/
historyChartManager.dart
81 lines (77 loc) · 2.79 KB
/
historyChartManager.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import "package:flutter/material.dart";
import 'package:waterledger/constants/constants.dart';
import 'package:flutter_redux/flutter_redux.dart';
//My Code
import "package:waterledger/historyChart.dart";
import 'package:waterledger/models/appState.dart';
import 'package:waterledger/viewModels/historyChartViewModel.dart';
class HistoryChartWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _HistoryChartState();
}
}
class _HistoryChartState extends State<HistoryChartWidget> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Card(
child: Column(
children: <Widget>[
ListTile(
title: Text("Amount of water consumed per day."),
subtitle: StoreConnector<AppState, HistoryChartViewModel>(
converter: (store) => HistoryChartViewModel.fromStore(store),
builder: (context, viewModel) =>
Text("(" + viewModel.timeSpanString + ")")),
),
Container(
width: 250,
height: 250,
child: StoreConnector<AppState, HistoryChartViewModel>(
converter: (store) => HistoryChartViewModel.fromStore(store),
builder: (context, viewModel) =>
TimeSeriesBar(viewModel.dataPoints)),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
StoreConnector<AppState, HistoryChartViewModel>(
converter: (store) => HistoryChartViewModel.fromStore(store),
builder: (context, viewModel) => DropdownButton(
value: viewModel.timeSpan,
items: [
DropdownMenuItem(
child: Text("Last 7 days"),
value: TimeSpan.WEEK,
),
DropdownMenuItem(
child: Text("Last 30 days"),
value: TimeSpan.MONTH,
),
DropdownMenuItem(
child: Text("Last 90 days"),
value: TimeSpan.QUARTER,
),
DropdownMenuItem(
child: Text("Last Year"),
value: TimeSpan.YEAR,
),
DropdownMenuItem(
child: Text("Since Beginning"),
value: TimeSpan.FOREVER,
),
],
onChanged: (value) => viewModel.onTimeSpanChange(value),
),
)
],
)
],
),
);
}
}