Sextant 3.0.1
前缀已保留dotnet add package Sextant --version 3.0.1
NuGet\Install-Package Sextant -Version 3.0.1
<PackageReference Include="Sextant" Version="3.0.1" />
paket add Sextant --version 3.0.1
#r "nuget: Sextant, 3.0.1"
// Install Sextant as a Cake Addin #addin nuget:?package=Sextant&version=3.0.1 // Install Sextant as a Cake Tool #tool nuget:?package=Sextant&version=3.0.1
Sextant
<p align="left"><img src="https://github.com/reactiveui/styleguide/blob/master/logo_sextant/vertical.png?raw=true" alt="Sextant" height="180px"></p>
基于 ReactiveUI 的视图模型导航库
Sextant诞生自Xamvvm的分支,它是功能完善且简洁的MVVM框架,具有良好的导航系统。然而,我只是想使用一个简单的导航系统来配合ReactiveUI,同时避免所有与MVVM框架相关的复杂性。此外,我还希望使其更加“反应友好”。
然后,一位狂野的Rodney Littles出现了,随之而来的是Kent撰写的令人惊叹的文章的实现。
Sextant目前处于一个非常初始的阶段,并且正处于不断的变化中,所以请对使用它保持耐心……因为我们会弄乱事情的。
这个库不过是我在巨人的肩膀上“站立”:感谢Kent作为这个框架的原始和真正的创造者,我基本上只是复制和粘贴了它 😃,感谢Geoffrey Huntley在ReactiveUI上的维护。
NuGet安装
在您的Forms项目和ViewModels项目中安装nuget包。
GitHub
预发布包可在https://nuget.pkg.github.com/reactiveui/index.json找到
NuGet
平台 | Sextant包 | NuGet |
---|---|---|
UWP | Sextant | |
Xamarin.Forms | Sextant.XamForms | |
Xamarin.Forms | Sextant.Plugins.Popup | |
Xamarin.iOS | Sextant | |
Avalonia | Sextant.Avalonia |
目标平台版本
验证您拥有的目标是您的目标平台(例如,Android,iOS,Tizen)的最小版本。
注册组件
视图
2.0版本添加了对IMutableDependencyResolver的新扩展方法,这些方法允许您将IViewFor注册到视图中。
Locator
.CurrentMutable
.RegisterNavigationView(() => new NavigationView(RxApp.MainThreadScheduler, RxApp.TaskpoolScheduler, ViewLocator.Current))
.RegisterParameterViewStackService()
.RegisterViewForNavigation(() => new PassPage(), () => new PassViewModel())
.RegisterViewForNavigation(() => new ReceivedPage(), () => new ReceivedViewModel());
设置初始页面
Locator
.Current
.GetService<IParameterViewStackService>()
.PushPage<PassViewModel>()
.Subscribe();
MainPage = Locator.Current.GetNavigationView("NavigationView");
使用导航服务
然后,您只需要在ViewModel中调用一个方法即可。
/// <summary>
/// Pops the <see cref="IPageViewModel"/> off the stack.
/// </summary>
/// <param name="animate">if set to <c>true</c> [animate].</param>
/// <returns></returns>
IObservable<Unit> PopModal(bool animate = true);
/// <summary>
/// Pops the <see cref="IPageViewModel"/> off the stack.
/// </summary>
/// <param name="animate">if set to <c>true</c> [animate].</param>
/// <returns></returns>
IObservable<Unit> PopPage(bool animate = true);
/// <summary>
/// Pushes the <see cref="IPageViewModel"/> onto the stack.
/// </summary>
/// <param name="modal">The modal.</param>
/// <param name="contract">The contract.</param>
/// <returns></returns>
IObservable<Unit> PushModal(IPageViewModel modal, string contract = null);
/// <summary>
/// Pushes the <see cref="IPageViewModel"/> onto the stack.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="contract">The contract.</param>
/// <param name="resetStack">if set to <c>true</c> [reset stack].</param>
/// <param name="animate">if set to <c>true</c> [animate].</param>
/// <returns></returns>
IObservable<Unit> PushPage(IPageViewModel page, string contract = null, bool resetStack = false, bool animate = true);
示例
public class ViewModel
{
private readonly IViewStackServicen _viewStackService; // or IParameterViewStackServicen
public ViewModel(IViewStackServicen viewStackService)
{
_viewStackService = viewStackService;
OpenModal = ReactiveCommand
// FirstModalViewModel must implement IViewModel or INavigable
.CreateFromObservable(() => viewStackService.PushModal<FirstModalViewModel>(),
outputScheduler: RxApp.MainThreadScheduler);
}
public ReactiveCommand<Unit, Unit> OpenModal { get; }
}
传递参数
2.0版本增加了在导航时传递参数的功能。
示例
public class ViewModel
{
private readonly IParameterViewStackServicen _viewStackService;
public ViewModel(IParameterViewStackServicen viewStackService)
{
_viewStackService = viewStackService;
Navigate = ReactiveCommand
// NavigableViewModel must implement INavigable
.CreateFromObservable(() => viewStackService.PushModal<NavigableViewModel>(new NavigationParameter { { "parameter", parameter } }),
outputScheduler: RxApp.MainThreadScheduler);
}
public ReactiveCommand<Unit, Unit> Navigate { get; }
}
INavigable接口公开了可订阅的视图模型生命周期方法。这些方法解包您的参数对象。实现该接口允许您在导航过程中为视图模型分配值。
public class NavigableViewModel : INavigable
{
public string? _parameter;
public IObservable<Unit> WhenNavigatedFrom(INavigationParameter parameter)
{
return Observable.Return(Unit.Default)
}
public IObservable<Unit> WhenNavigatedTo(INavigationParameter parameter)
{
parameter.TryGetValue("parameter", out _parameter);
return Observable.Return(Unit.Default);
}
public IObservable<Unit> WhenNavigatingTo(INavigationParameter parameter)
{
return Observable.Return(Unit.Default);
}
}
示例
贡献
Sextant在OSI批准的开源许可下开发,使其可以免费使用和分发,甚至可用于商业用途。我们爱这个项目中涉及的人,并且我们非常希望有您的加入,尤其是如果您是刚开始或者以前从未为开源做出过贡献。
为了让您,想加入我们这个可爱的人知道——这就是您支持我们的方式
- 在StackOverflow上回答问题
- 传播知识和教导新一代的开发者
- 在您认为合适的地方提交文档更新或不足之处。
- 为代码库做出贡献。
产品 | 版本 兼容的和额外的计算目标框架版本。 |
---|---|
.NET | net5.0 已计算。 net5.0-windows 已计算。 net6.0 兼容。 net6.0-android 已计算。 net6.0-ios 已计算。 net6.0-maccatalyst 已计算。 net6.0-macos 已计算。 net6.0-tvos 已计算。 net6.0-windows 已计算。 net6.0-windows10.0.17763 兼容。 net6.0-windows10.0.19041 兼容。 net7.0 已计算。 net7.0-android 已计算。 net7.0-ios 已计算。 net7.0-maccatalyst 已计算。 net7.0-macos 已计算。 net7.0-tvos 已计算。 net7.0-windows 已计算。 net8.0 兼容。 net8.0-android 已计算。 net8.0-android34.0 兼容。 net8.0-browser 已计算。 net8.0-ios 已计算。 net8.0-ios17.2 兼容。 net8.0-maccatalyst 已计算。 net8.0-maccatalyst17.2 兼容。 net8.0-macos 已计算。 net8.0-macos14.2 兼容。 net8.0-tvos 已计算。 net8.0-tvos17.2 兼容。 net8.0-windows 已计算。 net8.0-windows10.0.17763 兼容。 net8.0-windows10.0.19041 兼容。 |
.NET Core | netcoreapp2.0 已计算出。 netcoreapp2.1 已计算出。 netcoreapp2.2 已计算出。 netcoreapp3.0 已计算出。 netcoreapp3.1 已计算出。 |
.NET标准 | netstandard2.0 兼容。 netstandard2.1 已计算出。 |
.NET框架 | net461 已计算出。 net462 兼容。 net463 已计算出。 net47 已计算出。 net471 已计算出。 net472 兼容。 net48 已计算出。 net481 已计算出。 |
MonoAndroid | monoandroid 已计算出。 |
MonoMac | monomac 已计算出。 |
MonoTouch | monotouch 已计算出。 |
Tizen | tizen40 已计算出。 tizen60 已计算出。 |
Xamarin.iOS | xamarinios 已计算出。 |
Xamarin.Mac | xamarinmac 已计算出。 |
Xamarin.TVOS | xamarintvos 已计算出。 |
Xamarin.WatchOS | xamarinwatchos 已计算出。 |
-
.NETFramework 4.6.2
- ReactiveUI (>= 20.1.1)
- System.Collections.Immutable (>= 8.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETFramework 4.7.2
- ReactiveUI (>= 20.1.1)
- System.Collections.Immutable (>= 8.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETStandard 2.0
- ReactiveUI (>= 20.1.1)
- System.Collections.Immutable (>= 8.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net6.0
- ReactiveUI (>= 20.1.1)
-
net6.0-windows10.0.17763
- ReactiveUI (>= 20.1.1)
-
net6.0-windows10.0.19041
- ReactiveUI (>= 20.1.1)
-
net8.0
- ReactiveUI (>= 20.1.1)
-
net8.0-android34.0
- ReactiveUI (>= 20.1.1)
-
net8.0-ios17.2
- ReactiveUI (>= 20.1.1)
-
net8.0-maccatalyst17.2
- ReactiveUI (>= 20.1.1)
-
net8.0-macos14.2
- ReactiveUI (>= 20.1.1)
-
net8.0-tvos17.2
- ReactiveUI (>= 20.1.1)
-
net8.0-windows10.0.17763
- ReactiveUI (>= 20.1.1)
-
net8.0-windows10.0.19041
- ReactiveUI (>= 20.1.1)
NuGet 包 (6)
显示依赖 Sextant 的前 5 个 NuGet 包
包 | 下载 |
---|---|
Sextant.XamForms A ReactiveUI导航库用于Xamarin.Forms |
|
Sextant.Maui A ReactiveUI导航库用于Xamarin.Forms |
|
Community.Sextant.WinUI
A ReactiveUI导航库用于WinUI 3。 |
|
Community.Sextant.WinUI.Microsoft.Extensions.DependencyInjection
Community.Sextant.WinUI的Microsoft.Extensions.DependencyInjection适配器。 |
|
Sextant.Avalonia A ReactiveUI导航库用于Xamarin.Forms |
GitHub仓库
此包未被任何流行的GitHub仓库使用。
版本 | 下载 | 最后更新 |
---|---|---|
3.0.1 | 269 | 5/27/2024 |
2.12.162 | 167 | 5/26/2024 |
2.12.120 | 1,476 | 1/25/2024 |
2.12.113 | 896 | 12/9/2023 |
2.12.112 | 170 | 12/9/2023 |
2.12.4 | 13,538 | 5/19/2021 |
2.12.3 | 490 | 5/18/2021 |
2.11.1 | 12,424 | 2/28/2021 |
2.10.1 | 7,197 | 1/22/2021 |
2.9.5 | 703 | 12/31/2020 |
2.9.4 | 608 | 12/28/2020 |
2.9.1 | 2,915 | 12/16/2020 |
2.8.1 | 998 | 11/5/2020 |
2.7.1 | 3,172 | 6/6/2020 |
2.6.1 | 813 | 5/8/2020 |
2.5.8 | 1,140 | 3/5/2020 |
2.5.1 | 1,220 | 1/6/2020 |
2.4.1 | 907 | 12/12/2019 |
2.3.9 | 711 | 12/5/2019 |
2.3.7 | 633 | 11/28/2019 |
2.3.1 | 653 | 11/21/2019 |
2.2.2 | 3,536 | 9/16/2019 |
2.2.1 | 683 | 9/6/2019 |
2.1.1 | 827 | 8/28/2019 |
2.0.6 | 717 | 8/24/2019 |
2.0.1 | 1,237 | 7/26/2019 |
1.5.5 | 1,249 | 3/20/2019 |
1.4.0 | 1,350 | 8/16/2018 |
1.4.0-unstable0003 | 693 | 8/16/2018 |
1.4.0-unstable0002 | 696 | 8/16/2018 |
1.3.0 | 3,134 | 7/20/2018 |
1.1.0-unstable0007 | 1,337 | 6/7/2018 |
1.1.0-unstable0006 | 881 | 6/7/2018 |
1.1.0-unstable0005 | 827 | 6/7/2018 |
1.1.0-unstable0004 | 815 | 6/6/2018 |
1.1.0-unstable0001 | 813 | 6/1/2018 |
0.4.0-unstable0004 | 891 | 6/1/2018 |
0.4.0-unstable0003 | 886 | 5/21/2018 |
0.4.0-unstable0002 | 858 | 4/16/2018 |
0.4.0-unstable0001 | 811 | 4/16/2018 |
0.3.4 | 1,047 | 4/16/2018 |
0.3.0-unstable0018 | 838 | 4/16/2018 |