using System.Windows;
using PSLauncher.Core.Localization;
using PSLauncher.Models;

namespace PSLauncher.App.Views;

public partial class LauncherUpdateDialog : Window
{
    public bool UpdateRequested { get; private set; }

    public LauncherUpdateDialog(LauncherInfo info, string currentVersion)
    {
        InitializeComponent();
        VersionText.Text = $"v{currentVersion} → v{info.Version}";
        SizeText.Text = info.Download.SizeBytes > 0
            ? Strings.SizeLabel(Strings.FormatSize(info.Download.SizeBytes))
            : "";
    }

    private void OnUpdate(object sender, RoutedEventArgs e)
    {
        UpdateRequested = true;
        DialogResult = true;
        Close();
    }

    private void OnLater(object sender, RoutedEventArgs e)
    {
        UpdateRequested = false;
        DialogResult = false;
        Close();
    }
}
