using System.ComponentModel;
using System.Text.Json.Serialization;
using Luski.Classes.Attribs;
using Luski.Enums.Strings;
using Luski.GUI.MainScreen.UI.LuskiSettings.Pages.AdvancedSettings;

namespace Luski.Classes;

public class UpdaterSettings
{
    [JsonInclude]
    [Shared.GlobalAttributes.DisplayName("Self Contained")]
    [Description("This tells the updater to download the self contained version of the app.")]
    [JsonPropertyName("self_contained")]
    [SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
    public bool SelfContained { get; set; } = false;

    [JsonInclude]
    [JsonPropertyName("platform")]
    [SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
    public string Platform { get; set; } = "linux-x64";
    
    [JsonInclude]
    [Description("If the app can check for updates and an update is available, then the app will start the update process automatically.")]
    [Shared.GlobalAttributes.DisplayName("Auto Update")]
    [JsonPropertyName("auto_update")]
    [SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
    public bool AutoUpdate { get; set; } = false;
    
    [JsonInclude]
    [Description("This will allow the client to check for update during the launch process.")]
    [Shared.GlobalAttributes.DisplayName("Check For Updates")]
    [JsonPropertyName("update_check")]
    [SettingInfo(SettingGroup.Advanced, SettingsPage.Updater)]
    public bool AutoUpdateCheck { get; set; } = true;
}

[JsonSerializable(typeof(UpdaterSettings))]
[JsonSourceGenerationOptions(
    GenerationMode = JsonSourceGenerationMode.Default,
    PropertyNamingPolicy = JsonKnownNamingPolicy.Unspecified,
    WriteIndented = true,
    DefaultIgnoreCondition = JsonIgnoreCondition.Never)]
internal partial class UpdaterSettingsContext : JsonSerializerContext;
