using AvaloniaEdit.Document;

using CommunityToolkit.Mvvm.Input;

using Dock.Model.Controls;

using InkForge.Desktop.Models;
using InkForge.Desktop.ViewModels.Documents;

namespace InkForge.Desktop.Managers;

public partial class DocumentManager
{
	private readonly InkForgeFactory _factory;

	public IDocumentDock Dock { get; }

	public DocumentManager(NoteStore noteStore, InkForgeFactory factory)
	{
		_factory = factory;
		Dock = factory.CreateDocumentDock();
		Dock.IsCollapsable = false;
		Dock.CanCreateDocument = true;
		Dock.CreateDocument = CreateDocumentCommand;
	}

	[RelayCommand]
	private void OnCreateDocument()
	{
		NoteEditDocumentViewModel editViewModel = new(new()
		{
			Name = "Untitled Note",
		}, new());
		_factory.AddDockable(Dock, editViewModel);
		_factory.SetActiveDockable(editViewModel);
		_factory.SetFocusedDockable(Dock, editViewModel);
	}
}
