Replaced async void methods with async Task methods, where appropriate.
Also removed AnimationExtensions as it’s not used.
This commit is contained in:
parent
14efed11a8
commit
77b64d5370
@ -1,18 +0,0 @@
|
|||||||
using eShopOnContainers.Core.Animations.Base;
|
|
||||||
using System;
|
|
||||||
using Xamarin.Forms;
|
|
||||||
|
|
||||||
namespace eShopOnContainers.Core.Extensions
|
|
||||||
{
|
|
||||||
public static class AnimationExtension
|
|
||||||
{
|
|
||||||
public static async void Animate(this VisualElement visualElement, AnimationBase animation, Action onFinishedCallback = null)
|
|
||||||
{
|
|
||||||
animation.Target = visualElement;
|
|
||||||
|
|
||||||
await animation.Begin();
|
|
||||||
|
|
||||||
onFinishedCallback?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -59,7 +59,7 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand AddCommand => new Command<BasketItem>(AddItem);
|
public ICommand AddCommand => new Command<BasketItem>(async (item) => await AddItemAsync(item));
|
||||||
|
|
||||||
public ICommand CheckoutCommand => new Command(async () => await CheckoutAsync());
|
public ICommand CheckoutCommand => new Command(async () => await CheckoutAsync());
|
||||||
|
|
||||||
@ -80,22 +80,22 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
foreach (var basketItem in basket.Items)
|
foreach (var basketItem in basket.Items)
|
||||||
{
|
{
|
||||||
BadgeCount += basketItem.Quantity;
|
BadgeCount += basketItem.Quantity;
|
||||||
AddBasketItem(basketItem);
|
await AddBasketItemAsync(basketItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagingCenter.Unsubscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct);
|
MessagingCenter.Unsubscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct);
|
||||||
MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct, (sender, arg) =>
|
MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct, async (sender, arg) =>
|
||||||
{
|
{
|
||||||
BadgeCount++;
|
BadgeCount++;
|
||||||
|
|
||||||
AddCatalogItem(arg);
|
await AddCatalogItemAsync(arg);
|
||||||
});
|
});
|
||||||
|
|
||||||
await base.InitializeAsync(navigationData);
|
await base.InitializeAsync(navigationData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddCatalogItem(CatalogItem item)
|
private async Task AddCatalogItemAsync(CatalogItem item)
|
||||||
{
|
{
|
||||||
BasketItems.Add(new BasketItem
|
BasketItems.Add(new BasketItem
|
||||||
{
|
{
|
||||||
@ -106,26 +106,23 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
Quantity = 1
|
Quantity = 1
|
||||||
});
|
});
|
||||||
|
|
||||||
ReCalculateTotal();
|
await ReCalculateTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddItem(BasketItem item)
|
private async Task AddItemAsync(BasketItem item)
|
||||||
{
|
{
|
||||||
BadgeCount++;
|
BadgeCount++;
|
||||||
|
await AddBasketItemAsync(item);
|
||||||
AddBasketItem(item);
|
|
||||||
|
|
||||||
RaisePropertyChanged(() => BasketItems);
|
RaisePropertyChanged(() => BasketItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddBasketItem(BasketItem item)
|
private async Task AddBasketItemAsync(BasketItem item)
|
||||||
{
|
{
|
||||||
BasketItems.Add(item);
|
BasketItems.Add(item);
|
||||||
|
await ReCalculateTotal();
|
||||||
ReCalculateTotal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ReCalculateTotal()
|
private async Task ReCalculateTotal()
|
||||||
{
|
{
|
||||||
Total = 0;
|
Total = 0;
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
|
|
||||||
public ICommand AddCatalogItemCommand => new Command<CatalogItem>(AddCatalogItem);
|
public ICommand AddCatalogItemCommand => new Command<CatalogItem>(AddCatalogItem);
|
||||||
|
|
||||||
public ICommand FilterCommand => new Command(Filter);
|
public ICommand FilterCommand => new Command(async () => await FilterAsync());
|
||||||
|
|
||||||
public ICommand ClearFilterCommand => new Command(ClearFilter);
|
public ICommand ClearFilterCommand => new Command(async () => await ClearFilterAsync());
|
||||||
|
|
||||||
public override async Task InitializeAsync(object navigationData)
|
public override async Task InitializeAsync(object navigationData)
|
||||||
{
|
{
|
||||||
@ -110,7 +110,7 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem);
|
MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Filter()
|
private async Task FilterAsync()
|
||||||
{
|
{
|
||||||
if (Brand == null && Type == null)
|
if (Brand == null && Type == null)
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ClearFilter()
|
private async Task ClearFilterAsync()
|
||||||
{
|
{
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
|
|
||||||
|
@ -60,7 +60,6 @@
|
|||||||
<Compile Include="Converters\ToUpperConverter.cs" />
|
<Compile Include="Converters\ToUpperConverter.cs" />
|
||||||
<Compile Include="Effects\LineColorEffect.cs" />
|
<Compile Include="Effects\LineColorEffect.cs" />
|
||||||
<Compile Include="Exceptions\ServiceAuthenticationException.cs" />
|
<Compile Include="Exceptions\ServiceAuthenticationException.cs" />
|
||||||
<Compile Include="Extensions\AnimationExtension.cs" />
|
|
||||||
<Compile Include="Extensions\ObservableExtension.cs" />
|
<Compile Include="Extensions\ObservableExtension.cs" />
|
||||||
<Compile Include="GlobalSettings.cs" />
|
<Compile Include="GlobalSettings.cs" />
|
||||||
<Compile Include="Helpers\EasingHelper.cs" />
|
<Compile Include="Helpers\EasingHelper.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user