48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Microsoft.UI.Xaml.Media;
|
|
using WinWARP.Core.Enums;
|
|
using WinWARP.Core.Services.Interfaces;
|
|
using WinWARP.Ui.Helpers;
|
|
using WinWARP.Ui.Views.Dialogs;
|
|
|
|
namespace WinWARP.Ui.Services;
|
|
|
|
public class DialogService : IDialogService
|
|
{
|
|
private readonly XamlRootTracker _tracker;
|
|
|
|
public DialogService(XamlRootTracker tracker)
|
|
{
|
|
_tracker = tracker;
|
|
}
|
|
|
|
public async Task<(CommonDialogResult Result, string Title, string URL, int UpdateInterval)> ShowAddSubscriptionAsync()
|
|
{
|
|
var dialog = App.Services.GetRequiredService<AddSubscriptionDialog>();
|
|
//dialog.Title = "Add new subscription";
|
|
//dialog.PrimaryButtonText = "Add";
|
|
//dialog.CloseButtonText = "Cancel";
|
|
dialog.XamlRoot = _tracker.XamlRoot;
|
|
dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style;
|
|
|
|
var result = await dialog.ShowAsync();
|
|
|
|
var mappedResult = result switch
|
|
{
|
|
ContentDialogResult.Primary => CommonDialogResult.Primary,
|
|
ContentDialogResult.Secondary => CommonDialogResult.Secondary,
|
|
ContentDialogResult.None => CommonDialogResult.Cancel,
|
|
_ => CommonDialogResult.None
|
|
};
|
|
|
|
return (mappedResult, dialog.ViewModel.CustomName, dialog.ViewModel.SubscriptionLink, dialog.ViewModel.UpdateInterval);
|
|
}
|
|
}
|