import type { IColors } from "react-native-week-schedule-1";
import { DEFAULT_COLORS } from "../DEFAULT_COLORS";
import { scaleHorizontal, size } from "./Utils";

interface IGrid {
    cellWight: number;
    cellHeight: number;
    hours: string[];
    weekDays: string[];
    colors: IColors;
};

class Grid implements IGrid {
    private _diff = scaleHorizontal(13);
    private _offset = scaleHorizontal(5);
    private _numberOfColumns = 8;
    private _hours = ["12 am", "1 am", "2 am", "3 am", "4 am", "5 am", "6 am", "7 am", "8 am", "9 am", "10 am", "11 am", "12 pm", "1 pm", "2 pm", "3 pm", "4 pm", "5 pm", "6 pm", "7 pm", "8 pm", "9 pm", "10 pm", "11 pm"];
    private _weekDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    private _colors = DEFAULT_COLORS;

    public get cellWight() {
        return (size.width / this._numberOfColumns) - this._offset
    }

    public get cellHeight() {
        return (size.width / this._numberOfColumns) + this._diff - this._offset;
    }
    public get hours() {
        return this._hours ?? [];
    }

    public set hours(value: string[]) {
        this._hours = value;
    }

    public get weekDays() {
        return this._weekDays;
    }

    public set weekDays(value: string[]) {
        this._weekDays = value ?? [];
    }

    public set diff(value: number) {
        this._diff = value;
    }

    public set offset(value: number) {
        this._offset = value;
    }

    public get colors() {
        return this._colors
    }

    public updateColors(value: { [key in keyof IColors]?: string }) {
        this._colors = { ...DEFAULT_COLORS, ...value };
    }


};

export const grid = new Grid();