|
|
@@ -20,7 +20,7 @@ class _WalkingState extends State<Walking> {
|
|
|
|
|
|
num distance = 0;
|
|
|
Position? lastPosition;
|
|
|
- int points = 0;
|
|
|
+ num points = 0;
|
|
|
num totalPoints = 0;
|
|
|
num totalDistance = 0;
|
|
|
|
|
|
@@ -43,7 +43,8 @@ class _WalkingState extends State<Walking> {
|
|
|
|
|
|
void _updatePoints(num newPoints) {
|
|
|
setState(() {
|
|
|
- totalPoints = newPoints;
|
|
|
+ totalPoints += newPoints;
|
|
|
+ points += newPoints;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -64,15 +65,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;
|
|
|
}
|
|
|
@@ -91,7 +92,7 @@ class _WalkingState extends State<Walking> {
|
|
|
),
|
|
|
const SizedBox(height: 32),
|
|
|
Text(
|
|
|
- "Earned points since start:\n$totalPoints pts",
|
|
|
+ "Earned points since start:\n${totalPoints.floor()} pts",
|
|
|
textAlign: TextAlign.center,
|
|
|
style: const TextStyle(fontSize: 24),
|
|
|
),
|