import { Date, Time } from "std-widgets.slint";



export struct TaskData {
	sourceId: int,
	id: int,
    title: string,
    checked: bool,
	tags: [string],
}

export struct Event {
	sourceId: int,
	id: int,
	title: string,
	startsAt: Time,
	endsAt: Time,
	tasks: [TaskData],
}

export struct Day {
	sourceId: int,
	id: int,
	date: Date,
	events: [Event],
	tasks: [TaskData],
	isLate: bool,
	isToday: bool
}

struct OpenNewTaskFormParams {
	eventSourceId: int,
	eventId: int,
}

export global Backend  {
    in-out property<[string]> sources;
	in-out property<[string]> tags;
	in-out property<[Day]> visible_tasks;

	callback task_clicked(int, int);
	callback source_clicked(int);
	callback tag_clicked(int);
	
	callback open_new_task_form(OpenNewTaskFormParams);
	callback open_edit_task_form(int, int);
	callback open_new_event_form();
	callback open_edit_event_form(int, int);
	callback toggle_show_completed_tasks();
	callback delete_task_clicked(int, int);
	callback delete_event_clicked(int, int);

	pure callback formatDate(Date) -> string;
}
