Skip to content

Commit

Permalink
个性化主题色适配、设置页面排版修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Miaoyww committed Nov 2, 2024
1 parent adcb620 commit f83fe5e
Show file tree
Hide file tree
Showing 29 changed files with 235 additions and 151 deletions.
2 changes: 2 additions & 0 deletions src/NonsPlayer/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
<ResourceDictionary Source="/Styles/FlipView.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>


</Application.Resources>
</Application>
2 changes: 0 additions & 2 deletions src/NonsPlayer/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public App()
services.AddTransient<LocalArtistListBarViewModel>();
#endregion
// Lyric
services.AddTransient<LyricViewModel>();
services.AddTransient<LyricCardViewModel>();
Expand All @@ -153,7 +152,6 @@ public App()
GetService<IAppNotificationService>().Initialize();
UnhandledException += App_UnhandledException;


#region Config

Log.Information($"Start loading config, current config path:{ConfigManager.Instance.Settings.ConfigFilePath}");
Expand Down
6 changes: 4 additions & 2 deletions src/NonsPlayer/Components/Views/Home/GreetingsCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:winUi="using:CommunityToolkit.WinUI"
mc:Ignorable="d"
Unloaded="{x:Bind ViewModel.GreetingsCard_OnUnloaded}">
<Border Background="{StaticResource ComponentsCardBackground}"
<Border Background="{ThemeResource ComponentsCardBackground}"
CornerRadius="20">
<Grid Grid.Row="0" Margin="20">
<TextBlock FontSize="30"
Expand All @@ -16,7 +16,9 @@
VerticalAlignment="Center" HorizontalAlignment="Left" />
<TextBlock Text="{x:Bind ViewModel.TimeString, Mode=OneWay}"
Style="{StaticResource CommonTextStyle}"
FontWeight="Bold" FontSize="30" Foreground="#3662EC"
FontWeight="Bold"
FontSize="30"
Foreground="{ThemeResource IconActiveColor}"
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" />
</Grid>
</Border>
Expand Down
6 changes: 2 additions & 4 deletions src/NonsPlayer/Components/Views/Home/HitokotoCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:winUi="using:CommunityToolkit.WinUI"
mc:Ignorable="d"
Unloaded="{x:Bind ViewModel.HitokotoCard_OnUnloaded}">
<Border Background="{StaticResource ComponentsCardBackground}"
<Border Background="{ThemeResource ComponentsCardBackground}"
CornerRadius="20">
<Grid Grid.Row="0" Margin="20">
<Grid.ColumnDefinitions>
Expand All @@ -17,16 +17,14 @@
<StackPanel Grid.Column="0">
<TextBlock x:Uid="HitokotoCard"
Style="{StaticResource CommonTextStyle}"
Foreground="{StaticResource CommonTextColor}"
FontWeight="Medium" FontSize="25"
VerticalAlignment="Center" />
<TextBlock Text="HITOKOTO" FontSize="20"
Style="{StaticResource EnglishTextStyle}"
VerticalAlignment="Center" />
</StackPanel>
<RichTextBlock Grid.Column="1" Margin="30,0,0,0" VerticalAlignment="Center" Width="400"
Style="{StaticResource CommonRichTextStyle}" MaxLines="2"
Foreground="{StaticResource CommonTextColor}">
Style="{StaticResource CommonRichTextStyle}" MaxLines="2">
<Paragraph>
<Run Text="{x:Bind ViewModel.Hitokoto, Mode=OneWay}" />
</Paragraph>
Expand Down
2 changes: 1 addition & 1 deletion src/NonsPlayer/Components/Views/Home/RecentlyPlayCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:winUi="using:CommunityToolkit.WinUI"
xmlns:views="using:NonsPlayer.Components.Views"
mc:Ignorable="d">
<Border Background="{StaticResource ComponentsCardBackground}"
<Border Background="{ThemeResource ComponentsCardBackground}"
CornerRadius="20">
<Grid Margin="20,20,20,20">
<Grid.RowDefinitions>
Expand Down
7 changes: 5 additions & 2 deletions src/NonsPlayer/Components/Views/Home/TodayDurationCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:winUi="using:CommunityToolkit.WinUI"
mc:Ignorable="d"
Unloaded="{x:Bind ViewModel.TodayDurationCard_OnUnloaded}">
<Border Background="{StaticResource ComponentsCardBackground}"
<Border Background="{ThemeResource ComponentsCardBackground}"
CornerRadius="20">
<Grid Margin="20">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Center">
Expand All @@ -22,7 +22,10 @@
</TextBlock>
</StackPanel>
<TextBlock Style="{StaticResource CommonTextStyle}"
Text="{x:Bind ViewModel.Duration, Mode=OneWay}" FontSize="40" FontWeight="Bold" Foreground="#3662EC"
Text="{x:Bind ViewModel.Duration, Mode=OneWay}"
FontSize="40"
FontWeight="Bold"
Foreground="{ThemeResource IconActiveColor}"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Margin="0,20,0,20" />
</Grid>
Expand Down
5 changes: 3 additions & 2 deletions src/NonsPlayer/Components/Views/Home/TotalListenCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:winUi="using:CommunityToolkit.WinUI"
mc:Ignorable="d">
<Border Background="{StaticResource ComponentsCardBackground}"
<Border Background="{ThemeResource ComponentsCardBackground}"
CornerRadius="20">
<Grid Grid.Row="0" Margin="20">
<Grid.ColumnDefinitions>
Expand All @@ -24,7 +24,8 @@
</StackPanel>
<TextBlock Grid.Column="1" Text="{x:Bind ViewModel.TotalListen, Mode=OneWay}"
Style="{StaticResource CommonTextStyle}"
FontWeight="Bold" FontSize="38" Foreground="#3662EC"
FontWeight="Bold" FontSize="38"
Foreground="{ThemeResource IconActiveColor}"
VerticalAlignment="Center" HorizontalAlignment="Center" Margin="20,0,0,0" />
</Grid>
</Border>
Expand Down
3 changes: 2 additions & 1 deletion src/NonsPlayer/Components/Views/Local/LocalMusicCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Tapped="UIElement_OnTapped">
<Border Name="OpenMusicCard"
CornerRadius="{StaticResource CustomCornerRadius}"
Background="{StaticResource ComponentsCardBackground}">
Background="{ThemeResource ComponentsCardBackground}">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand All @@ -17,6 +17,7 @@
<ImageIcon Grid.Row="0"
HorizontalAlignment="Left"
Source="ms-appx:///Assets/Icons/library-music.svg"
Foreground="{ThemeResource CommonTextColor}"
Width="45" />
<StackPanel Grid.Row="1">
<TextBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Tapped="UIElement_OnTapped">
<Border Name="NewFolderCard"
CornerRadius="{StaticResource CustomCornerRadius}"
Background="{StaticResource ComponentsCardBackground}">
Background="{ThemeResource ComponentsCardBackground}">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand All @@ -18,6 +18,7 @@
<ImageIcon Grid.Row="0"
HorizontalAlignment="Left"
Source="ms-appx:///Assets/Icons/create_new_folder.svg"
Foreground="{ThemeResource CommonTextColor}"
Width="45" />
<StackPanel Grid.Row="1">
<TextBlock
Expand Down
3 changes: 2 additions & 1 deletion src/NonsPlayer/Components/Views/Local/LocalQueueCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Tapped="UIElement_OnTapped">
<Border Name="OpenQueueCard"
CornerRadius="{StaticResource CustomCornerRadius}"
Background="{StaticResource ComponentsCardBackground}">
Background="{ThemeResource ComponentsCardBackground}">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand All @@ -17,6 +17,7 @@
<ImageIcon Grid.Row="0"
HorizontalAlignment="Left"
Source="ms-appx:///Assets/Icons/queue-music.svg"
Foreground="{ThemeResource CommonTextColor}"
Width="45" />
<StackPanel Grid.Row="1">
<TextBlock
Expand Down
6 changes: 4 additions & 2 deletions src/NonsPlayer/Components/Views/Login/LoginTokenCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
xmlns:winUi="using:CommunityToolkit.WinUI"
mc:Ignorable="d">
<Border Name="Login"
Height="350" Width="350" CornerRadius="{StaticResource CustomCornerRadius}"
VerticalAlignment="Center" HorizontalAlignment="Center"
Height="350" Width="350"
CornerRadius="{StaticResource CustomCornerRadius}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Padding="0,40,0,0">
<Grid Name="TokenCard">
<Grid.RowDefinitions>
Expand Down
8 changes: 4 additions & 4 deletions src/NonsPlayer/Components/Views/MusicListBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="#"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
FontSize="15"
FontWeight="Medium" />
<TextBlock Grid.Column="1"
Margin="102,0,0,0"
x:Name="TitleTextBlock"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
FontSize="15"
FontWeight="Medium" />
<TextBlock Grid.Column="2"
x:Uid="MusicListBar_Album"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
FontSize="15"
FontWeight="Medium"
Margin="40,0,0,0" />
<TextBlock Grid.Column="3"
x:Uid="MusicListBar_Duration"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
FontSize="15"
FontWeight="Medium" />
</Grid>
Expand Down
9 changes: 4 additions & 5 deletions src/NonsPlayer/Components/Views/MusicListItemCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Name="IndexTextBlock" Grid.Column="0" Text="{x:Bind ViewModel.Index, Mode=OneWay}"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
FontSize="14"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,20,0"
Padding="0"
Expand All @@ -76,14 +76,13 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Name="TitleTextBlock"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
FontWeight="Medium"
FontSize="15"
MaxLines="2"
TextTrimming="WordEllipsis"
Foreground="{x:Bind ViewModel.TitleColor, Mode=OneWay}"
TextWrapping="Wrap">
<Run Text="{x:Bind ViewModel.Name, Mode=OneWay}" />
<Run Text="{x:Bind ViewModel.Trans, Mode=OneWay}"
Expand All @@ -106,7 +105,7 @@
x:Name="AlbumMetadata"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontFamily="HarmonyOS Sans SC" FontSize="14" FontWeight="Normal"
Foreground="Black" Padding="0"
Foreground="{ThemeResource CommonTextColor}" Padding="0"
Content="{x:Bind ViewModel.Album, Mode=OneWay}"
Command="{x:Bind ViewModel.ForwardAlbumCommand}" />
<StackPanel Grid.Column="4" HorizontalAlignment="Right" VerticalAlignment="Center"
Expand All @@ -125,7 +124,7 @@
FontSize="16" />
</Button>
<TextBlock Name="TimeTextBlock" Text="{x:Bind ViewModel.Time, Mode=OneWay}"
Style="{StaticResource CommonTextStyle}"
Style="{ThemeResource CommonTextStyle}"
Margin="0,3,0,0" Padding="0"
FontSize="14" />
</StackPanel>
Expand Down
3 changes: 2 additions & 1 deletion src/NonsPlayer/Components/Views/RadioCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<converters:RadioPlayIconConverter x:Key="RadioPlayIconConverter" />
<converters:LikeIconConverter x:Key="LikeIconConverter" />
</UserControl.Resources>
<Border CornerRadius="{StaticResource CustomCornerRadius}" Background="{StaticResource ComponentsCardBackground}">
<Border CornerRadius="{StaticResource CustomCornerRadius}"
Background="{ThemeResource ComponentsCardBackground}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down
7 changes: 4 additions & 3 deletions src/NonsPlayer/Components/Views/RecommendedPlaylistCard.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mc:Ignorable="d"
Tapped="{x:Bind ViewModel.RecommendedPlaylistCard_OnTapped}">
<Border
Background="{StaticResource ComponentsCardBackground}"
Background="{ThemeResource ComponentsCardBackground}"
CornerRadius="20" Width="500" Height="200">
<Grid>
<Grid.Resources>
Expand All @@ -32,11 +32,12 @@
<TextBlock x:Name="RecommendedPlaylistTextBlock"
Margin="20,10,0,0"
Style="{StaticResource CommonTextStyle}"
Foreground="{x:Bind ViewModel.FontColor, Mode=OneWay}" FontSize="40" CharacterSpacing="300" />
FontSize="40"
CharacterSpacing="300" />

