diff --git a/StabilityMatrix.Avalonia/App.axaml.cs b/StabilityMatrix.Avalonia/App.axaml.cs index 1c37458c..b51b1ed9 100644 --- a/StabilityMatrix.Avalonia/App.axaml.cs +++ b/StabilityMatrix.Avalonia/App.axaml.cs @@ -232,6 +232,7 @@ public sealed class App : Application services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddSingleton(); services.AddSingleton(); @@ -258,6 +259,7 @@ public sealed class App : Application .Register(provider.GetRequiredService) .Register(provider.GetRequiredService) .Register(provider.GetRequiredService) + .Register(provider.GetRequiredService) .Register(provider.GetRequiredService) .Register(provider.GetRequiredService)); } @@ -277,6 +279,7 @@ public sealed class App : Application services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); // Controls services.AddTransient(); diff --git a/StabilityMatrix.Avalonia/DesignData/DesignData.cs b/StabilityMatrix.Avalonia/DesignData/DesignData.cs index 9974fe0a..f20f3056 100644 --- a/StabilityMatrix.Avalonia/DesignData/DesignData.cs +++ b/StabilityMatrix.Avalonia/DesignData/DesignData.cs @@ -298,6 +298,14 @@ public static class DesignData } }); + public static EnvVarsViewModel EnvVarsViewModel => DialogFactory.Get(viewModel => + { + viewModel.EnvVars = new List + { + new("UWU", "TRUE"), + }; + }); + public static RefreshBadgeViewModel RefreshBadgeViewModel => new() { State = ProgressState.Success diff --git a/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs new file mode 100644 index 00000000..6bd657c3 --- /dev/null +++ b/StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Avalonia.Collections; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using StabilityMatrix.Core.Attributes; +using StabilityMatrix.Core.Models; + +namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; + +[View(typeof(EnvVarsViewModel))] +public partial class EnvVarsViewModel : ContentDialogViewModelBase +{ + [ObservableProperty] + private string title = "Environment Variables"; + + [ObservableProperty, NotifyPropertyChangedFor(nameof(EnvVarsView))] + private IList envVars = new List(); + + public DataGridCollectionView EnvVarsView => new(EnvVars); + + // Add new environment variable + [RelayCommand] + private void AddEnvVar() + { + EnvVars.Add(new EnvVarKeyPair()); + } +} diff --git a/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs index 04f9b8aa..0c3881a9 100644 --- a/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs @@ -17,7 +17,9 @@ using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Helpers; using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Services; +using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.Views; +using StabilityMatrix.Avalonia.Views.Dialogs; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Helper; @@ -39,6 +41,7 @@ public partial class SettingsViewModel : PageViewModelBase private readonly ISettingsManager settingsManager; private readonly IPrerequisiteHelper prerequisiteHelper; private readonly IPyRunner pyRunner; + private readonly ServiceManager dialogFactory; public SharedState SharedState { get; } public override string Title => "Settings"; @@ -77,12 +80,14 @@ public partial class SettingsViewModel : PageViewModelBase ISettingsManager settingsManager, IPrerequisiteHelper prerequisiteHelper, IPyRunner pyRunner, + ServiceManager dialogFactory, SharedState sharedState) { this.notificationService = notificationService; this.settingsManager = settingsManager; this.prerequisiteHelper = prerequisiteHelper; this.pyRunner = pyRunner; + this.dialogFactory = dialogFactory; SharedState = sharedState; SelectedTheme = settingsManager.Settings.Theme ?? AvailableThemes[1]; @@ -111,6 +116,26 @@ public partial class SettingsViewModel : PageViewModelBase settingsManager.Transaction(s => s.RemoveFolderLinksOnShutdown = value); } + #region Package Environment + + [RelayCommand] + private async Task OpenEnvVarsDialog() + { + var viewModel = dialogFactory.Get(); + var dialog = new BetterContentDialog + { + Content = new EnvVarsDialog + { + DataContext = viewModel + }, + PrimaryButtonText = "Save", + IsPrimaryButtonEnabled = true, + CloseButtonText = "Cancel", + }; + + await dialog.ShowAsync(); + } + [RelayCommand] private async Task CheckPythonVersion() { @@ -142,6 +167,10 @@ public partial class SettingsViewModel : PageViewModelBase dialog.PrimaryButtonText = "Ok"; await dialog.ShowAsync(); } + + #endregion + + #region System diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml new file mode 100644 index 00000000..fb280956 --- /dev/null +++ b/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml.cs b/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml.cs new file mode 100644 index 00000000..63068706 --- /dev/null +++ b/StabilityMatrix.Avalonia/Views/Dialogs/EnvVarsDialog.axaml.cs @@ -0,0 +1,17 @@ +using Avalonia.Markup.Xaml; +using StabilityMatrix.Avalonia.Controls; + +namespace StabilityMatrix.Avalonia.Views.Dialogs; + +public partial class EnvVarsDialog : UserControlBase +{ + public EnvVarsDialog() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/StabilityMatrix.Avalonia/Views/Dialogs/LaunchOptionsDialog.axaml b/StabilityMatrix.Avalonia/Views/Dialogs/LaunchOptionsDialog.axaml index e8d78ebf..90f9e431 100644 --- a/StabilityMatrix.Avalonia/Views/Dialogs/LaunchOptionsDialog.axaml +++ b/StabilityMatrix.Avalonia/Views/Dialogs/LaunchOptionsDialog.axaml @@ -46,7 +46,7 @@ IsVisible="{Binding IsSearchBoxEnabled}" x:Name="SearchBox"> - + @@ -60,7 +60,7 @@ - + @@ -68,7 +68,7 @@ - + - + - - - - - - - -