using Avalonia.Collections;
using Avalonia.Controls;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using PSCHelpdesk.Services;
using PSCHelpdesk.Shared.ViewModels;

namespace PSCHelpdesk.ViewModels;

public class PluginListViewModel : ViewModelBase, IViewModelBase
{
    public RelayCommand<object> LoadAllPluginsCommand { get; set; }
    public RelayCommand<object> UnLoadAllPluginsCommand { get; set; }
    public RelayCommand<object> LoadPluginCommand { get; set; }
    public AvaloniaList<string> Plugins { get; set; }
    public UserControl CurrentControl { get; set; }
        
    public PluginListViewModel()
    {
        Title = "Plugin List";
        var pluginService = Ioc.Default.GetService<PluginManager>();
        this.Plugins = new AvaloniaList<string>();
            
        LoadPluginCommand = new RelayCommand<object>(LoadPlugin);
        LoadAllPluginsCommand = new RelayCommand<object>(LoadAllPlugins);
        UnLoadAllPluginsCommand = new RelayCommand<object>(UnLoadAllPlugins);
            
        foreach (var plugin in pluginService.GetPlugins())
        {
            this.Plugins.Add(plugin.Key);
        }
    }
        
    async void LoadPlugin(object parameter)
    {
        
    }

    async void LoadAllPlugins(object parameter)
    {
        foreach (var plugin in Plugins)
        {
            
        }
    }

    async void UnLoadAllPlugins(object parameter)
    {
            
    }
        
}