Skip to content

Commit

Permalink
Merge pull request #27 from Crequency/dev=main
Browse files Browse the repository at this point in the history
[Pull Request] Click plugin card to open plugin detail window.
  • Loading branch information
Dynesshely authored May 21, 2023
2 parents 540d683 + cf3cf97 commit 63707ef
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
37 changes: 31 additions & 6 deletions ViewModels/Pages/Controls/PluginCardViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using Avalonia.Media.Imaging;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using KitX.Web.Rules;
using KitX_Dashboard.Data;
using KitX_Dashboard.Managers;
using KitX_Dashboard.Views;
using ReactiveUI;
using Serilog;
using System;
using System.IO;
using System.Reactive;

namespace KitX_Dashboard.ViewModels.Pages.Controls;

Expand All @@ -15,20 +19,39 @@ internal class PluginCardViewModel
public PluginCardViewModel()
{
pluginStruct.IconInBase64 = GlobalInfo.KitXIconBase64;
Log.Information($"Icon Loaded: {pluginStruct.IconInBase64}");

InitCommands();
}

private void InitCommands()
{
ViewDetailsCommand = ReactiveCommand.Create(() =>
{
if (Program.MainWindow is not null)
new PluginDetailWindow()
{
WindowStartupLocation = WindowStartupLocation.CenterOwner
}
.SetPluginStruct(pluginStruct)
.Show(Program.MainWindow);
});
}

internal string DisplayName => pluginStruct.DisplayName
.ContainsKey(ConfigManager.AppConfig.App.AppLanguage)
? pluginStruct.DisplayName[ConfigManager.AppConfig.App.AppLanguage]
: pluginStruct.DisplayName.Values.GetEnumerator().Current;
?
pluginStruct.DisplayName[ConfigManager.AppConfig.App.AppLanguage]
:
pluginStruct.DisplayName.Values.GetEnumerator().Current;

internal string Version => pluginStruct.Version;

internal string SimpleDescription => pluginStruct.SimpleDescription
.ContainsKey(ConfigManager.AppConfig.App.AppLanguage)
? pluginStruct.SimpleDescription[ConfigManager.AppConfig.App.AppLanguage]
: pluginStruct.SimpleDescription.GetEnumerator().Current.Value;
?
pluginStruct.SimpleDescription[ConfigManager.AppConfig.App.AppLanguage]
:
pluginStruct.SimpleDescription.GetEnumerator().Current.Value;

internal string IconInBase64 => pluginStruct.IconInBase64;

Expand Down Expand Up @@ -59,4 +82,6 @@ internal Bitmap IconDisplay
}
}
}

internal ReactiveCommand<Unit, Unit>? ViewDetailsCommand { get; set; }
}
6 changes: 4 additions & 2 deletions Views/Pages/Controls/PluginCard.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Bottom">
VerticalContentAlignment="Bottom"
Command="{Binding ViewDetailsCommand}">
<StackPanel Width="120"
Height="130"
Orientation="Vertical">
<TextBlock FontFamily="{StaticResource SourceHanSans}"
FontSize="20"
FontWeight="ExtraBold"
Text="{Binding DisplayName}"/>
Text="{Binding DisplayName}"
ToolTip.Tip="{Binding DisplayName}"/>
<TextBlock FontFamily="{StaticResource SourceHanSans}"
FontSize="14"
FontWeight="Light"
Expand Down

0 comments on commit 63707ef

Please sign in to comment.