using System;
using System.Threading.Tasks;
using Windows.Storage;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Personalization;
using Wino.Services;

namespace Wino.Core.WinUI.Models.Personalization;

/// <summary>
/// Custom themes that are generated by users.
/// </summary>
public class CustomAppTheme : AppThemeBase
{
    public CustomAppTheme(CustomThemeMetadata metadata) : base(metadata.Name, metadata.Id)
    {
        AccentColor = metadata.AccentColorHex;
    }

    public override AppThemeType AppThemeType => AppThemeType.Custom;

    public override string GetBackgroundPreviewImagePath()
        => $"ms-appdata:///local/{NewThemeService.CustomThemeFolderName}/{Id}_preview.jpg";

    public override async Task<string> GetThemeResourceDictionaryContentAsync()
    {
        var customAppThemeFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Wino.Core.WinUI/AppThemes/Custom.xaml"));
        return await FileIO.ReadTextAsync(customAppThemeFile);
    }
}
