Commit c4f8977a authored by Collin Jackson's avatar Collin Jackson

Merge pull request #568 from collinjackson/playfair

Add support for charts to fitness app
parents b4e3f859 98d4c3af
......@@ -173,28 +173,59 @@ class FeedFragment extends StatefulComponent {
});
}
Widget buildChart() {
double startX;
double endX;
double startY;
double endY;
List<Point> dataSet = new List<Point>();
for (FitnessItem item in userData) {
if (item is Measurement) {
double x = item.when.millisecondsSinceEpoch.toDouble();
double y = item.weight;
if (startX == null)
startX = x;
endX = x;
if (startY == null || startY > y)
startY = y;
if (endY == null || endY < y)
endY = y;
dataSet.add(new Point(x, y));
}
}
playfair.ChartData data = new playfair.ChartData(
startX: startX,
startY: startY,
endX: endX,
endY: endY,
dataSet: dataSet
);
return new playfair.Chart(data: data);
}
Widget buildBody() {
TextStyle style = Theme.of(this).text.title;
if (userData.length == 0)
return new Material(
type: MaterialType.canvas,
child: new Flex(
[new Text("No data yet.\nAdd some!", style: style)],
justifyContent: FlexJustifyContent.center
)
);
switch (_fitnessMode) {
case FitnessMode.feed:
if (userData.length > 0)
return new FitnessItemList(
items: userData,
onDismissed: _handleItemDismissed
);
return new Material(
type: MaterialType.canvas,
child: new Flex(
[new Text("No data yet.\nAdd some!", style: style)],
justifyContent: FlexJustifyContent.center
)
return new FitnessItemList(
items: userData,
onDismissed: _handleItemDismissed
);
case FitnessMode.chart:
return new Material(
type: MaterialType.canvas,
child: new Flex([
new Text("Charts are coming soon!", style: style)
], justifyContent: FlexJustifyContent.center)
child: new Container(
padding: const EdgeDims.all(20.0),
child: buildChart()
)
);
}
}
......
......@@ -4,6 +4,7 @@
library fitness;
import 'package:playfair/playfair.dart' as playfair;
import 'package:sky/editing/input.dart';
import 'package:sky/painting/text_style.dart';
import 'package:sky/theme/colors.dart' as colors;
......
......@@ -2,6 +2,7 @@ name: fitness
dependencies:
sky: any
sky_tools: any
playfair: any
path: "^1.3.6"
dependency_overrides:
material_design_icons:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment