using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DialogHostAvalonia;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InABox.Avalonia.Components.TimeSelector;

public partial class TimeSelectorViewModel : BasePopupViewModel<TimeSpan?>
{
    [ObservableProperty]
    private TimeSpan? _time;

    [ObservableProperty]
    private Func<TimeSpan?>? _getTime;

    [RelayCommand]
    private void Cancel()
    {
        Close(null);
    }

    [RelayCommand]
    private void Clear()
    {
        Close(TimeSpan.MinValue);
    }

    [RelayCommand]
    private void Now()
    {
        Close(DateTime.Now.TimeOfDay);
    }

    [RelayCommand]
    private void Select()
    {
        Close(GetTime is null ? Time : GetTime());
    }
}
