Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d77d7b48
Commit
d77d7b48
authored
Aug 20, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add goal weight indicator line to fitness chart
parent
1217f3b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
feed.dart
examples/fitness/lib/feed.dart
+13
-6
main.dart
examples/fitness/lib/main.dart
+3
-2
No files found.
examples/fitness/lib/feed.dart
View file @
d77d7b48
...
...
@@ -61,7 +61,7 @@ class FeedFragment extends StatefulComponent {
FeedFragment
({
this
.
navigator
,
this
.
userData
,
this
.
onItemCreated
,
this
.
onItemDeleted
});
Navigator
navigator
;
List
<
FitnessItem
>
userData
;
UserData
userData
;
FitnessItemHandler
onItemCreated
;
FitnessItemHandler
onItemDeleted
;
...
...
@@ -179,12 +179,13 @@ class FeedFragment extends StatefulComponent {
double
startY
;
double
endY
;
List
<
Point
>
dataSet
=
new
List
<
Point
>();
for
(
FitnessItem
item
in
userData
)
{
for
(
FitnessItem
item
in
userData
.
items
)
{
if
(
item
is
Measurement
)
{
double
x
=
item
.
when
.
millisecondsSinceEpoch
.
toDouble
();
double
y
=
item
.
weight
;
if
(
startX
==
null
)
if
(
startX
==
null
||
startX
>
x
)
startX
=
x
;
if
(
endX
==
null
||
endX
<
x
)
endX
=
x
;
if
(
startY
==
null
||
startY
>
y
)
startY
=
y
;
...
...
@@ -193,6 +194,10 @@ class FeedFragment extends StatefulComponent {
dataSet
.
add
(
new
Point
(
x
,
y
));
}
}
if
(
userData
.
goalWeight
>
0.0
)
{
startY
=
math
.
min
(
startY
,
userData
.
goalWeight
);
endY
=
math
.
max
(
endY
,
userData
.
goalWeight
);
}
playfair
.
ChartData
data
=
new
playfair
.
ChartData
(
startX:
startX
,
startY:
startY
,
...
...
@@ -200,14 +205,16 @@ class FeedFragment extends StatefulComponent {
endY:
endY
,
dataSet:
dataSet
,
numHorizontalGridlines:
5
,
roundToPlaces:
1
roundToPlaces:
1
,
indicatorLine:
userData
.
goalWeight
,
indicatorText:
"GOAL WEIGHT"
);
return
new
playfair
.
Chart
(
data:
data
);
}
Widget
buildBody
()
{
TextStyle
style
=
Theme
.
of
(
this
).
text
.
title
;
if
(
userData
.
length
==
0
)
if
(
userData
.
items
.
length
==
0
)
return
new
Material
(
type:
MaterialType
.
canvas
,
child:
new
Flex
(
...
...
@@ -218,7 +225,7 @@ class FeedFragment extends StatefulComponent {
switch
(
_fitnessMode
)
{
case
FitnessMode
.
feed
:
return
new
FitnessItemList
(
items:
userData
,
items:
userData
.
items
.
reversed
.
toList
()
,
onDismissed:
_handleItemDismissed
);
case
FitnessMode
.
chart
:
...
...
examples/fitness/lib/main.dart
View file @
d77d7b48
...
...
@@ -12,6 +12,7 @@ import 'package:sky/widgets.dart';
import
'user_data.dart'
;
import
'date_utils.dart'
;
import
'dart:async'
;
import
'dart:math'
as
math
;
part
'feed.dart'
;
part
'fitness_item.dart'
;
...
...
@@ -46,7 +47,7 @@ class UserDataImpl extends UserData {
List
<
FitnessItem
>
get
items
=>
_items
;
void
sort
()
{
_items
.
sort
((
a
,
b
)
=>
-
a
.
when
.
compareTo
(
b
.
when
));
_items
.
sort
((
a
,
b
)
=>
a
.
when
.
compareTo
(
b
.
when
));
}
void
add
(
FitnessItem
item
)
{
...
...
@@ -100,7 +101,7 @@ class FitnessApp extends App {
name:
'/'
,
builder:
(
navigator
,
route
)
=>
new
FeedFragment
(
navigator:
navigator
,
userData:
_userData
.
items
,
userData:
_userData
,
onItemCreated:
_handleItemCreated
,
onItemDeleted:
_handleItemDeleted
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment