-
Notifications
You must be signed in to change notification settings - Fork 0
/
daily.dart
105 lines (102 loc) · 4.17 KB
/
daily.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import "package:flutter/material.dart";
import 'package:flutter_redux/flutter_redux.dart';
import 'package:percent_indicator/percent_indicator.dart';
//my code
import "package:waterledger/buymecoffee.dart";
import "package:waterledger/models/appState.dart";
import 'package:waterledger/viewModels/dailyViewModel.dart';
import 'package:waterledger/dialogs/editEntry.dart';
class DailyWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _DailyWidgetState();
}
}
class _DailyWidgetState extends State<DailyWidget> {
@override
Widget build(BuildContext context) {
return ListView(children: [
Card(
child: Column(
children: <Widget>[
ListTile(
title: Text("Progress"),
subtitle: StoreConnector<AppState, DailyViewModel>(
converter: (store) => DailyViewModel.fromStore(store),
builder: (context, viewModel) => Text("You are " +
viewModel.progress.toStringAsPrecision(3) +
" percent to your goal."),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 250,
height: 250,
child: StoreConnector<AppState, DailyViewModel>(
converter: (store) => DailyViewModel.fromStore(store),
builder: (context, viewModel) =>
new CircularPercentIndicator(
radius: 175.0,
lineWidth: 30.0,
percent: (viewModel.progress / 100).clamp(0.0, 1.0),
center: new Text(
viewModel.progress.toStringAsPrecision(3) +
"%"),
progressColor: Theme.of(context).primaryColor,
))),
],
),
],
)),
Card(
child: Container(
padding: const EdgeInsets.all(8.0),
child: StoreConnector<AppState, DailyViewModel>(
converter: (store) => DailyViewModel.fromStore(store),
builder: (context, viewModel) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
viewModel.entryMessage,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 22),
)
]..addAll(viewModel.entries
.map(
(entry) => ListTile(
title: Text(entry.amount.toStringAsFixed(1) +
" " +
viewModel.unitsString),
subtitle: Text(TimeOfDay.fromDateTime(entry.date)
.format(context)),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
icon: Icon(Icons.delete),
onPressed: () =>
viewModel.deleteCallback(entry),
),
IconButton(
icon: Icon(Icons.edit),
onPressed: () => Navigator.of(context).push(
new MaterialPageRoute(
builder: (context) {
return EditEntryDialog(entry);
},
fullscreenDialog: true),
),
),
],
)),
)
.toList()),
)),
),
),
BMCWidget(),
]);
}
}