<TextBlock x:Uid="RecommendedPlaylistCardTip"
Style="{StaticResource EnglishTextStyle}"
Foreground="{x:Bind ViewModel.FontColor, Mode=OneWay}" FontSize="24"
FontSize="24"
VerticalAlignment="Center" HorizontalAlignment="Center"
Visibility="{x:Bind ViewModel.TipVisibility, Mode=OneWay}" />
</StackPanel>
Expand Down
6 changes: 3 additions & 3 deletions src/NonsPlayer/Contracts/Services/IThemeSelectorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public interface IThemeSelectorService
{
ElementTheme Theme { get; }

Task InitializeAsync();
void Initialize();

Task SetThemeAsync(ElementTheme theme);
void SetTheme(ElementTheme theme);

Task SetRequestedThemeAsync();
void SetRequestedTheme();
}
7 changes: 4 additions & 3 deletions src/NonsPlayer/Converters/LikeIconConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
using NonsPlayer.Helpers;

Expand All @@ -8,9 +9,9 @@ public class LikeIconConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if ((bool)value) return App.Current.Resources["IconActiveColor"] as SolidColorBrush;
if ((bool)value) return Application.Current.Resources["IconActiveColor"] as SolidColorBrush;

return App.Current.Resources["IconCommonColor"] as SolidColorBrush;
return Application.Current.Resources["IconCommonColor"] as SolidColorBrush;
}

public object? ConvertBack(object value, Type targetType, object parameter, string language)
Expand Down
4 changes: 2 additions & 2 deletions src/NonsPlayer/Services/ActivationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ private async Task HandleActivationAsync(object activationArgs)

private async Task InitializeAsync()
{
await _themeSelectorService.InitializeAsync().ConfigureAwait(false);
_themeSelectorService.Initialize();
await Task.CompletedTask;
}

private async Task StartupAsync()
{
await _themeSelectorService.SetRequestedThemeAsync();
_themeSelectorService.SetRequestedTheme();
await Task.CompletedTask;
}
}
Loading

0 comments on commit f83fe5e

Please sign in to comment.