2026-10-03 12:43:07 +02:00
|
|
|
|
2026-10-01 08:09:45 +02:00
|
|
|
using PrivaPub.ClientModels.Resources;
|
2022-12-15 20:03:40 +01:00
|
|
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace decePubClient.Models
|
|
|
|
|
{
|
|
|
|
|
public class PageSettings
|
|
|
|
|
{
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "LanguageId", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string CurrentLanguageCode { get; set; } = "en";
|
|
|
|
|
//public bool NativeNotificationsEnabled { get; set; } = false;
|
|
|
|
|
[Range(0, 359, ErrorMessageResourceName = nameof(Range), ErrorMessageResourceType = typeof(ErrorsResource))]
|
|
|
|
|
public short LightThemeIndexColour { get; set; } = 25;
|
|
|
|
|
[Range(0, 359, ErrorMessageResourceName = nameof(Range), ErrorMessageResourceType = typeof(ErrorsResource))]
|
|
|
|
|
public short DarkThemeIndexColour { get; set; } = 215;
|
|
|
|
|
[Range(-2, 359, ErrorMessageResourceName = nameof(Range), ErrorMessageResourceType = typeof(ErrorsResource))]
|
|
|
|
|
public short IconsThemeIndexColour { get; set; } = 25;
|
|
|
|
|
|
|
|
|
|
public bool PreferSystemTheming { get; set; } = true;
|
|
|
|
|
public bool ThemeIsDarkMode { get; set; } = false;
|
|
|
|
|
public bool ThemeIsLightGray { get; set; } = true;
|
|
|
|
|
public bool ThemeIsDarkGray { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
public bool ShowDonatorBadge { get; set; } = false;
|
2026-10-07 11:56:59 +02:00
|
|
|
// before publishing pictures without a description, the composer asks once
|
|
|
|
|
public bool RemindAltText { get; set; } = true;
|
2026-10-03 12:43:07 +02:00
|
|
|
|
|
|
|
|
// How the theme flags combine is in wwwroot/js/theme.js: with PreferSystemTheming the OS picks light or dark;
|
|
|
|
|
// otherwise ThemeIsDarkGray, then ThemeIsLightGray, then ThemeIsDarkMode decide; either grey flag drops the
|
|
|
|
|
// colour. These keep the flags consistent when the UI changes one aspect.
|
|
|
|
|
|
|
|
|
|
public const short DefaultLightThemeIndexColour = 25;
|
|
|
|
|
public const short DefaultDarkThemeIndexColour = 215;
|
|
|
|
|
|
|
|
|
|
public bool IsGray() => ThemeIsLightGray || ThemeIsDarkGray;
|
|
|
|
|
|
|
|
|
|
/// <summary>Leaves system theming and shows the light or dark variant, grey or coloured as before.</summary>
|
|
|
|
|
public void SetDarkMode(bool isDark)
|
|
|
|
|
{
|
|
|
|
|
PreferSystemTheming = false;
|
|
|
|
|
ThemeIsDarkMode = isDark;
|
|
|
|
|
if (IsGray())
|
|
|
|
|
SetGray(true, isDark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Switches grey on or off for the variant currently shown.</summary>
|
|
|
|
|
public void SetGray(bool isGray, bool isDark)
|
|
|
|
|
{
|
|
|
|
|
ThemeIsDarkGray = isGray && isDark;
|
|
|
|
|
ThemeIsLightGray = isGray && !isDark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Sets the hue of the light or dark variant; picking a hue means colour, so grey goes off.</summary>
|
|
|
|
|
public void SetHue(bool isDark, short hue)
|
|
|
|
|
{
|
|
|
|
|
if (isDark)
|
|
|
|
|
DarkThemeIndexColour = hue;
|
|
|
|
|
else
|
|
|
|
|
LightThemeIndexColour = hue;
|
|
|
|
|
SetGray(false, isDark);
|
|
|
|
|
}
|
2022-12-15 20:03:40 +01:00
|
|
|
}
|
|
|
|
|
}
|