fixing problems with previous card and next card
This commit is contained in:
@@ -20,4 +20,8 @@ img {
|
|||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert {
|
||||||
|
margin-top: 24px;
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
Card Workout!
|
Card Workout
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -26,12 +26,16 @@
|
|||||||
<div class="alert alert-success" role="alert">
|
<div class="alert alert-success" role="alert">
|
||||||
Current Exercise
|
Current Exercise
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="exercise && reps" class="card sticky-card">
|
<div *ngIf="exercise && reps && !rest" class="card sticky-card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">{{exercise}}</h5>
|
<h5 class="card-title">{{exercise}}</h5>
|
||||||
<p class="card-text">{{reps}} reps</p>
|
<p class="card-text">{{reps}} reps</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="rest">
|
||||||
|
<h5 class="card-title">Rest</h5>
|
||||||
|
<p class="card-text">2 minutes</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Current card -->
|
<!-- Current card -->
|
||||||
<div class="col-md-4 col-sm-12 center">
|
<div class="col-md-4 col-sm-12 center">
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ export class MainComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public displayExercise() {
|
public displayExercise() {
|
||||||
const currentCard = this.workoutDeck[this.currentCardNumber]
|
const currentCard = this.workoutDeck[this.currentCardNumber];
|
||||||
console.log(currentCard);
|
|
||||||
if (currentCard.value !== 1) {
|
if (currentCard.value !== 1) {
|
||||||
this.rest = undefined
|
this.rest = undefined
|
||||||
this.reps = Number(currentCard.value)+10;
|
this.reps = Number(currentCard.value)+10;
|
||||||
@@ -118,14 +117,34 @@ export class MainComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public incrementCardCounter() {
|
public incrementCardCounter() {
|
||||||
this.displayExercise();
|
|
||||||
this.currentCardNumber += 1;
|
this.currentCardNumber += 1;
|
||||||
this.previousCardNumber += 1;
|
this.previousCardNumber += 1;
|
||||||
|
this.displayExercise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public decrementCardCounter() {
|
public decrementCardCounter() {
|
||||||
this.displayExercise()
|
|
||||||
this.currentCardNumber -= 1;
|
this.currentCardNumber -= 1;
|
||||||
this.previousCardNumber -= 1;
|
this.previousCardNumber -= 1;
|
||||||
|
const currentCard = this.workoutDeck[this.currentCardNumber];
|
||||||
|
const nextCard = this.workoutDeck[this.currentCardNumber+1];
|
||||||
|
if (currentCard.suit === 'c') {
|
||||||
|
this.cCounter -= 1;
|
||||||
|
} else if (currentCard.suit === 'd') {
|
||||||
|
this.dCounter -= 1;
|
||||||
|
} else if (currentCard.suit === 'h') {
|
||||||
|
this.hCounter -= 1;
|
||||||
|
} else if (currentCard.suit === 's') {
|
||||||
|
this.sCounter -= 1;
|
||||||
|
}
|
||||||
|
if (nextCard.suit === 'c') {
|
||||||
|
this.cCounter -= 1;
|
||||||
|
} else if (nextCard.suit === 'd') {
|
||||||
|
this.dCounter -= 1;
|
||||||
|
} else if (nextCard.suit === 'h') {
|
||||||
|
this.hCounter -= 1;
|
||||||
|
} else if (nextCard.suit === 's') {
|
||||||
|
this.sCounter -= 1;
|
||||||
|
}
|
||||||
|
this.displayExercise()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user