moer changes
This commit is contained in:
@@ -37,9 +37,9 @@ public partial class App :
|
||||
services.AddHostedService<AppService>();
|
||||
|
||||
services.AddSingleton<IDispatcher>(new Dispatcher(DispatcherQueue.GetForCurrentThread()));
|
||||
|
||||
|
||||
services.AddTransient<IViewModelTemplate, ViewModelTemplate>();
|
||||
services.AddTransient<IViewModelTemplateDescriptorProvider, ViewModelTemplateDescriptorProvider>();
|
||||
services.AddTransient<IViewModelTemplateFactory, ViewModelTemplateFactory>();
|
||||
|
||||
services.AddHandler<AppConfigurationChangedHandler>();
|
||||
services.AddConfiguration<AppConfiguration>(args =>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</UserControl.Resources>
|
||||
<ItemsControl
|
||||
Margin="6,0,6,0"
|
||||
ItemTemplateSelector="{ui:ViewModelTemplate}"
|
||||
ItemTemplateSelector="{Binding Template}"
|
||||
ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
namespace Hyperbar.Widget;
|
||||
using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
|
||||
[NotificationHandler(nameof(IWidgetHostViewModel))]
|
||||
public partial class ApplicationBarViewModel :
|
||||
ObservableCollectionViewModel<IDisposable>
|
||||
{
|
||||
public ApplicationBarViewModel(IViewModelTemplateFactory templateFactory,
|
||||
public ApplicationBarViewModel(IViewModelTemplate template,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
Template = template;
|
||||
|
||||
Add<PrimaryViewModel>(0);
|
||||
Add<SecondaryViewModel>(1);
|
||||
}
|
||||
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
public IViewModelTemplate Template { get; }
|
||||
}
|
||||
@@ -3,4 +3,13 @@
|
||||
x:Class="Hyperbar.Windows.GeneralSettingsNavigationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="General" />
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:ui="using:Hyperbar.UI.Windows"
|
||||
Content="General">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Tapped">
|
||||
<ui:NavigateAction />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
|
||||
@@ -2,9 +2,12 @@ using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class GeneralSettingsNavigationView :
|
||||
public partial class GeneralSettingsNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public GeneralSettingsNavigationView() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected GeneralSettingsNavigationViewModel ViewModel =>
|
||||
(GeneralSettingsNavigationViewModel)DataContext;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:ui="using:Hyperbar.UI.Windows">
|
||||
<ItemsControl
|
||||
HorizontalAlignment="Center"
|
||||
ItemTemplateSelector="{ui:ViewModelTemplate}"
|
||||
ItemTemplateSelector="{Binding Template}"
|
||||
ItemsSource="{x:Bind ViewModel}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
[NotificationHandler(nameof(IWidgetHostViewModel))]
|
||||
public partial class PrimaryViewModel(IViewModelTemplateFactory templateFactory,
|
||||
public partial class PrimaryViewModel(IViewModelTemplate template,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
@@ -15,5 +16,6 @@ public partial class PrimaryViewModel(IViewModelTemplateFactory templateFactory,
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
|
||||
public IViewModelTemplateFactory TemplateFactory => templateFactory;
|
||||
public IViewModelTemplate Template => template;
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:Hyperbar.UI.Windows">
|
||||
<Grid>
|
||||
<ItemsControl ItemTemplateSelector="{ui:ViewModelTemplate}" ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Template}" ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Hyperbar.UI.Windows;
|
||||
using Hyperbar.Windows;
|
||||
|
||||
namespace Hyperbar.Widget;
|
||||
@@ -9,18 +10,19 @@ public partial class SecondaryViewModel :
|
||||
[ObservableProperty]
|
||||
private int index;
|
||||
|
||||
public SecondaryViewModel(IViewModelTemplateFactory templateFactory,
|
||||
public SecondaryViewModel(IViewModelTemplate template,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
int index) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
{
|
||||
Template = template;
|
||||
this.index = index;
|
||||
|
||||
Add<SettingsButtonViewModel>();
|
||||
}
|
||||
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
public IViewModelTemplate Template { get; }
|
||||
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.SettingsButtonView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
<UserControl.Resources>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrush" Color="Transparent" />
|
||||
@@ -18,8 +21,13 @@
|
||||
Width="{ThemeResource ButtonWidth}"
|
||||
Height="{ThemeResource ButtonHeight}"
|
||||
Padding="{ThemeResource ButtonPadding}"
|
||||
Command="{x:Bind ViewModel.InvokeCommand}"
|
||||
Content=""
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="16" />
|
||||
FontSize="16">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Click">
|
||||
<windows:NavigateAction Path="Settings" />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</Button>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public partial class SettingsButtonViewModel :
|
||||
ObservableViewModel
|
||||
public partial class SettingsButtonViewModel(IViewModelTemplate template,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IRelayCommand? invokeCommand;
|
||||
|
||||
public SettingsButtonViewModel(IViewModelTemplateFactory templateFactory,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
InvokeCommand = new AsyncRelayCommand(async () =>
|
||||
await mediator.PublishAsync(new Navigate("Settings")));
|
||||
}
|
||||
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
public IViewModelTemplate Template => template;
|
||||
}
|
||||
@@ -2,9 +2,7 @@
|
||||
<Window
|
||||
x:Class="Hyperbar.Windows.SettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:Hyperbar.UI.Windows"
|
||||
xmlns:windows="using:Hyperbar.Windows">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
</Window.SystemBackdrop>
|
||||
@@ -12,6 +10,6 @@
|
||||
IsBackButtonVisible="Collapsed"
|
||||
IsPaneToggleButtonVisible="False"
|
||||
IsSettingsVisible="False"
|
||||
MenuItemTemplateSelector="{ui:ViewModelTemplate}"
|
||||
MenuItemTemplateSelector="{Binding Template}"
|
||||
MenuItemsSource="{x:Bind ViewModel, Mode=OneWay}" />
|
||||
</Window>
|
||||
</Window>
|
||||
@@ -1,19 +1,21 @@
|
||||
namespace Hyperbar.Windows;
|
||||
using Hyperbar.UI.Windows;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public partial class SettingsViewModel :
|
||||
ObservableCollectionViewModel<INavigationViewModel>
|
||||
{
|
||||
public SettingsViewModel(IServiceProvider serviceProvider,
|
||||
public SettingsViewModel(IViewModelTemplate template,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
IViewModelTemplateFactory templateFactory) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
IDisposer disposer) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
Template = template;
|
||||
|
||||
Add<GeneralSettingsNavigationViewModel>("General");
|
||||
Add<WidgetSettingsNavigationViewModel>("Widgets");
|
||||
|
||||
TemplateFactory = templateFactory;
|
||||
}
|
||||
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
public IViewModelTemplate Template { get; }
|
||||
}
|
||||
|
||||
@@ -3,4 +3,13 @@
|
||||
x:Class="Hyperbar.Windows.WidgetSettingsNavigationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="Widgets" />
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:ui="using:Hyperbar.UI.Windows"
|
||||
Content="Widgets">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Tapped">
|
||||
<ui:NavigateAction />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using Hyperbar.Widget;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class WidgetSettingsNavigationView :
|
||||
public partial class WidgetSettingsNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public WidgetSettingsNavigationView() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected WidgetSettingsNavigationViewModel ViewModel =>
|
||||
(WidgetSettingsNavigationViewModel)DataContext;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user