Refactor message boxes

This commit is contained in:
tyrrrz
2026-05-26 15:00:42 +03:00
parent 2aec84884b
commit 45629c9d7f
3 changed files with 7 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using DiscordChatExporter.Core.Discord.Data; using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Gui.Localization;
using DiscordChatExporter.Gui.ViewModels; using DiscordChatExporter.Gui.ViewModels;
using DiscordChatExporter.Gui.ViewModels.Components; using DiscordChatExporter.Gui.ViewModels.Components;
using DiscordChatExporter.Gui.ViewModels.Dialogs; using DiscordChatExporter.Gui.ViewModels.Dialogs;
@@ -8,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace DiscordChatExporter.Gui.Framework; namespace DiscordChatExporter.Gui.Framework;
public class ViewModelManager(IServiceProvider services) public class ViewModelManager(IServiceProvider services, LocalizationManager localizationManager)
{ {
public MainViewModel GetMainViewModel() => services.GetRequiredService<MainViewModel>(); public MainViewModel GetMainViewModel() => services.GetRequiredService<MainViewModel>();
@@ -46,7 +47,7 @@ public class ViewModelManager(IServiceProvider services)
} }
public MessageBoxViewModel GetMessageBoxViewModel(string title, string message) => public MessageBoxViewModel GetMessageBoxViewModel(string title, string message) =>
GetMessageBoxViewModel(title, message, "CLOSE", null); GetMessageBoxViewModel(title, message, localizationManager.CloseButton, null);
public SettingsViewModel GetSettingsViewModel() => public SettingsViewModel GetSettingsViewModel() =>
services.GetRequiredService<SettingsViewModel>(); services.GetRequiredService<SettingsViewModel>();

View File

@@ -6,20 +6,20 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs;
public partial class MessageBoxViewModel : DialogViewModelBase public partial class MessageBoxViewModel : DialogViewModelBase
{ {
[ObservableProperty] [ObservableProperty]
public partial string? Title { get; set; } = "Title"; public partial string? Title { get; set; }
[ObservableProperty] [ObservableProperty]
public partial string? Message { get; set; } = "Message"; public partial string? Message { get; set; }
[ObservableProperty] [ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsDefaultButtonVisible))] [NotifyPropertyChangedFor(nameof(IsDefaultButtonVisible))]
[NotifyPropertyChangedFor(nameof(ButtonsCount))] [NotifyPropertyChangedFor(nameof(ButtonsCount))]
public partial string? DefaultButtonText { get; set; } = "OK"; public partial string? DefaultButtonText { get; set; }
[ObservableProperty] [ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsCancelButtonVisible))] [NotifyPropertyChangedFor(nameof(IsCancelButtonVisible))]
[NotifyPropertyChangedFor(nameof(ButtonsCount))] [NotifyPropertyChangedFor(nameof(ButtonsCount))]
public partial string? CancelButtonText { get; set; } = "Cancel"; public partial string? CancelButtonText { get; set; }
public bool IsDefaultButtonVisible => !string.IsNullOrWhiteSpace(DefaultButtonText); public bool IsDefaultButtonVisible => !string.IsNullOrWhiteSpace(DefaultButtonText);

View File

@@ -3,7 +3,6 @@ using System.Threading.Tasks;
using DiscordChatExporter.Gui.Framework; using DiscordChatExporter.Gui.Framework;
using DiscordChatExporter.Gui.Localization; using DiscordChatExporter.Gui.Localization;
using DiscordChatExporter.Gui.Services; using DiscordChatExporter.Gui.Services;
using DiscordChatExporter.Gui.Utils.Extensions;
using DiscordChatExporter.Gui.ViewModels.Components; using DiscordChatExporter.Gui.ViewModels.Components;
using PowerKit.Extensions; using PowerKit.Extensions;