Fix machine detail sub-item navigation

This commit is contained in:
2026-06-30 08:10:09 +01:00
parent e394736648
commit 86245dae81
5 changed files with 125 additions and 44 deletions

View File

@@ -5,7 +5,8 @@ namespace Marechai.App.Presentation.Models;
/// </summary>
public class GpuDisplayItem
{
public int Id { get; set; }
public string DisplayName { get; set; } = string.Empty;
public string Manufacturer { get; set; } = string.Empty;
public bool HasManufacturer { get; set; }
}
}

View File

@@ -5,8 +5,9 @@ namespace Marechai.App.Presentation.Models;
/// </summary>
public class ProcessorDisplayItem
{
public int Id { get; set; }
public string DisplayName { get; set; } = string.Empty;
public string Manufacturer { get; set; } = string.Empty;
public bool HasDetails { get; set; }
public string DetailsText { get; set; } = string.Empty;
}
}

View File

@@ -5,7 +5,8 @@ namespace Marechai.App.Presentation.Models;
/// </summary>
public class SoundSynthesizerDisplayItem
{
public int Id { get; set; }
public string DisplayName { get; set; } = string.Empty;
public bool HasDetails { get; set; }
public string DetailsText { get; set; } = string.Empty;
}
}

View File

@@ -315,6 +315,57 @@ public partial class MachineViewViewModel : ObservableObject, IRegionAware
return Task.CompletedTask;
}
[RelayCommand]
public Task NavigateToProcessor(ProcessorDisplayItem? processor)
{
if(processor is null || processor.Id <= 0) return Task.CompletedTask;
var parameters = new NavigationParameters
{
{ NavParamKeys.ProcessorId, processor.Id },
{ NavParamKeys.MachineId, _currentMachineId },
{ NavParamKeys.NavigationSource, nameof(MachineViewViewModel) }
};
_regionManager.RequestNavigate(RegionNames.Content, nameof(ProcessorDetailPage), parameters);
return Task.CompletedTask;
}
[RelayCommand]
public Task NavigateToGpu(GpuDisplayItem? gpu)
{
if(gpu is null || gpu.Id <= 0) return Task.CompletedTask;
var parameters = new NavigationParameters
{
{ NavParamKeys.GpuId, gpu.Id },
{ NavParamKeys.MachineId, _currentMachineId },
{ NavParamKeys.NavigationSource, nameof(MachineViewViewModel) }
};
_regionManager.RequestNavigate(RegionNames.Content, nameof(GpuDetailPage), parameters);
return Task.CompletedTask;
}
[RelayCommand]
public Task NavigateToSoundSynth(SoundSynthesizerDisplayItem? soundSynth)
{
if(soundSynth is null || soundSynth.Id <= 0) return Task.CompletedTask;
var parameters = new NavigationParameters
{
{ NavParamKeys.SoundSynthId, soundSynth.Id },
{ NavParamKeys.MachineId, _currentMachineId },
{ NavParamKeys.NavigationSource, nameof(MachineViewViewModel) }
};
_regionManager.RequestNavigate(RegionNames.Content, nameof(SoundSynthDetailPage), parameters);
return Task.CompletedTask;
}
[RelayCommand]
public async Task OpenVideo(MachineVideoDisplayItem? video)
{
@@ -424,6 +475,7 @@ public partial class MachineViewViewModel : ObservableObject, IRegionAware
Processors.Add(new ProcessorDisplayItem
{
Id = processor.Id ?? 0,
DisplayName = processor.Name ?? string.Empty,
Manufacturer = processor.Company ?? string.Empty,
HasDetails = details.Count > 0,
@@ -464,6 +516,7 @@ public partial class MachineViewViewModel : ObservableObject, IRegionAware
{
Gpus.Add(new GpuDisplayItem
{
Id = gpu.Id ?? 0,
DisplayName = LocalizeSpecialGpuName(gpu.Name),
Manufacturer = gpu.Company ?? string.Empty,
HasManufacturer = !string.IsNullOrEmpty(gpu.Company)
@@ -483,6 +536,7 @@ public partial class MachineViewViewModel : ObservableObject, IRegionAware
SoundSynthesizers.Add(new SoundSynthesizerDisplayItem
{
Id = synth.Id ?? 0,
DisplayName = LocalizeSpecialSoundSynthName(synth.Name),
HasDetails = details.Count > 0,
DetailsText = string.Join(", ", details)

View File

@@ -204,22 +204,30 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource MetadataCardStyle}">
<StackPanel Spacing="8">
<TextBlock Text="{Binding DisplayName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextControlForeground}" />
<TextBlock Text="{Binding Manufacturer}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}" />
<TextBlock Text="{Binding DetailsText}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}"
TextWrapping="Wrap"
Visibility="{Binding HasDetails}" />
</StackPanel>
</Border>
<Button Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Command="{Binding DataContext.NavigateToProcessorCommand, ElementName=PageRoot}"
CommandParameter="{Binding}"
Background="Transparent"
BorderThickness="0">
<Border Style="{StaticResource MetadataCardStyle}">
<StackPanel Spacing="8">
<TextBlock Text="{Binding DisplayName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextControlForeground}" />
<TextBlock Text="{Binding Manufacturer}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}" />
<TextBlock Text="{Binding DetailsText}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}"
TextWrapping="Wrap"
Visibility="{Binding HasDetails}" />
</StackPanel>
</Border>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -277,18 +285,26 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource MetadataCardStyle}">
<StackPanel Spacing="8">
<TextBlock Text="{Binding DisplayName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextControlForeground}" />
<TextBlock Text="{Binding Manufacturer}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}"
Visibility="{Binding HasManufacturer}" />
</StackPanel>
</Border>
<Button Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Command="{Binding DataContext.NavigateToGpuCommand, ElementName=PageRoot}"
CommandParameter="{Binding}"
Background="Transparent"
BorderThickness="0">
<Border Style="{StaticResource MetadataCardStyle}">
<StackPanel Spacing="8">
<TextBlock Text="{Binding DisplayName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextControlForeground}" />
<TextBlock Text="{Binding Manufacturer}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}"
Visibility="{Binding HasManufacturer}" />
</StackPanel>
</Border>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -312,19 +328,27 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource MetadataCardStyle}">
<StackPanel Spacing="8">
<TextBlock Text="{Binding DisplayName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextControlForeground}" />
<TextBlock Text="{Binding DetailsText}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}"
TextWrapping="Wrap"
Visibility="{Binding HasDetails}" />
</StackPanel>
</Border>
<Button Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Command="{Binding DataContext.NavigateToSoundSynthCommand, ElementName=PageRoot}"
CommandParameter="{Binding}"
Background="Transparent"
BorderThickness="0">
<Border Style="{StaticResource MetadataCardStyle}">
<StackPanel Spacing="8">
<TextBlock Text="{Binding DisplayName}"
FontSize="14"
FontWeight="SemiBold"
Foreground="{ThemeResource TextControlForeground}" />
<TextBlock Text="{Binding DetailsText}"
FontSize="12"
Foreground="{ThemeResource SystemBaseMediumColor}"
TextWrapping="Wrap"
Visibility="{Binding HasDetails}" />
</StackPanel>
</Border>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>