From d78b8e273f3123d79737049379443ee8405d952c Mon Sep 17 00:00:00 2001 From: jerrry08 Date: Sun, 21 Jan 2024 14:40:43 -0400 Subject: [PATCH] Update themes --- Anikin/ViewModels/ProfileViewModel.cs | 34 +++-- Anikin/Views/AnimeItemView.xaml | 3 +- Anikin/Views/AnimeTabView.xaml | 31 ++--- Anikin/Views/Episodes/EpisodePage.xaml | 120 +++++++++--------- Anikin/Views/Episodes/EpisodesTabView.xaml | 5 +- Anikin/Views/ProfileTabView.xaml | 34 +++++ .../Templates/AnimeCarouselTemplateView.xaml | 3 +- .../Templates/AnimeTypeRangeTemplateView.xaml | 2 +- .../Templates/CarouselGenreTemplateView.xaml | 1 + Anikin/Views/Templates/GenreTemplateView.xaml | 3 +- .../Templates/SemiEpisodeTemplateView.xaml | 1 - 11 files changed, 140 insertions(+), 97 deletions(-) diff --git a/Anikin/ViewModels/ProfileViewModel.cs b/Anikin/ViewModels/ProfileViewModel.cs index 30da621..258769e 100644 --- a/Anikin/ViewModels/ProfileViewModel.cs +++ b/Anikin/ViewModels/ProfileViewModel.cs @@ -1,13 +1,10 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using Anikin.Services; using Anikin.ViewModels.Framework; using Anikin.Views; using Anikin.Views.Settings; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Maui; using Microsoft.Maui.ApplicationModel; using Microsoft.Maui.Controls; @@ -31,6 +28,27 @@ public ProfileViewModel(SettingsService settingsService) }; } + [RelayCommand] + private void ThemeSelected(int index) + { + var selectedTheme = (AppTheme)index; + + if (Settings.AppTheme == selectedTheme) + { + // For some reason, EventToCommandBehavior does not get removed + // when calling `new AppShell()` + return; + } + + Settings.AppTheme = selectedTheme; + Settings.Save(); + + App.ApplyTheme(); + + if (Application.Current is not null) + Application.Current.MainPage = new AppShell(); + } + [RelayCommand] async Task LoginWithAnilist() { @@ -62,11 +80,9 @@ async Task LoginWithAnilist() var clientID = "14733"; - var result = await Browser - .Default - .OpenAsync( - $"https://anilist.co/api/v2/oauth/authorize?client_id={clientID}&response_type=token" - ); + var result = await Browser.Default.OpenAsync( + $"https://anilist.co/api/v2/oauth/authorize?client_id={clientID}&response_type=token" + ); } [RelayCommand] diff --git a/Anikin/Views/AnimeItemView.xaml b/Anikin/Views/AnimeItemView.xaml index a4fcc65..0dcd339 100644 --- a/Anikin/Views/AnimeItemView.xaml +++ b/Anikin/Views/AnimeItemView.xaml @@ -111,7 +111,8 @@ LineBreakMode="TailTruncation" MaxLines="2" Text="{Binding Title.PreferredTitle}" - TextColor="#E9FFFFFF" /> + TextColor="{AppThemeBinding Light={StaticResource Gray900}, + Dark=#E9FFFFFF}" /> diff --git a/Anikin/Views/AnimeTabView.xaml b/Anikin/Views/AnimeTabView.xaml index cb1f0a2..18240b8 100644 --- a/Anikin/Views/AnimeTabView.xaml +++ b/Anikin/Views/AnimeTabView.xaml @@ -42,7 +42,7 @@ IsRefreshing="{Binding IsRefreshing}" ZIndex="-1"> - + + + diff --git a/Anikin/Views/Templates/AnimeCarouselTemplateView.xaml b/Anikin/Views/Templates/AnimeCarouselTemplateView.xaml index e25b2a8..82e4773 100644 --- a/Anikin/Views/Templates/AnimeCarouselTemplateView.xaml +++ b/Anikin/Views/Templates/AnimeCarouselTemplateView.xaml @@ -56,7 +56,7 @@ - + @@ -111,6 +111,7 @@ LineBreakMode="TailTruncation" MaxLines="5" Text="{Binding Title.PreferredTitle}" + TextColor="White" VerticalOptions="Center" /> diff --git a/Anikin/Views/Templates/GenreTemplateView.xaml b/Anikin/Views/Templates/GenreTemplateView.xaml index dbd720b..e9906ea 100644 --- a/Anikin/Views/Templates/GenreTemplateView.xaml +++ b/Anikin/Views/Templates/GenreTemplateView.xaml @@ -13,7 +13,8 @@ diff --git a/Anikin/Views/Templates/SemiEpisodeTemplateView.xaml b/Anikin/Views/Templates/SemiEpisodeTemplateView.xaml index 070514b..e23a3fa 100644 --- a/Anikin/Views/Templates/SemiEpisodeTemplateView.xaml +++ b/Anikin/Views/Templates/SemiEpisodeTemplateView.xaml @@ -42,7 +42,6 @@