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
62e67957
Commit
62e67957
authored
Aug 20, 2015
by
Collin Jackson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #717 from collinjackson/indicator
Add goal weight indicator line to fitness chart
parents
66c292c8
d77d7b48
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 @
62e67957
...
@@ -61,7 +61,7 @@ class FeedFragment extends StatefulComponent {
...
@@ -61,7 +61,7 @@ class FeedFragment extends StatefulComponent {
FeedFragment
({
this
.
navigator
,
this
.
userData
,
this
.
onItemCreated
,
this
.
onItemDeleted
});
FeedFragment
({
this
.
navigator
,
this
.
userData
,
this
.
onItemCreated
,
this
.
onItemDeleted
});
Navigator
navigator
;
Navigator
navigator
;
List
<
FitnessItem
>
userData
;
UserData
userData
;
FitnessItemHandler
onItemCreated
;
FitnessItemHandler
onItemCreated
;
FitnessItemHandler
onItemDeleted
;
FitnessItemHandler
onItemDeleted
;
...
@@ -179,12 +179,13 @@ class FeedFragment extends StatefulComponent {
...
@@ -179,12 +179,13 @@ class FeedFragment extends StatefulComponent {
double
startY
;
double
startY
;
double
endY
;
double
endY
;
List
<
Point
>
dataSet
=
new
List
<
Point
>();
List
<
Point
>
dataSet
=
new
List
<
Point
>();
for
(
FitnessItem
item
in
userData
)
{
for
(
FitnessItem
item
in
userData
.
items
)
{
if
(
item
is
Measurement
)
{
if
(
item
is
Measurement
)
{
double
x
=
item
.
when
.
millisecondsSinceEpoch
.
toDouble
();
double
x
=
item
.
when
.
millisecondsSinceEpoch
.
toDouble
();
double
y
=
item
.
weight
;
double
y
=
item
.
weight
;
if
(
startX
==
null
)
if
(
startX
==
null
||
startX
>
x
)
startX
=
x
;
startX
=
x
;
if
(
endX
==
null
||
endX
<
x
)
endX
=
x
;
endX
=
x
;
if
(
startY
==
null
||
startY
>
y
)
if
(
startY
==
null
||
startY
>
y
)
startY
=
y
;
startY
=
y
;
...
@@ -193,6 +194,10 @@ class FeedFragment extends StatefulComponent {
...
@@ -193,6 +194,10 @@ class FeedFragment extends StatefulComponent {
dataSet
.
add
(
new
Point
(
x
,
y
));
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
(
playfair
.
ChartData
data
=
new
playfair
.
ChartData
(
startX:
startX
,
startX:
startX
,
startY:
startY
,
startY:
startY
,
...
@@ -200,14 +205,16 @@ class FeedFragment extends StatefulComponent {
...
@@ -200,14 +205,16 @@ class FeedFragment extends StatefulComponent {
endY:
endY
,
endY:
endY
,
dataSet:
dataSet
,
dataSet:
dataSet
,
numHorizontalGridlines:
5
,
numHorizontalGridlines:
5
,
roundToPlaces:
1
roundToPlaces:
1
,
indicatorLine:
userData
.
goalWeight
,
indicatorText:
"GOAL WEIGHT"
);
);
return
new
playfair
.
Chart
(
data:
data
);
return
new
playfair
.
Chart
(
data:
data
);
}
}
Widget
buildBody
()
{
Widget
buildBody
()
{
TextStyle
style
=
Theme
.
of
(
this
).
text
.
title
;
TextStyle
style
=
Theme
.
of
(
this
).
text
.
title
;
if
(
userData
.
length
==
0
)
if
(
userData
.
items
.
length
==
0
)
return
new
Material
(
return
new
Material
(
type:
MaterialType
.
canvas
,
type:
MaterialType
.
canvas
,
child:
new
Flex
(
child:
new
Flex
(
...
@@ -218,7 +225,7 @@ class FeedFragment extends StatefulComponent {
...
@@ -218,7 +225,7 @@ class FeedFragment extends StatefulComponent {
switch
(
_fitnessMode
)
{
switch
(
_fitnessMode
)
{
case
FitnessMode
.
feed
:
case
FitnessMode
.
feed
:
return
new
FitnessItemList
(
return
new
FitnessItemList
(
items:
userData
,
items:
userData
.
items
.
reversed
.
toList
()
,
onDismissed:
_handleItemDismissed
onDismissed:
_handleItemDismissed
);
);
case
FitnessMode
.
chart
:
case
FitnessMode
.
chart
:
...
...
examples/fitness/lib/main.dart
View file @
62e67957
...
@@ -12,6 +12,7 @@ import 'package:sky/widgets.dart';
...
@@ -12,6 +12,7 @@ import 'package:sky/widgets.dart';
import
'user_data.dart'
;
import
'user_data.dart'
;
import
'date_utils.dart'
;
import
'date_utils.dart'
;
import
'dart:async'
;
import
'dart:async'
;
import
'dart:math'
as
math
;
part
'feed.dart'
;
part
'feed.dart'
;
part
'fitness_item.dart'
;
part
'fitness_item.dart'
;
...
@@ -46,7 +47,7 @@ class UserDataImpl extends UserData {
...
@@ -46,7 +47,7 @@ class UserDataImpl extends UserData {
List
<
FitnessItem
>
get
items
=>
_items
;
List
<
FitnessItem
>
get
items
=>
_items
;
void
sort
()
{
void
sort
()
{
_items
.
sort
((
a
,
b
)
=>
-
a
.
when
.
compareTo
(
b
.
when
));
_items
.
sort
((
a
,
b
)
=>
a
.
when
.
compareTo
(
b
.
when
));
}
}
void
add
(
FitnessItem
item
)
{
void
add
(
FitnessItem
item
)
{
...
@@ -100,7 +101,7 @@ class FitnessApp extends App {
...
@@ -100,7 +101,7 @@ class FitnessApp extends App {
name:
'/'
,
name:
'/'
,
builder:
(
navigator
,
route
)
=>
new
FeedFragment
(
builder:
(
navigator
,
route
)
=>
new
FeedFragment
(
navigator:
navigator
,
navigator:
navigator
,
userData:
_userData
.
items
,
userData:
_userData
,
onItemCreated:
_handleItemCreated
,
onItemCreated:
_handleItemCreated
,
onItemDeleted:
_handleItemDeleted
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