diff --git a/JournalApp.Tests/CalendarTests.razor b/JournalApp.Tests/CalendarTests.razor index 8562f22..b73b909 100644 --- a/JournalApp.Tests/CalendarTests.razor +++ b/JournalApp.Tests/CalendarTests.razor @@ -100,34 +100,6 @@ weekHeaders[6].TextContent.Should().Be("Tu"); } - [Fact] - public void ChangePalette() - { - var layout = Render( - @ - - - - ); - - var preferenceService = Services.GetService(); - var initialColor = preferenceService.PrimaryColor; - - layout.Find(".pick-palette").Click(); - - // Click a color. - var overlay = layout.Find(".color-picker .mud-dialog-content .mud-picker-color-overlay-black .mud-picker-color-overlay"); - overlay.PointerDown(new PointerEventArgs { OffsetX = 235, OffsetY = 18 }); - overlay.PointerUp(new PointerEventArgs { OffsetX = 235, OffsetY = 18 }); - - // Close dialog. - layout.Find(".mud-overlay-dialog").Click(); - layout.WaitForAssertion(() => layout.FindAll(".mud-overlay-dialog").Count.Should().Be(0)); - - // Color should have changed. - preferenceService.PrimaryColor.Should().NotBe(initialColor); - } - [Fact] [Description("Are the number of years, and months in the grid correct?")] public void YearsAndMonths() diff --git a/JournalApp/Data/PreferenceService.cs b/JournalApp/Data/PreferenceService.cs index bb3fe69..e47d4fe 100644 --- a/JournalApp/Data/PreferenceService.cs +++ b/JournalApp/Data/PreferenceService.cs @@ -64,24 +64,6 @@ public bool HideNotes set => _preferenceStore.Set("hide_notes", value); } - public MudColor PrimaryColor - { - get - { - var palette = _preferenceStore.Get("mood_palette2", string.Empty); - - if (string.IsNullOrEmpty(palette)) - palette = "#FF9FDF"; - - return palette; - } - set - { - _preferenceStore.Set("mood_palette2", value.Value[..^2]); - GenerateMoodColors(); - } - } - public SafetyPlan SafetyPlan { get => _preferenceStore.GetJson("safety_plan"); @@ -152,7 +134,9 @@ private void UpdateStatusBar() private void GenerateMoodColors() { var emojis = DataPoint.Moods.Where(x => x != "🤔").ToList(); - var primary = PrimaryColor.ToMauiColor(); +#pragma warning disable CS0618 // Type or member is obsolete + var primary = Color.FromHex("#FF9FDF"); +#pragma warning restore CS0618 // Type or member is obsolete var complementary = primary.GetComplementary(); _moodColors = []; diff --git a/JournalApp/Pages/Calendar/CalendarPage.razor b/JournalApp/Pages/Calendar/CalendarPage.razor index fade809..c040258 100644 --- a/JournalApp/Pages/Calendar/CalendarPage.razor +++ b/JournalApp/Pages/Calendar/CalendarPage.razor @@ -14,8 +14,6 @@ Calendar - - @@ -118,17 +116,6 @@ } } - async Task OpenColorPicker() - { - logger.LogInformation("Opening color picker"); - - if (await ColorPickerDialog.ShowDialog(DialogService, PreferenceService.PrimaryColor) is MudColor selectedColor) - { - PreferenceService.PrimaryColor = selectedColor; - StateHasChanged(); - } - } - void Close() { logger.LogInformation("Going to index"); diff --git a/JournalApp/Pages/Calendar/ColorPickerDialog.razor b/JournalApp/Pages/Calendar/ColorPickerDialog.razor deleted file mode 100644 index 8e1ef16..0000000 --- a/JournalApp/Pages/Calendar/ColorPickerDialog.razor +++ /dev/null @@ -1,68 +0,0 @@ -@namespace JournalApp -@using Color = Microsoft.Maui.Graphics.Color; -@using MudBlazor.Utilities -@inject ILogger logger -@inject IDialogService DialogService -@inject KeyEventService KeyEventService - - - - Pick primary color - - - - - - - - Reset - - Cancel - - Submit - - - -@code { - [CascadingParameter] IMudDialogInstance MudDialog { get; set; } - - [Parameter] - public MudColor SelectedColor { get; set; } - - protected override void OnInitialized() - { - base.OnInitialized(); - - KeyEventService.Entered(() => Submit()); - } - - void Reset() - { - SelectedColor = new MudColor("#FF9FDF"); - KeyEventService.CloseDialog(MudDialog, SelectedColor); - } - - void Cancel() - { - KeyEventService.CancelDialog(MudDialog); - } - - void Submit() - { - KeyEventService.CloseDialog(MudDialog, SelectedColor); - } - - public static async Task ShowDialog(IDialogService dialogService, MudColor color) - { - var parameters = new DialogParameters { - { x => x.SelectedColor, color } - }; - - var options = new DialogOptions { FullWidth = false }; - - var dialog = await dialogService.ShowAsync(parameters, options); - var result = await dialog.Result; - - return result.Data as MudColor; - } -}