Files

31 lines
1009 B
C#
Raw Permalink Normal View History

2024-04-18 01:44:37 +02:00
using System;
using System.Threading.Tasks;
using Windows.Storage;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Personalization;
using Wino.Services;
2025-02-16 11:54:23 +01:00
namespace Wino.Core.UWP.Models.Personalization;
/// <summary>
/// Custom themes that are generated by users.
/// </summary>
public class CustomAppTheme : AppThemeBase
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
public CustomAppTheme(CustomThemeMetadata metadata) : base(metadata.Name, metadata.Id)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
AccentColor = metadata.AccentColorHex;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override AppThemeType AppThemeType => AppThemeType.Custom;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override string GetBackgroundPreviewImagePath()
=> $"ms-appdata:///local/{ThemeService.CustomThemeFolderName}/{Id}_preview.jpg";
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override async Task<string> GetThemeResourceDictionaryContentAsync()
{
var customAppThemeFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Wino.Core.UWP/AppThemes/Custom.xaml"));
return await FileIO.ReadTextAsync(customAppThemeFile);
2024-04-18 01:44:37 +02:00
}
}