Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
移除ReactiveUI (#1514)
Browse files Browse the repository at this point in the history
* 移除ReactiveUI及相关引用,并重置VM接口部分

* 处理部分VM

* 梳理VM

* 完成替换重制工作
  • Loading branch information
Richasy authored Oct 9, 2022
1 parent a31afcf commit 3113e73
Show file tree
Hide file tree
Showing 365 changed files with 3,201 additions and 3,995 deletions.
23 changes: 23 additions & 0 deletions Bili.Uwp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DI.App", "src\Lib\DI.App\DI
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DI.Task", "src\Lib\DI.Task\DI.Task.csproj", "{A87244E1-94AB-40E6-A32B-1972429FBCB2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DI.Container", "src\Lib\DI.Container\DI.Container.csproj", "{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -485,6 +487,26 @@ Global
{A87244E1-94AB-40E6-A32B-1972429FBCB2}.Release|x64.Build.0 = Release|x64
{A87244E1-94AB-40E6-A32B-1972429FBCB2}.Release|x86.ActiveCfg = Release|x86
{A87244E1-94AB-40E6-A32B-1972429FBCB2}.Release|x86.Build.0 = Release|x86
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|ARM.ActiveCfg = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|ARM.Build.0 = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|ARM64.Build.0 = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|x64.ActiveCfg = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|x64.Build.0 = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|x86.ActiveCfg = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Debug|x86.Build.0 = Debug|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|Any CPU.Build.0 = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|ARM.ActiveCfg = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|ARM.Build.0 = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|ARM64.ActiveCfg = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|ARM64.Build.0 = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|x64.ActiveCfg = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|x64.Build.0 = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|x86.ActiveCfg = Release|Any CPU
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -510,6 +532,7 @@ Global
{6832083A-A832-4DF4-B3F7-C83D1F51BB95} = {48DF06B5-90AD-4AC6-81F7-B381DB093B09}
{18D92F2F-046E-4A35-83FC-476B097BB8B7} = {45B5DFF9-9F13-4BF3-B561-8ABBDFE5C237}
{A87244E1-94AB-40E6-A32B-1972429FBCB2} = {45B5DFF9-9F13-4BF3-B561-8ABBDFE5C237}
{81B36A8C-E9A5-46F1-B803-B4D329C6E4B4} = {45B5DFF9-9F13-4BF3-B561-8ABBDFE5C237}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {563225C5-4D56-446B-9ADE-09D3F0DE7963}
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Adapter.UnitTests/Adapter.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Update="Moq" Version="4.18.2" />
<PackageReference Update="xunit" Version="2.4.2" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
16 changes: 6 additions & 10 deletions src/App/App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
</Compile>
<Compile Include="Controls\Pgc\SeasonItem\SeasonItem.cs" />
<Compile Include="Controls\ReactiveControl.cs" />
<Compile Include="Controls\ReactiveUserControl.cs" />
<Compile Include="Controls\Settings\NotificationSettingSection.xaml.cs">
<DependentUpon>NotificationSettingSection.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -1323,26 +1324,17 @@
<Version>7.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.8.0-prerelease.220712001</Version>
<Version>2.8.2-prerelease.220830001</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="ReactiveUI">
<Version>18.3.1</Version>
</PackageReference>
<PackageReference Include="ReactiveUI.Uwp">
<Version>18.3.1</Version>
</PackageReference>
<PackageReference Include="Richasy.ExpanderEx.UWP">
<Version>1.0.4</Version>
</PackageReference>
<PackageReference Include="Richasy.FluentIcon.Regular.UWP">
<Version>1.1.150</Version>
</PackageReference>
<PackageReference Include="Splat">
<Version>14.4.1</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.26.0</Version>
</PackageReference>
Expand All @@ -1359,6 +1351,10 @@
<Project>{18d92f2f-046e-4a35-83fc-476b097bb8b7}</Project>
<Name>DI.App</Name>
</ProjectReference>
<ProjectReference Include="..\Lib\DI.Container\DI.Container.csproj">
<Project>{81b36a8c-e9a5-46f1-b803-b4d329c6e4b4}</Project>
<Name>DI.Container</Name>
</ProjectReference>
<ProjectReference Include="..\Lib\FrostMaster.Uwp\FrostMaster.Uwp.csproj">
<Project>{b9cd5845-2de3-40fc-bc0f-27c406929551}</Project>
<Name>FrostMaster.Uwp</Name>
Expand Down
16 changes: 8 additions & 8 deletions src/App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
using System;
using System.Text;
using Bili.DI.App;
using Bili.DI.Container;
using Bili.Models.App.Constants;
using Bili.Toolkit.Interfaces;
using Bili.ViewModels.Interfaces.Core;
using Splat;
using NLog;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
Expand Down Expand Up @@ -34,7 +35,7 @@ public App()
UnhandledException += OnUnhandledException;
var provider = CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(provider);
Locator.Current.GetService<IAppToolkit>().InitializeTheme();
Locator.Instance.GetService<IAppToolkit>().InitializeTheme();
RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested;
}

Expand Down Expand Up @@ -80,7 +81,7 @@ private async void OnLaunchedOrActivatedAsync(IActivatedEventArgs e)

if (e is LaunchActivatedEventArgs && (e as LaunchActivatedEventArgs).PrelaunchActivated == false)
{
var settingsToolkit = Locator.Current.GetService<ISettingsToolkit>();
var settingsToolkit = Locator.Instance.GetService<ISettingsToolkit>();
var isPrelaunch = settingsToolkit.ReadLocalSetting(Models.Enums.SettingNames.IsPrelaunch, true);
CoreApplication.EnablePrelaunch(isPrelaunch);
if (rootFrame.Content == null)
Expand All @@ -98,7 +99,7 @@ private async void OnLaunchedOrActivatedAsync(IActivatedEventArgs e)
}
else
{
await Locator.Current.GetService<IAppViewModel>()
await Locator.Instance.GetService<IAppViewModel>()
.InitializeProtocolFromQueryAsync(protocalArgs.Uri);
}
}
Expand All @@ -120,7 +121,7 @@ await Locator.Current.GetService<IAppViewModel>()
else
{
var args = e as CommandLineActivatedEventArgs;
await Locator.Current.GetService<IAppViewModel>()
await Locator.Instance.GetService<IAppViewModel>()
.InitializeCommandFromArgumentsAsync(args.Operation.Arguments);
}
}
Expand All @@ -140,7 +141,7 @@ await Locator.Current.GetService<IAppViewModel>()
}

