/*
 * Mirai. Copyright (C) 2024 Vyn
 * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
 * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
 */

#pragma once

#include "../AddSourceWindow/AddSourceWindow.h"
#include "../EditEventWindow/EditEventWindow.h"
#include "../EditSourceWindow/EditSourceWindow.h"
#include "../SettingsWindow/SettingsWindow.h"
#include "mirai-core/Mirai.h"
#include "mirai-core/View.h"
#include "slint.h"
#include "ui.h"

class AppWindow
{

  public:
	AppWindow(mirai::Mirai *mirai);

	void run();

	void reloadSources();
	void reloadTasks();
	void refreshModels();

  private:
	void setupCallbacks();
	const ui::AppWindowModels &models();
	const ui::AppWindowActions &actions();

	std::shared_ptr<slint::VectorModel<ui::Source>> sources_;
	std::shared_ptr<slint::VectorModel<ui::Day>> days_;
	std::shared_ptr<slint::VectorModel<ui::CalendarDay>> calendar_;
	std::shared_ptr<slint::VectorModel<ui::TaskData>> unscheduledTasks_;

	slint::ComponentHandle<ui::AppWindow> mainWindow_ = ui::AppWindow::create();
	SettingsWindow settingsWindow_;
	AddSourceWindow addSourceWindow_;
	EditSourceWindow editSourceWindow_;
	EditEventWindow editEventWindow_;

	mirai::Mirai *miraiInstance_;
	mirai::View view_;
};
