init release

This commit is contained in:
2024-11-17 11:56:55 +01:00
parent 435753880c
commit 21cde45999
18 changed files with 1023 additions and 157 deletions

View File

@@ -0,0 +1,62 @@
// src/app/training.component.ts
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Deck, DeckImage } from '../deck.service';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-training',
templateUrl: './training.component.html',
standalone: true,
imports: [CommonModule]
})
export class TrainingComponent {
@Input() deck!: Deck;
@Output() close = new EventEmitter<void>();
currentIndex: number = 0;
knownCount: number = 0;
unknownCount: number = 0;
showTextFlag: boolean = false;
get currentImage(): DeckImage | null {
if (this.currentIndex < this.deck.images.length) {
return this.deck.images[this.currentIndex];
}
return null;
}
get progress(): string {
return `Fortschritt: ${this.currentIndex} / ${this.deck.images.length}`;
}
showText(): void {
this.showTextFlag = true;
}
markKnown(): void {
this.knownCount++;
this.nextImage();
}
markUnknown(): void {
this.unknownCount++;
this.nextImage();
}
nextImage(): void {
this.currentIndex++;
this.showTextFlag = false;
if (this.currentIndex >= this.deck.images.length) {
this.endTraining();
}
}
endTraining(): void {
alert(`Training beendet!\nGewusst: ${this.knownCount}\nNicht gewusst: ${this.unknownCount}`);
this.close.emit();
}
closeTraining(): void {
this.close.emit();
}
}