Skip to content

Commit

Permalink
fix: 优化暗黑模式表现并修复dialog暗黑模式异常问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yaobiao131 committed Apr 8, 2024
1 parent 5d8c39d commit 8922ab4
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 157 deletions.
19 changes: 12 additions & 7 deletions DownKyi/PrismExtension/Dialog/DialogWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
Title="{Binding Title}"
WindowStartupLocation="CenterOwner">
<Window.Styles>
<SimpleTheme />
<Style Selector="Window">
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="TransparencyLevelHint" Value="AcrylicBlur" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CanResize" Value="False" />
<Setter Property="ShowInTaskbar" Value="False" />
<Setter Property="SystemDecorations" Value="None" />
</Style>
<Style Selector="Window">
<Setter Property="FontFamily" Value="{DynamicResource ProgramFont}" />
</Style>
<Style Selector="TemplatedControl">
<Setter Property="FontFamily" Value="{DynamicResource ProgramFont}" />
</Style>
<!-- <Style Selector="Window"> -->
<!-- <Setter Property="FontFamily" Value="{DynamicResource ProgramFont}" /> -->
<!-- </Style> -->
<!-- <Style Selector="TemplatedControl"> -->
<!-- <Setter Property="FontFamily" Value="{DynamicResource ProgramFont}" /> -->
<!-- </Style> -->

<!-- <SimpleTheme /> -->
<!-- <StyleInclude Source="avares://Avalonia.Themes.Simple/SimpleTheme.xaml" /> -->
</Window.Styles>
</Window>
4 changes: 2 additions & 2 deletions DownKyi/Themes/Colors/ColorDark.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Color x:Key="ColorWindowBorder">Black</Color>
<Color x:Key="ColorCaptionForeground">Black</Color>
<Color x:Key="ColorCaptionForeground">white</Color>
<Color x:Key="ColorCaptionBackground">#7FD0D0D0</Color>
<Color x:Key="ColorSystemBtnTint">white</Color>
<Color x:Key="ColorSystemBtnTintDark">black</Color>
Expand All @@ -16,7 +16,7 @@
<Color x:Key="ColorBackgroundDark">#FF00A1D6</Color>
<Color x:Key="ColorImageBorder">#7FD0D0D0</Color>
<Color x:Key="ColorImageBackground">#7FD0D0D0</Color>
<Color x:Key="ColorText">white</Color>
<Color x:Key="ColorText">Black</Color>
<Color x:Key="ColorTextDark">white</Color>
<Color x:Key="ColorTabHeaderGrey">#FF141414</Color>

Expand Down
27 changes: 7 additions & 20 deletions DownKyi/ViewModels/ViewDownloadManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,20 @@ public class ViewDownloadManagerViewModel : ViewModelBase

#region 页面属性申明

private VectorImage arrowBack;

public VectorImage ArrowBack
{
get => arrowBack;
set => SetProperty(ref arrowBack, value);
}

private List<TabHeader> tabHeaders;
private List<TabHeader> _tabHeaders;

public List<TabHeader> TabHeaders
{
get => tabHeaders;
set => SetProperty(ref tabHeaders, value);
get => _tabHeaders;
set => SetProperty(ref _tabHeaders, value);
}

private int selectTabId;
private int _selectTabId;

public int SelectTabId
{
get => selectTabId;
set => SetProperty(ref selectTabId, value);
get => _selectTabId;
set => SetProperty(ref _selectTabId, value);
}

#endregion
Expand All @@ -51,9 +43,6 @@ public ViewDownloadManagerViewModel(IRegionManager regionManager, IEventAggregat

#region 属性初始化

ArrowBack = NavigationIcon.Instance().ArrowBack;
ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");

TabHeaders = new List<TabHeader>
{
new()
Expand Down Expand Up @@ -107,7 +96,7 @@ private void ExecuteLeftTabHeadersCommand(object parameter)
return;
}

NavigationParameters param = new NavigationParameters();
var param = new NavigationParameters();

switch (tabHeader.Id)
{
Expand Down Expand Up @@ -136,7 +125,5 @@ public override void OnNavigatedTo(NavigationContext navigationContext)
SelectTabId = 0;

PropertyChangeAsync(() => { regionManager.RequestNavigate("DownloadManagerContentRegion", ViewDownloadingViewModel.Tag, new NavigationParameters()); });

ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");
}
}
20 changes: 3 additions & 17 deletions DownKyi/ViewModels/ViewLoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using DownKyi.Core.BiliApi.Login;
using DownKyi.Core.Logging;
using DownKyi.Events;
using DownKyi.Images;
using DownKyi.Utils;
using Prism.Commands;
using Prism.Events;
Expand All @@ -22,14 +21,6 @@ public class ViewLoginViewModel : ViewModelBase

