ui rework

This commit is contained in:
Lightczx
2024-01-26 15:38:00 +08:00
parent 2c6d25f0a3
commit f823cb5f1a
18 changed files with 342 additions and 188 deletions

View File

@@ -44,9 +44,7 @@ Install with Snap Hutao MSIX package, can be installed with Windows built-in App
### 特定的原神项目 / Specific Genshin-related Projects
* [biuuu/genshin-wish-export](https://github.com/biuuu/genshin-wish-export)
* [xunkong/xunkong](https://github.com/xunkong/xunkong)
* [YuehaiTeam/cocogoat](https://github.com/YuehaiTeam/cocogoat)
* [Scighost/Starward](https://github.com/Scighost/Starward)
### 使用的技术栈 / Tech Stack
@@ -57,7 +55,6 @@ Install with Snap Hutao MSIX package, can be installed with Windows built-in App
* [dotnet/efcore](https://github.com/dotnet/efcore)
* [dotnet/runtime](https://github.com/dotnet/runtime)
* [DotNetAnalyzers/StyleCopAnalyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers)
* [microsoft/CsWin32](https://github.com/microsoft/CsWin32)
* [microsoft/vs-validation](https://github.com/microsoft/vs-validation)
* [microsoft/WindowsAppSDK](https://github.com/microsoft/WindowsAppSDK)
* [microsoft/microsoft-ui-xaml](https://github.com/microsoft/microsoft-ui-xaml)

View File

@@ -0,0 +1,39 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using CommunityToolkit.WinUI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Snap.Hutao.Control.Helper;
[SuppressMessage("", "SH001")]
[DependencyProperty("PaneCornerRadius", typeof(CornerRadius), default, nameof(OnPaneCornerRadiusChanged), IsAttached = true, AttachedType = typeof(NavigationView))]
public sealed partial class NavigationViewHelper
{
private static void OnPaneCornerRadiusChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args)
{
NavigationView navigationView = (NavigationView)dp;
CornerRadius newValue = (CornerRadius)args.NewValue;
if (navigationView.IsLoaded)
{
SetNavigationViewPaneCornerRadius(navigationView, newValue);
return;
}
navigationView.Loaded += (s, e) =>
{
NavigationView loadedNavigationView = (NavigationView)s;
SetNavigationViewPaneCornerRadius(loadedNavigationView, newValue);
};
}
private static void SetNavigationViewPaneCornerRadius(NavigationView navigationView, CornerRadius value)
{
if (navigationView.FindDescendant("RootSplitView") is SplitView splitView)
{
splitView.CornerRadius = value;
}
}
}

View File

@@ -24,10 +24,33 @@
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}"/>
</Style>
<Style
x:Key="AcrylicBorderCardStyle"
BasedOn="{StaticResource BorderCardStyle}"
TargetType="Border">
<Setter Property="Background" Value="{ThemeResource SystemControlAcrylicElementMediumHighBrush}"/>
</Style>
<Style x:Key="GridCardStyle" TargetType="Grid">
<Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}"/>
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}"/>
</Style>
<Style
x:Key="AcrylicGridCardStyle"
BasedOn="{StaticResource GridCardStyle}"
TargetType="Grid">
<Setter Property="Background" Value="{ThemeResource SystemControlAcrylicElementMediumHighBrush}"/>
</Style>
<Style
x:Key="AcrylicBorderlessBorderCardStyle"
BasedOn="{StaticResource AcrylicBorderCardStyle}"
TargetType="Border">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
</Style>
</ResourceDictionary>

View File

@@ -2,6 +2,53 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shch="using:Snap.Hutao.Control.Helper">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<AcrylicBrush
x:Key="InfoBarErrorSeverityBackgroundBrush"
FallbackColor="#FDE7E9"
TintColor="#FDE7E9"
TintOpacity="0.6"/>
<AcrylicBrush
x:Key="InfoBarWarningSeverityBackgroundBrush"
FallbackColor="#FFF4CE"
TintColor="#FFF4CE"
TintOpacity="0.6"/>
<AcrylicBrush
x:Key="InfoBarSuccessSeverityBackgroundBrush"
FallbackColor="#DFF6DD"
TintColor="#DFF6DD"
TintOpacity="0.6"/>
<AcrylicBrush
x:Key="InfoBarInformationalSeverityBackgroundBrush"
FallbackColor="#80F6F6F6"
TintColor="#80F6F6F6"
TintOpacity="0.6"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<AcrylicBrush
x:Key="InfoBarErrorSeverityBackgroundBrush"
FallbackColor="#442726"
TintColor="#442726"
TintOpacity="0.6"/>
<AcrylicBrush
x:Key="InfoBarWarningSeverityBackgroundBrush"
FallbackColor="#433519"
TintColor="#433519"
TintOpacity="0.6"/>
<AcrylicBrush
x:Key="InfoBarSuccessSeverityBackgroundBrush"
FallbackColor="#393D1B"
TintColor="#393D1B"
TintOpacity="0.6"/>
<AcrylicBrush
x:Key="InfoBarInformationalSeverityBackgroundBrush"
FallbackColor="#34424d"
TintColor="#34424d"
TintOpacity="0.6"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<Thickness x:Key="InfoBarIconMargin">19,16,19,16</Thickness>
<Thickness x:Key="InfoBarContentRootPadding">0,0,0,0</Thickness>
<x:Double x:Key="InfoBarIconFontSize">20</x:Double>

View File

@@ -2,18 +2,18 @@
x:Class="Snap.Hutao.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shv="using:Snap.Hutao.View"
mc:Ignorable="d">
<Grid>
<shv:MainView/>
<shv:TitleView
x:Name="TitleBarView"
Height="44"
Margin="48,0,0,0"/>
Margin="44,0,0,0"/>
<shv:MainView/>
</Grid>
</Window>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

View File

@@ -135,6 +135,7 @@
<None Remove="Resource\Navigation\WikiMonster.png" />
<None Remove="Resource\Navigation\WikiWeapon.png" />
<None Remove="Resource\Segoe Fluent Icons.ttf" />
<None Remove="Resource\TestBackground.jpg" />
<None Remove="Resource\WelcomeView_Background.png" />
<None Remove="stylecop.json" />
<None Remove="View\Card\AchievementCard.xaml" />
@@ -277,6 +278,7 @@
<Content Include="Resource\Navigation\WikiAvatar.png" />
<Content Include="Resource\Navigation\WikiMonster.png" />
<Content Include="Resource\Navigation\WikiWeapon.png" />
<Content Include="Resource\TestBackground.jpg" />
<Content Include="Resource\WelcomeView_Background.png" />
</ItemGroup>

View File

@@ -14,6 +14,7 @@
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
d:DataContext="{d:DesignInstance shva:AchievementViewModelSlim}"
Background="Transparent"
Command="{Binding NavigateCommand}"
Style="{ThemeResource DefaultButtonStyle}"
mc:Ignorable="d">

View File

@@ -16,6 +16,7 @@
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
d:DataContext="{d:DesignInstance shvd:DailyNoteViewModelSlim}"
Background="Transparent"
Command="{Binding NavigateCommand}"
Style="{ThemeResource DefaultButtonStyle}"
mc:Ignorable="d">

View File

@@ -15,6 +15,7 @@
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
d:DataContext="{d:DesignInstance shvg:GachaLogViewModelSlim}"
Background="Transparent"
Command="{Binding NavigateCommand}"
Style="{ThemeResource DefaultButtonStyle}"
mc:Ignorable="d">

View File

@@ -14,6 +14,7 @@
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
d:DataContext="{d:DesignInstance shvg:LaunchGameViewModelSlim}"
Background="Transparent"
Command="{Binding LaunchCommand}"
Style="{ThemeResource DefaultButtonStyle}"
mc:Ignorable="d">

View File

@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shv="using:Snap.Hutao.View"
xmlns:shvh="using:Snap.Hutao.View.Helper"
@@ -12,16 +13,34 @@
<UserControl.Resources>
<Thickness x:Key="NavigationViewContentMargin">0,44,0,0</Thickness>
<x:Double x:Key="NavigationViewItemOnLeftIconBoxHeight">24</x:Double>
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent"/>
<StaticResource x:Key="NavigationViewExpandedPaneBackground" ResourceKey="SystemControlBaseHighAcrylicElementBrush"/>
<Thickness x:Key="NavigationViewContentGridBorderThickness">0</Thickness>
</UserControl.Resources>
<Grid>
<Image
Opacity="0.35"
Source="ms-appx:///Resource/TestBackground.jpg"
Stretch="UniformToFill"/>
<NavigationView
x:Name="NavView"
Margin="-1,0,0,-1"
shch:NavigationViewHelper.PaneCornerRadius="8,0,0,8"
CompactPaneLength="48"
IsBackEnabled="{x:Bind ContentFrame.CanGoBack, Mode=OneWay}"
IsPaneOpen="True"
OpenPaneLength="192"
PaneDisplayMode="Left"
UseLayoutRounding="False">
<NavigationView.Resources>
<StaticResource x:Key="NavigationViewExpandedPaneBackground" ResourceKey="SystemControlBaseHighAcrylicElementBrush"/>
<CornerRadius x:Key="NavigationViewContentGridCornerRadius">0</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">0</CornerRadius>
</NavigationView.Resources>
<NavigationView.MenuItems>
<NavigationViewItem
shvh:NavHelper.NavigateTo="shvp:AnnouncementPage"

View File

@@ -29,7 +29,7 @@
<DataTemplate x:Key="AnnouncementTemplate">
<ItemContainer cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
<Border Style="{StaticResource BorderCardStyle}">
<Border Background="{ThemeResource SystemControlAcrylicElementMediumHighBrush}" Style="{StaticResource BorderCardStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
@@ -187,10 +187,14 @@
</DataTemplate>
<DataTemplate x:Key="CardTemplate" x:DataType="shvcp:CardReference">
<ItemContainer cw:Effects.Shadow="{ThemeResource CompatCardShadow}" Child="{Binding Card}">
<ItemContainer cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
<ItemContainer.Resources>
<SolidColorBrush x:Key="ItemContainerPointerOverBackground" Color="Transparent"/>
</ItemContainer.Resources>
<Border Background="{ThemeResource SystemControlAcrylicElementMediumHighBrush}" CornerRadius="{ThemeResource ControlCornerRadius}">
<ContentControl HorizontalContentAlignment="Stretch" Content="{Binding Card}"/>
</Border>
</ItemContainer>
</DataTemplate>
</shc:ScopedPage.Resources>
@@ -205,7 +209,7 @@
Text="{Binding GreetingText}"/>
<ItemsControl
Margin="16,8,12,0"
Margin="16,8,16,0"
ItemTemplate="{StaticResource HutaoAnnouncementTemplate}"
ItemsSource="{Binding HutaoAnnouncements}"
Visibility="{Binding HutaoAnnouncements.Count, Converter={StaticResource Int32ToVisibilityConverter}}"/>

View File

@@ -21,6 +21,15 @@
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
</mxi:Interaction.Behaviors>
<Page.Resources>
<SolidColorBrush x:Key="ToggleButtonBackground" Color="Transparent"/>
<SolidColorBrush x:Key="ExpanderContentBackground" Color="Transparent"/>
<SolidColorBrush x:Key="SettingsCardBackground" Color="Transparent"/>
<SolidColorBrush x:Key="SettingsCardBackgroundDisabled" Color="Transparent"/>
<SolidColorBrush x:Key="SettingsCardBackgroundPointerOver" Color="Transparent"/>
<SolidColorBrush x:Key="SettingsCardBackgroundPressed" Color="Transparent"/>
</Page.Resources>
<Grid>
<SplitView
DisplayMode="Inline"
@@ -31,6 +40,7 @@
<SplitView.Pane>
<ScrollViewer>
<StackPanel Margin="16" Spacing="3">
<Border Style="{ThemeResource AcrylicBorderlessBorderCardStyle}">
<cwc:SettingsExpander
Description="{Binding RuntimeOptions.Version}"
Header="{shcm:ResourceString Name=AppName}"
@@ -48,6 +58,8 @@
<cwc:SettingsCard Description="{Binding RuntimeOptions.WebView2Version}" Header="{shcm:ResourceString Name=ViewPageSettingWebview2Header}"/>
</cwc:SettingsExpander.Items>
</cwc:SettingsExpander>
</Border>
<Border Style="{ThemeResource AcrylicBorderlessBorderCardStyle}">
<cwc:SettingsExpander
Description="{shcm:ResourceString Name=ViewPageFeedbackEngageWithUsDescription}"
Header="{shcm:ResourceString Name=ViewPageFeedbackCommonLinksHeader}"
@@ -74,6 +86,8 @@
IsClickEnabled="True"/>
</cwc:SettingsExpander.Items>
</cwc:SettingsExpander>
</Border>
<Border Style="{ThemeResource AcrylicBorderlessBorderCardStyle}">
<cwc:SettingsExpander
Header="{shcm:ResourceString Name=ViewPageFeedbackFeatureGuideHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xF8A5;}"
@@ -173,12 +187,13 @@
IsClickEnabled="True"/>
</cwc:SettingsExpander.Items>
</cwc:SettingsExpander>
</Border>
</StackPanel>
</ScrollViewer>
</SplitView.Pane>
<Grid>
<Grid Margin="16,16,0,16" Style="{ThemeResource AcrylicGridCardStyle}">
<Grid
Padding="16,16,0,16"
Padding="16"
RowSpacing="8"
Visibility="{Binding IsInitialized, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<Grid.RowDefinitions>

View File

@@ -356,9 +356,13 @@
</Pivot>
</Grid>
<Grid Visibility="{Binding GamePathSelectedAndValid, Converter={StaticResource BoolToVisibilityRevertConverter}}">
<StackPanel
<Border
Margin="128,0"
HorizontalAlignment="Center"
Padding="16"
VerticalAlignment="Center"
Style="{ThemeResource AcrylicBorderCardStyle}">
<StackPanel
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Spacing="3">
<shci:CachedImage
@@ -389,6 +393,7 @@
</cwc:SettingsCard.Description>
</cwc:SettingsCard>
</StackPanel>
</Border>
</Grid>
</Grid>
</shc:ScopedPage>

View File

@@ -322,7 +322,7 @@
Spacing="16">
<!-- 简介 -->
<Border cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
<Grid Background="{ThemeResource SystemControlAcrylicElementMediumHighBrush}" Style="{ThemeResource GridCardStyle}">
<Grid Style="{ThemeResource AcrylicGridCardStyle}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>

View File

@@ -1 +0,0 @@