Window.Current.Activate();
Locator.Current.GetService<IAppToolkit>().InitializeTitleBar();
Locator.Instance.GetService<IAppToolkit>().InitializeTitleBar();
}

/// <summary>
Expand Down Expand Up @@ -172,8 +173,7 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
private void OnUnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
e.Handled = true;

Locator.Current.GetService<ILogger>().Write(e.Exception, e.Message, Splat.LogLevel.Error);
Locator.Instance.GetService<ILogger>().Error(e.Exception);
}

private void NavigateToRootPage(object args = null)
Expand Down
2 changes: 1 addition & 1 deletion src/App/Behaviors/IncrementalBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private void OnIncrementalTriggered(object sender, EventArgs e)
{
if (AssociatedObject.DataContext is IIncrementalViewModel vm)
{
vm.IncrementalCommand.Execute().Subscribe();
vm.IncrementalCommand.ExecuteAsync(null);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/App/Behaviors/InitializeBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.ViewModels.Interfaces;
using Microsoft.Toolkit.Uwp.UI.Behaviors;
using Windows.UI.Xaml.Controls;
Expand All @@ -17,7 +16,7 @@ protected override void OnAssociatedObjectLoaded()
{
if (AssociatedObject.DataContext is IInitializeViewModel initVM)
{
initVM.InitializeCommand.Execute().Subscribe();
initVM.InitializeCommand.ExecuteAsync(null);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/App/Behaviors/ReloadBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void OnActivatableControlActivated(object sender, EventArgs e)
var dataContext = AssociatedObject.DataContext;
if (dataContext is IReloadViewModel reloadVM)
{
reloadVM.ReloadCommand.Execute().Subscribe();
reloadVM.ReloadCommand.ExecuteAsync(null);
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/App/Controls/App/AppTitleBar.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using System.ComponentModel;
using Bili.DI.Container;
using Bili.Models.Data.Local;
using Bili.ViewModels.Interfaces.Core;
using ReactiveUI;
using Splat;
using CommunityToolkit.Mvvm.ComponentModel;
using Windows.UI.Xaml;

namespace Bili.App.Controls
Expand All @@ -24,10 +23,10 @@ public sealed partial class AppTitleBar : AppTitleBarBase
public AppTitleBar()
{
InitializeComponent();
ViewModel = Locator.Current.GetService<IAppViewModel>();
_navigationViewModel = Locator.Current.GetService<INavigationViewModel>();
_recordViewModel = Locator.Current.GetService<IRecordViewModel>();
(ViewModel as ReactiveObject).PropertyChanged += OnViewModelPropertyChanged;
ViewModel = Locator.Instance.GetService<IAppViewModel>();
_navigationViewModel = Locator.Instance.GetService<INavigationViewModel>();
_recordViewModel = Locator.Instance.GetService<IRecordViewModel>();
(ViewModel as ObservableObject).PropertyChanged += OnViewModelPropertyChanged;
Loaded += OnLoaded;
}

Expand Down Expand Up @@ -62,7 +61,7 @@ private void ChangeTitleBarVisibility()
private void OnRemoveRecordButtonClick(object sender, RoutedEventArgs e)
{
var context = (sender as FrameworkElement).DataContext as PlayRecord;
_recordViewModel.RemovePlayRecordCommand.Execute(context).Subscribe();
_recordViewModel.RemovePlayRecordCommand.Execute(context);
}

private void OnPlayRecordItemClick(object sender, Windows.UI.Xaml.Controls.ItemClickEventArgs e)
Expand Down
6 changes: 3 additions & 3 deletions src/App/Controls/App/CenterPopup/CenterPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

using System;
using Bili.App.Pages.Desktop;
using Bili.DI.Container;
using Bili.ViewModels.Interfaces.Core;
using Splat;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
Expand All @@ -23,7 +23,7 @@ public partial class CenterPopup : ContentControl
public CenterPopup()
{
DefaultStyleKey = typeof(CenterPopup);
_navigationViewModel = Locator.Current.GetService<INavigationViewModel>();
_navigationViewModel = Locator.Instance.GetService<INavigationViewModel>();
Loaded += OnLoaded;
}

Expand All @@ -38,7 +38,7 @@ public void Show()
/// </summary>
public void Hide()
{
_navigationViewModel.BackCommand.Execute().Subscribe();
_navigationViewModel.BackCommand.Execute(null);
Closed?.Invoke(this, EventArgs.Empty);
}

Expand Down
6 changes: 3 additions & 3 deletions src/App/Controls/App/ImageViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Bili.DI.Container;
using Bili.Toolkit.Interfaces;
using Bili.ViewModels.Interfaces.Core;
using Splat;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.Storage.Pickers;
Expand Down Expand Up @@ -41,8 +41,8 @@ public ImageViewer()
{
InitializeComponent();
_images = new Dictionary<string, byte[]>();
_callerViewModel = Locator.Current.GetService<ICallerViewModel>();
_resourceToolkit = Locator.Current.GetService<IResourceToolkit>();
_callerViewModel = Locator.Instance.GetService<ICallerViewModel>();
_resourceToolkit = Locator.Instance.GetService<IResourceToolkit>();
Instance = this;
Images = new ObservableCollection<Models.Data.Appearance.Image>();
}
Expand Down
4 changes: 2 additions & 2 deletions src/App/Controls/App/PageHeader.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Richasy. All rights reserved.

using System.Windows.Input;
using Bili.DI.Container;
using Bili.ViewModels.Interfaces.Core;
using Splat;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

Expand Down Expand Up @@ -45,7 +45,7 @@ public sealed partial class PageHeader : UserControl
public PageHeader()
{
InitializeComponent();
_appViewModel = Locator.Current.GetService<IAppViewModel>();
_appViewModel = Locator.Instance.GetService<IAppViewModel>();
}

/// <summary>
Expand Down
5 changes: 2 additions & 3 deletions src/App/Controls/App/QuestionPanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright (c) Richasy. All rights reserved.

using Bili.DI.Container;
using Bili.ViewModels.Interfaces.Home;
using ReactiveUI;
using Splat;

namespace Bili.App.Controls
{
Expand All @@ -17,7 +16,7 @@ public sealed partial class QuestionPanel : QuestionPanelBase
public QuestionPanel()
{
InitializeComponent();
ViewModel = Splat.Locator.Current.GetService<IHelpPageViewModel>();
ViewModel = Locator.Instance.GetService<IHelpPageViewModel>();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/App/Controls/App/XboxNavigationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<muxc:NavigationView
x:Name="RootNavView"
Style="{StaticResource BiliNavigationViewStyle}"
ItemInvoked="OnRootNavViewItemInvoked"
ItemInvoked="OnRootNavViewItemInvokedAsync"
LosingFocus="OnRootNavViewLosingFocus"
NoFocusCandidateFound="OnRootNavViewNoFocusCandidateFound"
PaneDisplayMode="LeftCompact"
Expand All @@ -37,7 +37,7 @@
<muxc:NavigationViewItem
x:Name="SignInItem"
Content="{loc:Locale Name=SignIn}"
IsEnabled="{x:Bind AccountViewModel.IsSigning, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}"
IsEnabled="{x:Bind AccountViewModel.TrySignInCommand.IsRunning, Mode=OneWay, Converter={StaticResource ObjectToBoolReverseConverter}}"
Visibility="{x:Bind AccountViewModel.IsConnected, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<muxc:NavigationViewItem.Icon>
<icons:RegularFluentIcon Symbol="Person16" />
Expand Down
16 changes: 7 additions & 9 deletions src/App/Controls/App/XboxNavigationView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void NavigateToMainView(PageIds pageId, object parameter = null)
}
}

private void OnRootNavViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
private async void OnRootNavViewItemInvokedAsync(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
if (args.IsSettingsInvoked)
{
Expand All @@ -98,14 +98,12 @@ private void OnRootNavViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView
{
if (args.InvokedItemContainer == SignInItem)
{
AccountViewModel.TrySignInCommand.Execute(false).Subscribe(
_ =>
{
if (AccountViewModel.State == AuthorizeState.SignedIn)
{
ViewModel.Navigate(PageIds.XboxAccount);
}
});
await AccountViewModel.TrySignInCommand.ExecuteAsync(false);
if (AccountViewModel.State == AuthorizeState.SignedIn)
{
ViewModel.Navigate(PageIds.XboxAccount);
}

return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/App/Controls/Article/ArticleItem/ArticleItem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Richasy. All rights reserved.

using Bili.DI.Container;
using Bili.Toolkit.Interfaces;
using Bili.ViewModels.Interfaces.Article;
using Splat;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand All @@ -25,7 +25,7 @@ public sealed class ArticleItem : ReactiveControl<IArticleItemViewModel>, IRepea
/// <inheritdoc/>
public void ChangeLayout(Orientation orientation)
{
var resourceToolkit = Locator.Current.GetService<IResourceToolkit>();
var resourceToolkit = Locator.Instance.GetService<IResourceToolkit>();
Style = orientation == Orientation.Horizontal
? resourceToolkit.GetResource<Style>("HorizontalArticleItemStyle")
: resourceToolkit.GetResource<Style>("VerticalArticleItemStyle");
Expand Down
Loading

0 comments on commit 3113e73

Please sign in to comment.