#region 页面属性申明

private VectorImage _arrowBack;

public VectorImage ArrowBack
{
get => _arrowBack;
set => SetProperty(ref _arrowBack, value);
}

private Bitmap? _loginQrCode;

public Bitmap? LoginQrCode
Expand Down Expand Up @@ -60,9 +51,6 @@ public ViewLoginViewModel(IEventAggregator eventAggregator) : base(eventAggregat
{
#region 属性初始化

ArrowBack = NavigationIcon.Instance().ArrowBack;
ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");

#endregion
}

Expand All @@ -78,7 +66,7 @@ private void ExecuteBackSpace()

// 结束任务
_tokenSource.Cancel();
NavigationParam parameter = new NavigationParam
var parameter = new NavigationParam
{
ViewName = ParentView,
ParentViewName = null,
Expand Down Expand Up @@ -131,7 +119,7 @@ private void Login()
/// <param name="oauthKey"></param>
private void GetLoginStatus(string oauthKey)
{
CancellationToken cancellationToken = _tokenSource.Token;
var cancellationToken = _tokenSource.Token;
while (true)
{
Thread.Sleep(1000);
Expand Down Expand Up @@ -196,7 +184,7 @@ private void GetLoginStatus(string oauthKey)
// 保存登录信息
try
{
bool isSucceed = LoginHelper.SaveLoginInfoCookies(loginStatus.Data.Url);
var isSucceed = LoginHelper.SaveLoginInfoCookies(loginStatus.Data.Url);
if (!isSucceed)
{
EventAggregator.GetEvent<MessageEvent>()
Expand Down Expand Up @@ -236,8 +224,6 @@ private void GetLoginStatus(string oauthKey)
/// </summary>
private void InitStatus()
{
ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");

LoginQrCode = null;
LoginQrCodeOpacity = 1;
LoginQrCodeStatus = false;
Expand Down
44 changes: 13 additions & 31 deletions DownKyi/ViewModels/ViewToolboxViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using DownKyi.Events;
using DownKyi.Images;
using DownKyi.Utils;
using DownKyi.ViewModels.PageViewModels;
using DownKyi.ViewModels.Toolbox;
Expand All @@ -18,28 +17,20 @@ public class ViewToolboxViewModel : ViewModelBase

#region 页面属性申明

private VectorImage arrowBack;

public VectorImage ArrowBack
{
get => arrowBack;
set => SetProperty(ref arrowBack, value);
}

private List<TabHeader> tabHeaders;
private List<TabHeader> _tabHeaders;

public List<TabHeader> TabHeaders
{
get => tabHeaders;
set => SetProperty(ref tabHeaders, value);
get => _tabHeaders;
set => SetProperty(ref _tabHeaders, value);
}

private int selectTabId;
private int _selectTabId;

public int SelectTabId
{
get => selectTabId;
set => SetProperty(ref selectTabId, value);
get => _selectTabId;
set => SetProperty(ref _selectTabId, value);
}

#endregion
Expand All @@ -51,9 +42,6 @@ public ViewToolboxViewModel(IRegionManager regionManager, IEventAggregator event

#region 属性初始化

ArrowBack = NavigationIcon.Instance().ArrowBack;
ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");

TabHeaders = new List<TabHeader>
{
new() { Id = 0, Title = DictionaryResource.GetString("BiliHelper") },
Expand All @@ -67,17 +55,16 @@ public ViewToolboxViewModel(IRegionManager regionManager, IEventAggregator event
#region 命令申明

// 返回事件
private DelegateCommand backSpaceCommand;
private DelegateCommand? _backSpaceCommand;

public DelegateCommand BackSpaceCommand =>
backSpaceCommand ?? (backSpaceCommand = new DelegateCommand(ExecuteBackSpace));
public DelegateCommand BackSpaceCommand => _backSpaceCommand ??= new DelegateCommand(ExecuteBackSpace);

/// <summary>
/// 返回事件
/// </summary>
private void ExecuteBackSpace()
{
NavigationParam parameter = new NavigationParam
var parameter = new NavigationParam
{
ViewName = ParentView,
ParentViewName = null,
Expand All @@ -87,25 +74,22 @@ private void ExecuteBackSpace()
}

// 左侧tab点击事件
private DelegateCommand<object> leftTabHeadersCommand;
private DelegateCommand<object>? _leftTabHeadersCommand;

public DelegateCommand<object> LeftTabHeadersCommand => leftTabHeadersCommand ??
(leftTabHeadersCommand =
new DelegateCommand<object>(
ExecuteLeftTabHeadersCommand));
public DelegateCommand<object> LeftTabHeadersCommand => _leftTabHeadersCommand ??= new DelegateCommand<object>(ExecuteLeftTabHeadersCommand);

/// <summary>
/// 左侧tab点击事件
/// </summary>
/// <param name="parameter"></param>
private void ExecuteLeftTabHeadersCommand(object parameter)
{
if (!(parameter is TabHeader tabHeader))
if (parameter is not TabHeader tabHeader)
{
return;
}

NavigationParameters param = new NavigationParameters();
var param = new NavigationParameters();

switch (tabHeader.Id)
{
Expand Down Expand Up @@ -138,8 +122,6 @@ public override void OnNavigatedTo(NavigationContext navigationContext)
regionManager.RequestNavigate("ToolboxContentRegion", ViewBiliHelperViewModel.Tag,
new NavigationParameters());
});

ArrowBack.Fill = DictionaryResource.GetColor("ColorTextDark");
}
}
}
16 changes: 8 additions & 8 deletions DownKyi/Views/Dialogs/ViewAlertDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
xmlns:prismExtension="clr-namespace:DownKyi.PrismExtension.Dialog"
x:DataType="vmd:ViewAlertDialogViewModel">

<prismExtension:Dialog.Theme>
<ControlTheme TargetType="Window">
<Setter Property="CanResize" Value="False" />
<Setter Property="ShowInTaskbar" Value="False" />
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="SystemDecorations" Value="None" />
</ControlTheme>
</prismExtension:Dialog.Theme>
<!-- <prismExtension:Dialog.Theme> -->
<!-- <ControlTheme TargetType="Window"> -->
<!-- <Setter Property="CanResize" Value="False" /> -->
<!-- <Setter Property="ShowInTaskbar" Value="False" /> -->
<!-- <Setter Property="SizeToContent" Value="WidthAndHeight" /> -->
<!-- <Setter Property="SystemDecorations" Value="None" /> -->
<!-- </ControlTheme> -->
<!-- </prismExtension:Dialog.Theme> -->

<Border BorderBrush="{DynamicResource BrushWindowBorder}" BorderThickness="1,1,0.6,0.6">
<Grid RowDefinitions="40,*">
Expand Down
16 changes: 8 additions & 8 deletions DownKyi/Views/Dialogs/ViewAlreadyDownloadedDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
xmlns:prismExtension="clr-namespace:DownKyi.PrismExtension.Dialog"
x:DataType="vmd:ViewAlreadyDownloadedDialogViewModel">

<prismExtension:Dialog.Theme>
<ControlTheme TargetType="Window">
<Setter Property="CanResize" Value="False" />
<Setter Property="ShowInTaskbar" Value="False" />
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="SystemDecorations" Value="None" />
</ControlTheme>
</prismExtension:Dialog.Theme>
<!-- <prismExtension:Dialog.Theme> -->
<!-- <ControlTheme TargetType="Window"> -->
<!-- <Setter Property="CanResize" Value="False" /> -->
<!-- <Setter Property="ShowInTaskbar" Value="False" /> -->
<!-- <Setter Property="SizeToContent" Value="WidthAndHeight" /> -->
<!-- <Setter Property="SystemDecorations" Value="None" /> -->
<!-- </ControlTheme> -->
<!-- </prismExtension:Dialog.Theme> -->

<Border BorderBrush="{DynamicResource BrushWindowBorder}" BorderThickness="1,1,0.6,0.6">
<Grid RowDefinitions="40,*">
Expand Down
Loading

0 comments on commit 8922ab4

Please sign in to comment.