add wheel & colors change & delete items fix & add item animation

This commit is contained in:
p-wojt
2022-01-01 19:48:12 +01:00
parent 9649216920
commit 0f955e3ce2
14 changed files with 563 additions and 300 deletions

View File

@@ -1,39 +0,0 @@
export class Counter {
static value: number;
min: number;
max: number;
constructor(min: number, max: number){
Counter.value = min;
this.min = min;
this.max = max;
}
increment(){
if(!this.isMax()){
Counter.value++;
return true;
}
return false;
}
decrement(){
if(!this.isMin()){
Counter.value--;
return true;
}
return false;
}
clear(){
Counter.value = 0;
}
private isMax(){
return this.max === Counter.value;
}
private isMin(){
return this.min === Counter.value;
}
}

32
src/model/item-list.ts Normal file
View File

@@ -0,0 +1,32 @@
import { Item } from "./item";
import { List } from "./list";
export class ItemList implements List<Item> {
items: Item[];
maximumSize: number;
constructor(maxSize: number){
this.items = [];
this.maximumSize = maxSize;
}
add(item: Item){
if(this.items.length < this.maximumSize)
this.items.push(item);
}
removeById(id: number){
const toRemove = this.items.find(e => e.id === id);
if(toRemove){
this.remove(toRemove);
}
}
remove(item: Item){
this.items.splice(this.items.indexOf(item), 1);
}
clear(){
this.items = [];
}
}

View File

@@ -1,11 +1,11 @@
export class Item {
id: number;
name: string;
color: string;
id: number;
name: string;
color: string;
constructor(id: number, name: string, color: string){
this.id = id;
this.name = name;
this.color = color;
}
}
constructor(id: number, name: string, color: string) {
this.id = id;
this.name = name;
this.color = color;
}
}

5
src/model/list.ts Normal file
View File

@@ -0,0 +1,5 @@
export interface List<T> {
items: T[];
add(item: T): void;
}