|
|
@@ -20,8 +20,8 @@ class _WalkingState extends State<Walking> {
|
|
|
|
|
|
num distance = 0;
|
|
|
Position? lastPosition;
|
|
|
- int points = 0;
|
|
|
- num totalPoints = 0;
|
|
|
+ num points = 0;
|
|
|
+ int totalPoints = 0;
|
|
|
num totalDistance = 0;
|
|
|
|
|
|
@override
|
|
|
@@ -43,7 +43,9 @@ class _WalkingState extends State<Walking> {
|
|
|
|
|
|
void _updatePoints(num newPoints) {
|
|
|
setState(() {
|
|
|
- totalPoints = newPoints;
|
|
|
+ final currentPoints = points + newPoints;
|
|
|
+ totalPoints += currentPoints.floor();
|
|
|
+ points += currentPoints;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -64,15 +66,15 @@ class _WalkingState extends State<Walking> {
|
|
|
}
|
|
|
}
|
|
|
if (distance > 0 && activity.type == ActivityType.WALKING) {
|
|
|
- points += (distance / 10).floor();
|
|
|
- _updatePoints(points);
|
|
|
+ _updatePoints(distance / 10);
|
|
|
} else if (distance > 0 && activity.type == ActivityType.RUNNING) {
|
|
|
- points += (distance / 8).floor();
|
|
|
- _updatePoints(points);
|
|
|
+ _updatePoints(distance / 8);
|
|
|
}
|
|
|
- if (activity.type != ActivityType.WALKING && activity.type != ActivityType.RUNNING && points > 0) {
|
|
|
- WalkingServices.addScore(Score(points: points, distance: 0));
|
|
|
- points = 0;
|
|
|
+ if (activity.type != ActivityType.WALKING && activity.type != ActivityType.RUNNING && points.floor() > 0) {
|
|
|
+ WalkingServices.addScore(Score(points: points.floor(), distance: 0));
|
|
|
+ setState(() {
|
|
|
+ points = 0;
|
|
|
+ });
|
|
|
}
|
|
|
lastPosition = position;
|
|
|
}
|