Merge pull request #139 from bdovaz/use-interface

Use interfaces instead of implementations
This commit is contained in:
Tyson Elliot Hooker
2024-09-30 12:14:20 +10:00
committed by GitHub
4 changed files with 16 additions and 22 deletions

View File

@@ -1,8 +1,6 @@
using Mopups.PreBaked.AbstractClasses;
namespace Mopups.PreBaked.Interfaces
namespace Mopups.PreBaked.Interfaces
{
public interface IGenericViewModel<TViewModel> where TViewModel : BasePopupViewModel
public interface IGenericViewModel<TViewModel> where TViewModel : IBasePopupViewModel
{
void SetViewModel(TViewModel viewModel);
TViewModel GetViewModel();

View File

@@ -1,10 +1,12 @@
using System.ComponentModel;
namespace Mopups.PreBaked.Interfaces
{
public interface IBasePopupViewModel
{
public interface IBasePopupViewModel
{
bool IsBusy { get; set; }
event PropertyChangedEventHandler PropertyChanged;
}
void RunOnAttachment<TPopupType>(TPopupType popupPage) where TPopupType : Pages.PopupPage;
}
}

View File

@@ -1,25 +1,19 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Mopups.PreBaked.AbstractClasses;
using Mopups.Pages;
using Mopups.Pages;
namespace Mopups.PreBaked.Interfaces
{
public interface IPreBakedMopupService
{
public interface IPreBakedMopupService
{
TPopupPage AttachViewModel<TPopupPage, TViewModel>(TPopupPage popupPage, TViewModel viewModel)
where TPopupPage : PopupPage, IGenericViewModel<TViewModel>
where TViewModel : BasePopupViewModel;
where TViewModel : IBasePopupViewModel;
TPopupPage CreatePopupPage<TPopupPage>() where TPopupPage : PopupPage, new();
Task ForceMinimumWaitTime(Task returnableTask, int millisecondsDelay);
Task<TAsyncActionResult> ForceMinimumWaitTime<TAsyncActionResult>(Task<TAsyncActionResult> returnableTask, int millisecondsDelay);
void PopAsync<TPopupType>() where TPopupType : PopupPage, new();
void PopAsync<TPopupType>(Action<Exception> exceptionActionForSafeFireAndForget) where TPopupType : PopupPage, new();
Task<TReturnable> PushAsync<TViewModel, TPopupPage, TReturnable>(TViewModel modalViewModel)
where TViewModel : PopupViewModel<TReturnable>
where TViewModel : IPopupViewModel<TReturnable>, IBasePopupViewModel
where TPopupPage : PopupPage, IGenericViewModel<TViewModel>, new();
Task<TSyncActionResult> WrapReturnableFuncInLoader<TSyncActionResult>(Func<TSyncActionResult> action, Color loaderColour, Color loaderPopupColour, List<string> reasonsForLoader, Color textColour, int millisecondsBetweenReasons = 2000);
Task<TSyncActionResult> WrapReturnableFuncInLoader<TSyncActionResult, TPopupPage>(Func<TSyncActionResult> action, Color loaderColour, Color loaderPopupColour, List<string> reasonsForLoader, Color textColour, int millisecondsBetweenReasons = 2000) where TPopupPage : PopupPage, IGenericViewModel<PopupPages.Loader.LoaderViewModel>, new();

View File

@@ -75,8 +75,8 @@ namespace Mopups.PreBaked.Services
public TPopupPage AttachViewModel<TPopupPage, TViewModel>(TPopupPage popupPage, TViewModel viewModel)
where TPopupPage : PopupPage, IGenericViewModel<TViewModel>
where TViewModel : BasePopupViewModel
{
where TViewModel : IBasePopupViewModel
{
popupPage.SetViewModel(viewModel);
viewModel.RunOnAttachment<TPopupPage>(popupPage);
return popupPage;
@@ -84,8 +84,8 @@ namespace Mopups.PreBaked.Services
public async Task<TReturnable> PushAsync<TViewModel, TPopupPage, TReturnable>(TViewModel modalViewModel)
where TPopupPage : PopupPage, IGenericViewModel<TViewModel>, new()
where TViewModel : PopupViewModel<TReturnable>
{
where TViewModel : IPopupViewModel<TReturnable>, IBasePopupViewModel
{
TPopupPage popupModal = AttachViewModel(CreatePopupPage<TPopupPage>(), modalViewModel);
await s_popupNavigation.PushAsync(popupModal);
return await modalViewModel.Returnable.Task;