Bunch of insane work
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<DataTemplate x:Key="DefaultDataTemplate">
|
||||
<ui:TemplateGeneratorControl />
|
||||
<ui:ViewModelTemplatePresenter />
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -37,7 +37,9 @@ public partial class App :
|
||||
services.AddHostedService<AppService>();
|
||||
|
||||
services.AddSingleton<IDispatcher>(new Dispatcher(DispatcherQueue.GetForCurrentThread()));
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
|
||||
services.AddTransient<IViewModelTemplateDescriptorProvider, ViewModelTemplateDescriptorProvider>();
|
||||
services.AddTransient<IViewModelTemplateFactory, ViewModelTemplateFactory>();
|
||||
|
||||
services.AddHandler<AppConfigurationChangedHandler>();
|
||||
services.AddConfiguration<AppConfiguration>(args =>
|
||||
@@ -55,6 +57,9 @@ public partial class App :
|
||||
services.AddContentTemplate<SettingsButtonViewModel, SettingsButtonView>();
|
||||
services.AddContentTemplate<SettingsViewModel, SettingsView>("Settings");
|
||||
|
||||
services.AddContentTemplate<GeneralSettingsNavigationViewModel, GeneralSettingsNavigationView>();
|
||||
services.AddContentTemplate<WidgetSettingsNavigationViewModel, WidgetSettingsNavigationView>();
|
||||
|
||||
services.AddTransient<IInitializer, AppInitializer>();
|
||||
})
|
||||
.Build();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
x:Class="Hyperbar.Windows.ApplicationBarView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
xmlns:ui="using:Hyperbar.UI.Windows">
|
||||
<UserControl.Resources>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrush" Color="Transparent" />
|
||||
@@ -17,7 +17,7 @@
|
||||
</UserControl.Resources>
|
||||
<ItemsControl
|
||||
Margin="6,0,6,0"
|
||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||
ItemTemplateSelector="{ui:ViewModelTemplate}"
|
||||
ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -36,7 +36,7 @@
|
||||
</ItemsControl.ItemContainerTransitions>
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="windows:GridExtension.GridColumnBindingPath" Value="Index" />
|
||||
<Setter Property="ui:GridExtension.GridColumnBindingPath" Value="Index" />
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
</ItemsControl>
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
[NotificationHandler(nameof(IWidgetHostViewModel))]
|
||||
public partial class ApplicationBarViewModel :
|
||||
ObservableCollectionViewModel<IDisposable>,
|
||||
ITemplatedViewModel
|
||||
ObservableCollectionViewModel<IDisposable>
|
||||
{
|
||||
public ApplicationBarViewModel(ITemplateFactory templateFactory,
|
||||
public ApplicationBarViewModel(IViewModelTemplateFactory templateFactory,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) : base(serviceFactory, mediator, disposer)
|
||||
IDisposer disposer) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
|
||||
@@ -16,5 +16,5 @@ public partial class ApplicationBarViewModel :
|
||||
Add<SecondaryViewModel>(1);
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<NavigationViewItem
|
||||
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" />
|
||||
@@ -0,0 +1,10 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class GeneralSettingsNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public GeneralSettingsNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class GeneralSettingsNavigationViewModel(IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
string text) :
|
||||
NavigationViewModel(serviceProvider, serviceFactory, mediator, disposer, text)
|
||||
{
|
||||
}
|
||||
@@ -15,10 +15,12 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="ApplicationBarView.xaml" />
|
||||
<None Remove="GeneralSettingsNavigationView.xaml" />
|
||||
<None Remove="PrimaryView.xaml" />
|
||||
<None Remove="SecondaryView.xaml" />
|
||||
<None Remove="SettingsButtonView.xaml" />
|
||||
<None Remove="SettingsView.xaml" />
|
||||
<None Remove="WidgetSettingsNavigationView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
@@ -55,6 +57,16 @@
|
||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="GeneralSettingsNavigationView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="WidgetSettingsNavigationView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="SettingsView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
x:Class="Hyperbar.Windows.PrimaryView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
xmlns:ui="using:Hyperbar.UI.Windows">
|
||||
<ItemsControl
|
||||
HorizontalAlignment="Center"
|
||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||
ItemTemplateSelector="{ui:ViewModelTemplate}"
|
||||
ItemsSource="{x:Bind ViewModel}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
[NotificationHandler(nameof(IWidgetHostViewModel))]
|
||||
public partial class PrimaryViewModel(ITemplateFactory templateFactory,
|
||||
public partial class PrimaryViewModel(IViewModelTemplateFactory templateFactory,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
int index) :
|
||||
ObservableCollectionViewModel<IWidgetViewModel>(serviceFactory, mediator, disposer),
|
||||
IWidgetHostViewModel,
|
||||
ITemplatedViewModel
|
||||
ObservableCollectionViewModel<IWidgetViewModel>(serviceProvider, serviceFactory, mediator, disposer),
|
||||
IWidgetHostViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index = index;
|
||||
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
public IViewModelTemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
x:Class="Hyperbar.Windows.SecondaryView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||
xmlns:ui="using:Hyperbar.UI.Windows">
|
||||
<Grid>
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl ItemTemplateSelector="{ui:ViewModelTemplate}" ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel Orientation="Horizontal" />
|
||||
|
||||
@@ -4,17 +4,17 @@ using Hyperbar.Windows;
|
||||
namespace Hyperbar.Widget;
|
||||
|
||||
public partial class SecondaryViewModel :
|
||||
ObservableCollectionViewModel<IDisposable>,
|
||||
ITemplatedViewModel
|
||||
ObservableCollectionViewModel<IDisposable>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private int index;
|
||||
|
||||
public SecondaryViewModel(ITemplateFactory templateFactory,
|
||||
public SecondaryViewModel(IViewModelTemplateFactory templateFactory,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
int index) : base(serviceFactory, mediator, disposer)
|
||||
int index) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
this.index = index;
|
||||
@@ -22,5 +22,5 @@ public partial class SecondaryViewModel :
|
||||
Add<SettingsButtonViewModel>();
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
@@ -4,21 +4,21 @@ using CommunityToolkit.Mvvm.Input;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public partial class SettingsButtonViewModel :
|
||||
ObservableViewModel,
|
||||
ITemplatedViewModel
|
||||
ObservableViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IRelayCommand? invokeCommand;
|
||||
|
||||
public SettingsButtonViewModel(ITemplateFactory templateFactory,
|
||||
public SettingsButtonViewModel(IViewModelTemplateFactory templateFactory,
|
||||
IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) : base(serviceFactory, mediator, disposer)
|
||||
IDisposer disposer) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
InvokeCommand = new AsyncRelayCommand(async () =>
|
||||
await mediator.PublishAsync(new Navigate("Settings")));
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
x:Class="Hyperbar.Windows.SettingsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hyperbar="using:Hyperbar">
|
||||
xmlns:ui="using:Hyperbar.UI.Windows"
|
||||
xmlns:windows="using:Hyperbar.Windows">
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
</Window.SystemBackdrop>
|
||||
@@ -11,11 +12,6 @@
|
||||
IsBackButtonVisible="Collapsed"
|
||||
IsPaneToggleButtonVisible="False"
|
||||
IsSettingsVisible="False"
|
||||
MenuItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||
<NavigationView.MenuItemTemplate>
|
||||
<DataTemplate x:DataType="hyperbar:NavigationViewModel">
|
||||
<NavigationViewItem Content="{x:Bind Text, Mode=OneWay}" />
|
||||
</DataTemplate>
|
||||
</NavigationView.MenuItemTemplate>
|
||||
</NavigationView>
|
||||
MenuItemTemplateSelector="{ui:ViewModelTemplate}"
|
||||
MenuItemsSource="{x:Bind ViewModel, Mode=OneWay}" />
|
||||
</Window>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Hyperbar.UI.Windows;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
@@ -5,9 +7,18 @@ namespace Hyperbar.Windows;
|
||||
public partial class SettingsView :
|
||||
Window
|
||||
{
|
||||
public SettingsView() =>
|
||||
public SettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.TitleBarConfiguration(args =>
|
||||
{
|
||||
args.ExtendsContentIntoTitleBar = true;
|
||||
args.ButtonBackgroundColor = Colors.Transparent;
|
||||
args.ButtonInactiveBackgroundColor = Colors.Transparent;
|
||||
});
|
||||
}
|
||||
|
||||
protected SettingsViewModel ViewModel =>
|
||||
(SettingsViewModel)(Content as FrameworkElement)!.DataContext;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public partial class SettingsViewModel :
|
||||
ObservableCollectionViewModel<NavigationViewModel>
|
||||
ObservableCollectionViewModel<INavigationViewModel>
|
||||
{
|
||||
public SettingsViewModel(IServiceFactory serviceFactory,
|
||||
public SettingsViewModel(IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer) : base(serviceFactory, mediator, disposer)
|
||||
IDisposer disposer,
|
||||
IViewModelTemplateFactory templateFactory) : base(serviceProvider, serviceFactory, mediator, disposer)
|
||||
{
|
||||
Add<NavigationViewModel>("General");
|
||||
Add<NavigationViewModel>("Widgets");
|
||||
Add<GeneralSettingsNavigationViewModel>("General");
|
||||
Add<WidgetSettingsNavigationViewModel>("Widgets");
|
||||
|
||||
TemplateFactory = templateFactory;
|
||||
}
|
||||
|
||||
public IViewModelTemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class WidgetNavigationViewModel(IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
string text) :
|
||||
NavigationViewModel(serviceProvider, serviceFactory, mediator, disposer, text)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<NavigationViewItem
|
||||
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" />
|
||||
@@ -0,0 +1,10 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class WidgetSettingsNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public WidgetSettingsNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class WidgetSettingsNavigationViewModel(IServiceProvider serviceProvider,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IDisposer disposer,
|
||||
string text) :
|
||||
NavigationViewModel<WidgetNavigationViewModel>(serviceProvider, serviceFactory, mediator, disposer, text)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user