Skip to content

Commit

Permalink
Merge pull request #139 from bdovaz/use-interface
Browse files Browse the repository at this point in the history
Use interfaces instead of implementations
  • Loading branch information
LuckyDucko authored Sep 30, 2024
2 parents 764c3e2 + f39dd1f commit b5fb645
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ public TPopupPage CreatePopupPage<TPopupPage>()

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;
}

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;
Expand Down

0 comments on commit b5fb645

Please sign in to comment.