Inner scope navigation
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="WidgetNavigationView.xaml" />
|
||||
<None Remove="WidgetSettingsNavigationView.xaml" />
|
||||
<None Remove="WidgetSettingsView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240124002-experimental2" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26031-preview" />
|
||||
@@ -18,4 +23,18 @@
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="WidgetSettingsNavigationView.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="WidgetNavigationView.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="WidgetSettingsView.xaml">
|
||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -9,9 +9,6 @@ public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddWidgetWindows(this IServiceCollection services)
|
||||
{
|
||||
// We need to feed information to the Widgets about our Windows host,
|
||||
// so the Windows host can make discussions how to display and interact with the widgets.
|
||||
|
||||
services.AddTransient((Func<IServiceProvider, IProxyServiceCollection<IWidgetBuilder>>)(provider =>
|
||||
new ProxyServiceCollection<IWidgetBuilder>(services =>
|
||||
{
|
||||
@@ -25,6 +22,11 @@ public static class IServiceCollectionExtensions
|
||||
services.AddHandler<KeyAcceleratorHandler>();
|
||||
services.AddHandler<StartProcessHandler>();
|
||||
|
||||
services.AddTransient<IViewModelContentBinder, ViewModelContentBinder>();
|
||||
|
||||
services.AddNavigationHandler<WindowHandler>();
|
||||
services.AddNavigationHandler<ContentControlHandler>();
|
||||
|
||||
services.AddHandler<WidgetViewModelEnumerator>();
|
||||
|
||||
services.AddTransient<IWidgetView, WidgetView>();
|
||||
@@ -33,6 +35,9 @@ public static class IServiceCollectionExtensions
|
||||
|
||||
services.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
|
||||
services.AddContentTemplate<WidgetSplitButtonViewModel, WidgetSplitButtonView>();
|
||||
|
||||
services.AddContentTemplate<WidgetSettingsNavigationViewModel, WidgetSettingsNavigationView>();
|
||||
services.AddContentTemplate<WidgetSettingsViewModel, WidgetSettingsView>("WidgetSettings");
|
||||
})));
|
||||
|
||||
return services;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<NavigationViewItem
|
||||
x:Class="Hyperbar.Widget.Windows.WidgetNavigationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:ui="using:Hyperbar.UI.Windows"
|
||||
Content="Widgets"
|
||||
IsExpanded="True"
|
||||
MenuItemsSource="{Binding}"
|
||||
SelectsOnInvoked="False">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Tapped">
|
||||
<ui:NavigateAction Name="WidgetSettings" TargetName="Settings" />
|
||||
</interactions:EventTriggerBehavior>
|
||||
<interactions:EventTriggerBehavior EventName="Loaded">
|
||||
<interactions:InvokeCommandAction Command="{Binding InitializeCommand}" />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
public partial class WidgetNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public WidgetNavigationView() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected WidgetNavigationViewModel ViewModel =>
|
||||
(WidgetNavigationViewModel)DataContext;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
[NotificationHandler(nameof(WidgetNavigationViewModel))]
|
||||
public class WidgetNavigationViewModel(IViewModelTemplateSelector viewModelTemplateSelector,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string text) :
|
||||
NavigationViewModel<WidgetSettingsNavigationViewModel>(serviceProvider, serviceFactory, publisher, subscriber, disposer, text)
|
||||
{
|
||||
public IViewModelTemplateSelector ViewModelTemplateSelector => viewModelTemplateSelector;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<NavigationViewItem
|
||||
x:Class="Hyperbar.Widget.Windows.WidgetSettingsNavigationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:ui="using:Hyperbar.UI.Windows"
|
||||
Content="{Binding Text}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Tapped">
|
||||
<ui:NavigateAction Name="WidgetSettings" TargetName="Settings" />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
@@ -0,0 +1,10 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
public sealed partial class WidgetSettingsNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public WidgetSettingsNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
public class WidgetSettingsNavigationViewModel(IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string text) :
|
||||
NavigationViewModel(serviceProvider, serviceFactory, publisher, subscriber, disposer, text);
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
public class WidgetSettingsNavigationViewModelEnumerator(IPublisher publisher,
|
||||
IWidgetHostCollection widgetHosts) :
|
||||
INotificationHandler<Enumerate<WidgetSettingsNavigationViewModel>>
|
||||
{
|
||||
public async Task Handle(Enumerate<WidgetSettingsNavigationViewModel> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
foreach (IWidgetHost host in widgetHosts)
|
||||
{
|
||||
if (host.Services.GetService<IServiceFactory>() is IServiceFactory serviceFactory)
|
||||
{
|
||||
await publisher.PublishAsync(new Create<WidgetSettingsNavigationViewModel>(serviceFactory
|
||||
.Create<WidgetSettingsNavigationViewModel>(host.Configuration.Name)),
|
||||
nameof(WidgetNavigationViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Widget.Windows.WidgetSettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid>
|
||||
<Button>Test</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
public partial class WidgetSettingsView : UserControl
|
||||
{
|
||||
public WidgetSettingsView() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected WidgetSettingsViewModel ViewModel =>
|
||||
(WidgetSettingsViewModel)DataContext;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget.Windows;
|
||||
|
||||
public class WidgetSettingsViewModel(IViewModelTemplateSelector viewModelTemplateSelector,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableCollectionViewModel<IObservableViewModel>(serviceProvider, serviceFactory, publisher, subscriber, disposer)
|
||||
{
|
||||
public IViewModelTemplateSelector ViewModelTemplateSelector => viewModelTemplateSelector;
|
||||
}
|
||||
Reference in New Issue
Block a user