From e31ace84fbd37623b3863d8959818d7d70129c87 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Dec 2019 23:23:38 -0500 Subject: added app routing and cook page front end --- .../src/app/cook-page/cook-page.component.ts | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 recipeBuddy/src/app/cook-page/cook-page.component.ts (limited to 'recipeBuddy/src/app/cook-page/cook-page.component.ts') diff --git a/recipeBuddy/src/app/cook-page/cook-page.component.ts b/recipeBuddy/src/app/cook-page/cook-page.component.ts new file mode 100644 index 0000000..51a4c67 --- /dev/null +++ b/recipeBuddy/src/app/cook-page/cook-page.component.ts @@ -0,0 +1,59 @@ +import {Component, OnInit} from '@angular/core'; + +/** + * @title Card with multiple sections + */ +@Component({ + selector: 'app-cook-page', + templateUrl: './cook-page.component.html', + styleUrls: ['./cook-page.component.css'], +}) +export class CookPageComponent implements OnInit { + step: number; + instructions: string[] = ["Cut the bread", "Toast the bread", "Warm the butter", "Apply butter to bread", "Enjoy"]; + timers: number[] = [5,60,30,0,0]; + previousStep: string; + currentStep: string; + nextStep: string; + timeLeft: number; + + timerInterval; + + ngOnInit() { + this.step = 1; + this.previousStep = ""; + this.currentStep = this.instructions[this.step-1]; + this.nextStep = this.instructions[this.step]; + this.timeLeft = this.timers[this.step-1]; + } + + next(): void { + clearInterval(this.timerInterval); + this.step++; + this.previousStep = this.instructions[this.step-2]; + this.currentStep = this.instructions[this.step-1]; + this.nextStep = this.instructions[this.step]; + this.timeLeft = this.timers[this.step-1]; + } + + previous(): void { + clearInterval(this.timerInterval); + this.step--; + this.previousStep = this.instructions[this.step-2]; + this.currentStep = this.instructions[this.step-1]; + this.nextStep = this.instructions[this.step]; + this.timeLeft = this.timers[this.step-1]; + } + + startTimer(): void { + this.timerInterval = setInterval(() => { + if(this.timeLeft > 0) { + this.timeLeft --; + } + else { + clearInterval(this.timerInterval); + } + }, 1000) + } +} + -- cgit v1.1