Merge pull request #114 from dotnet/revert-85-xamarin
Revert "ViewModelLocator now connects view models to views, rather than NavigationService."
This commit is contained in:
commit
4818f68902
@ -1,6 +1,6 @@
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Services;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
@ -28,13 +28,12 @@ namespace eShopOnContainers
|
||||
{
|
||||
UseMockServices = Settings.UseMocks;
|
||||
|
||||
ViewModelLocator.Initialize();
|
||||
ViewModelLocator.UpdateDependencies(UseMockServices);
|
||||
ViewModelLocator.Instance.UpdateDependencies(UseMockServices);
|
||||
}
|
||||
|
||||
private Task InitNavigation()
|
||||
{
|
||||
var navigationService = ViewModelLocator.Resolve<INavigationService>();
|
||||
var navigationService = ViewModelLocator.Instance.Resolve<INavigationService>();
|
||||
return navigationService.InitializeAsync();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using eShopOnContainers.Core.Models.Basket;
|
||||
using eShopOnContainers.Core.Models.Catalog;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -21,7 +21,7 @@ namespace eShopOnContainers.Core.Helpers
|
||||
|
||||
try
|
||||
{
|
||||
if (!ViewModelLocator.UseMockService
|
||||
if (!ViewModelLocator.Instance.UseMockService
|
||||
&& Settings.UrlBase != GlobalSetting.DefaultEndpoint)
|
||||
{
|
||||
foreach (var catalogItem in catalogItems)
|
||||
@ -54,7 +54,7 @@ namespace eShopOnContainers.Core.Helpers
|
||||
|
||||
try
|
||||
{
|
||||
if (!ViewModelLocator.UseMockService
|
||||
if (!ViewModelLocator.Instance.UseMockService
|
||||
&& Settings.UrlBase != GlobalSetting.DefaultEndpoint)
|
||||
{
|
||||
foreach (var basketItem in basketItems)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using Plugin.Settings;
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
@ -27,7 +27,7 @@ namespace eShopOnContainers.Core.Helpers
|
||||
private const string IdUrlBase = "url_base";
|
||||
private static readonly string AccessTokenDefault = string.Empty;
|
||||
private static readonly string IdTokenDefault = string.Empty;
|
||||
private static readonly bool UseMocksDefault = ViewModelLocator.UseMockService;
|
||||
private static readonly bool UseMocksDefault = ViewModelLocator.Instance.UseMockService;
|
||||
private static readonly string UrlBaseDefault = GlobalSetting.Instance.BaseEndpoint;
|
||||
|
||||
#endregion
|
||||
|
@ -1,4 +1,4 @@
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Core.ViewModels;
|
||||
using eShopOnContainers.Core.Views;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
@ -12,7 +11,9 @@ namespace eShopOnContainers.Services
|
||||
{
|
||||
public class NavigationService : INavigationService
|
||||
{
|
||||
protected Application CurrentApplication
|
||||
protected readonly Dictionary<Type, Type> _mappings;
|
||||
|
||||
protected Application CurrentApplication
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -20,6 +21,13 @@ namespace eShopOnContainers.Services
|
||||
}
|
||||
}
|
||||
|
||||
public NavigationService()
|
||||
{
|
||||
_mappings = new Dictionary<Type, Type>();
|
||||
|
||||
CreatePageViewModelMappings();
|
||||
}
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
if(string.IsNullOrEmpty(Settings.AuthAccessToken))
|
||||
@ -92,7 +100,7 @@ namespace eShopOnContainers.Services
|
||||
|
||||
protected virtual async Task InternalNavigateToAsync(Type viewModelType, object parameter)
|
||||
{
|
||||
Page page = CreatePage(viewModelType, parameter);
|
||||
Page page = CreateAndBindPage(viewModelType, parameter);
|
||||
|
||||
if (page is LoginView)
|
||||
{
|
||||
@ -101,6 +109,7 @@ namespace eShopOnContainers.Services
|
||||
else
|
||||
{
|
||||
var navigationPage = CurrentApplication.MainPage as CustomNavigationView;
|
||||
|
||||
if (navigationPage != null)
|
||||
{
|
||||
await navigationPage.PushAsync(page);
|
||||
@ -116,23 +125,40 @@ namespace eShopOnContainers.Services
|
||||
|
||||
protected Type GetPageTypeForViewModel(Type viewModelType)
|
||||
{
|
||||
var viewName = viewModelType.FullName.Replace("Model", string.Empty);
|
||||
var viewModelAssemblyName = viewModelType.GetTypeInfo().Assembly.FullName;
|
||||
var viewAssemblyName = string.Format(CultureInfo.InvariantCulture, "{0}, {1}", viewName, viewModelAssemblyName);
|
||||
var viewType = Type.GetType(viewAssemblyName);
|
||||
return viewType;
|
||||
if (!_mappings.ContainsKey(viewModelType))
|
||||
{
|
||||
throw new KeyNotFoundException($"No map for ${viewModelType} was found on navigation mappings");
|
||||
}
|
||||
|
||||
return _mappings[viewModelType];
|
||||
}
|
||||
|
||||
protected Page CreatePage(Type viewModelType, object parameter)
|
||||
protected Page CreateAndBindPage(Type viewModelType, object parameter)
|
||||
{
|
||||
Type pageType = GetPageTypeForViewModel(viewModelType);
|
||||
|
||||
if (pageType == null)
|
||||
{
|
||||
throw new Exception($"Cannot locate page type for {viewModelType}");
|
||||
throw new Exception($"Mapping type for {viewModelType} is not a page");
|
||||
}
|
||||
|
||||
Page page = Activator.CreateInstance(pageType) as Page;
|
||||
ViewModelBase viewModel = ViewModelLocator.Instance.Resolve(viewModelType) as ViewModelBase;
|
||||
page.BindingContext = viewModel;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
private void CreatePageViewModelMappings()
|
||||
{
|
||||
_mappings.Add(typeof(BasketViewModel), typeof(BasketView));
|
||||
_mappings.Add(typeof(CatalogViewModel), typeof(CatalogView));
|
||||
_mappings.Add(typeof(CheckoutViewModel), typeof(CheckoutView));
|
||||
_mappings.Add(typeof(LoginViewModel), typeof(LoginView));
|
||||
_mappings.Add(typeof(MainViewModel), typeof(MainView));
|
||||
_mappings.Add(typeof(OrderDetailViewModel), typeof(OrderDetailView));
|
||||
_mappings.Add(typeof(ProfileViewModel), typeof(ProfileView));
|
||||
_mappings.Add(typeof(SettingsViewModel), typeof(SettingsView));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
@ -3,7 +3,7 @@ using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels.Base
|
||||
namespace eShopOnContainers.ViewModels.Base
|
||||
{
|
||||
public abstract class ExtendedBindableObject : BindableObject
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Core;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Services;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels.Base
|
||||
namespace eShopOnContainers.ViewModels.Base
|
||||
{
|
||||
public abstract class ViewModelBase : ExtendedBindableObject
|
||||
{
|
||||
@ -27,14 +28,14 @@ namespace eShopOnContainers.Core.ViewModels.Base
|
||||
|
||||
public ViewModelBase()
|
||||
{
|
||||
DialogService = ViewModelLocator.Resolve<IDialogService>();
|
||||
NavigationService = ViewModelLocator.Resolve<INavigationService>();
|
||||
DialogService = ViewModelLocator.Instance.Resolve<IDialogService>();
|
||||
NavigationService = ViewModelLocator.Instance.Resolve<INavigationService>();
|
||||
GlobalSetting.Instance.BaseEndpoint = Settings.UrlBase;
|
||||
}
|
||||
|
||||
public virtual Task InitializeAsync(object navigationData)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
using Microsoft.Practices.Unity;
|
||||
using eShopOnContainers.Core.ViewModels;
|
||||
using eShopOnContainers.Services;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using eShopOnContainers.Core.Services.Catalog;
|
||||
using eShopOnContainers.Core.Services.OpenUrl;
|
||||
using eShopOnContainers.Core.Services.RequestProvider;
|
||||
@ -10,53 +9,54 @@ using eShopOnContainers.Core.Services.Basket;
|
||||
using eShopOnContainers.Core.Services.Identity;
|
||||
using eShopOnContainers.Core.Services.Order;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels.Base
|
||||
namespace eShopOnContainers.ViewModels.Base
|
||||
{
|
||||
public static class ViewModelLocator
|
||||
public class ViewModelLocator
|
||||
{
|
||||
private static readonly IUnityContainer _unityContainer = new UnityContainer();
|
||||
private bool _useMockService;
|
||||
private readonly IUnityContainer _unityContainer;
|
||||
|
||||
public static readonly BindableProperty AutoWireViewModelProperty =
|
||||
BindableProperty.CreateAttached("AutoWireViewModel", typeof(bool), typeof(ViewModelLocator), default(bool), propertyChanged: OnAutoWireViewModelChanged);
|
||||
private static readonly ViewModelLocator _instance = new ViewModelLocator();
|
||||
|
||||
public static bool GetAutoWireViewModel(BindableObject bindable)
|
||||
{
|
||||
return (bool)bindable.GetValue(ViewModelLocator.AutoWireViewModelProperty);
|
||||
}
|
||||
public static ViewModelLocator Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public static void SetAutoWireViewModel(BindableObject bindable, bool value)
|
||||
{
|
||||
bindable.SetValue(ViewModelLocator.AutoWireViewModelProperty, value);
|
||||
}
|
||||
public bool UseMockService
|
||||
{
|
||||
get { return _useMockService; }
|
||||
set { _useMockService = value; ; }
|
||||
}
|
||||
|
||||
public static bool UseMockService { get; set; }
|
||||
protected ViewModelLocator()
|
||||
{
|
||||
_unityContainer = new UnityContainer();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
// Services
|
||||
_unityContainer.RegisterType<IDialogService, DialogService>();
|
||||
_unityContainer.RegisterType<INavigationService, NavigationService>(new ContainerControlledLifetimeManager());
|
||||
_unityContainer.RegisterType<IOpenUrlService, OpenUrlService>();
|
||||
_unityContainer.RegisterType<IRequestProvider, RequestProvider>();
|
||||
_unityContainer.RegisterType<IIdentityService, IdentityService>();
|
||||
_unityContainer.RegisterType<ICatalogService, CatalogMockService>();
|
||||
_unityContainer.RegisterType<IBasketService, BasketMockService>();
|
||||
_unityContainer.RegisterType<IUserService, UserMockService>();
|
||||
// Services
|
||||
_unityContainer.RegisterType<IDialogService, DialogService>();
|
||||
RegisterSingleton<INavigationService, NavigationService>();
|
||||
_unityContainer.RegisterType<IOpenUrlService, OpenUrlService>();
|
||||
_unityContainer.RegisterType<IRequestProvider, RequestProvider>();
|
||||
_unityContainer.RegisterType<IIdentityService, IdentityService>();
|
||||
|
||||
// View models
|
||||
_unityContainer.RegisterType<BasketViewModel>();
|
||||
_unityContainer.RegisterType<CatalogViewModel>();
|
||||
_unityContainer.RegisterType<CheckoutViewModel>();
|
||||
_unityContainer.RegisterType<LoginViewModel>();
|
||||
_unityContainer.RegisterType<MainViewModel>();
|
||||
_unityContainer.RegisterType<OrderDetailViewModel>();
|
||||
_unityContainer.RegisterType<ProfileViewModel>();
|
||||
_unityContainer.RegisterType<SettingsViewModel>();
|
||||
}
|
||||
_unityContainer.RegisterType<ICatalogService, CatalogMockService>();
|
||||
_unityContainer.RegisterType<IBasketService, BasketMockService>();
|
||||
_unityContainer.RegisterType<IUserService, UserMockService>();
|
||||
|
||||
public static void UpdateDependencies(bool useMockServices)
|
||||
// View models
|
||||
_unityContainer.RegisterType<BasketViewModel>();
|
||||
_unityContainer.RegisterType<CatalogViewModel>();
|
||||
_unityContainer.RegisterType<CheckoutViewModel>();
|
||||
_unityContainer.RegisterType<LoginViewModel>();
|
||||
_unityContainer.RegisterType<MainViewModel>();
|
||||
_unityContainer.RegisterType<OrderDetailViewModel>();
|
||||
_unityContainer.RegisterType<ProfileViewModel>();
|
||||
_unityContainer.RegisterType<SettingsViewModel>();
|
||||
}
|
||||
|
||||
public void UpdateDependencies(bool useMockServices)
|
||||
{
|
||||
// Change injected dependencies
|
||||
if (useMockServices)
|
||||
@ -80,31 +80,29 @@ namespace eShopOnContainers.Core.ViewModels.Base
|
||||
}
|
||||
}
|
||||
|
||||
public static T Resolve<T>()
|
||||
public T Resolve<T>()
|
||||
{
|
||||
return _unityContainer.Resolve<T>();
|
||||
}
|
||||
|
||||
private static void OnAutoWireViewModelChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
var view = bindable as Element;
|
||||
if (view == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public object Resolve(Type type)
|
||||
{
|
||||
return _unityContainer.Resolve(type);
|
||||
}
|
||||
|
||||
var viewType = view.GetType();
|
||||
var viewName = viewType.FullName.Replace(".Views.", ".ViewModels.");
|
||||
var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName;
|
||||
var viewModelName = string.Format(CultureInfo.InvariantCulture, "{0}Model, {1}", viewName, viewAssemblyName);
|
||||
public void Register<T>(T instance)
|
||||
{
|
||||
_unityContainer.RegisterInstance<T>(instance);
|
||||
}
|
||||
|
||||
var viewModelType = Type.GetType(viewModelName);
|
||||
if (viewModelType == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var viewModel = _unityContainer.Resolve(viewModelType);
|
||||
view.BindingContext = viewModel;
|
||||
}
|
||||
public void Register<TInterface, T>() where T : TInterface
|
||||
{
|
||||
_unityContainer.RegisterType<TInterface, T>();
|
||||
}
|
||||
|
||||
public void RegisterSingleton<TInterface, T>() where T : TInterface
|
||||
{
|
||||
_unityContainer.RegisterType<TInterface, T>(new ContainerControlledLifetimeManager());
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ using eShopOnContainers.Core.Models.Catalog;
|
||||
using eShopOnContainers.Core.Services.Basket;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -59,7 +61,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand AddCommand => new Command<BasketItem>(async (item) => await AddItemAsync(item));
|
||||
public ICommand AddCommand => new Command<BasketItem>(AddItem);
|
||||
|
||||
public ICommand CheckoutCommand => new Command(async () => await CheckoutAsync());
|
||||
|
||||
@ -80,22 +82,22 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
foreach (var basketItem in basket.Items)
|
||||
{
|
||||
BadgeCount += basketItem.Quantity;
|
||||
await AddBasketItemAsync(basketItem);
|
||||
AddBasketItem(basketItem);
|
||||
}
|
||||
}
|
||||
|
||||
MessagingCenter.Unsubscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct);
|
||||
MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct, async (sender, arg) =>
|
||||
MessagingCenter.Subscribe<CatalogViewModel, CatalogItem>(this, MessengerKeys.AddProduct, (sender, arg) =>
|
||||
{
|
||||
BadgeCount++;
|
||||
|
||||
await AddCatalogItemAsync(arg);
|
||||
AddCatalogItem(arg);
|
||||
});
|
||||
|
||||
await base.InitializeAsync(navigationData);
|
||||
}
|
||||
|
||||
private async Task AddCatalogItemAsync(CatalogItem item)
|
||||
private void AddCatalogItem(CatalogItem item)
|
||||
{
|
||||
BasketItems.Add(new BasketItem
|
||||
{
|
||||
@ -106,23 +108,26 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
Quantity = 1
|
||||
});
|
||||
|
||||
await ReCalculateTotal();
|
||||
ReCalculateTotal();
|
||||
}
|
||||
|
||||
private async Task AddItemAsync(BasketItem item)
|
||||
private void AddItem(BasketItem item)
|
||||
{
|
||||
BadgeCount++;
|
||||
await AddBasketItemAsync(item);
|
||||
|
||||
AddBasketItem(item);
|
||||
|
||||
RaisePropertyChanged(() => BasketItems);
|
||||
}
|
||||
|
||||
private async Task AddBasketItemAsync(BasketItem item)
|
||||
private void AddBasketItem(BasketItem item)
|
||||
{
|
||||
BasketItems.Add(item);
|
||||
await ReCalculateTotal();
|
||||
|
||||
ReCalculateTotal();
|
||||
}
|
||||
|
||||
private async Task ReCalculateTotal()
|
||||
private async void ReCalculateTotal()
|
||||
{
|
||||
Total = 0;
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
using System.Threading.Tasks;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Collections.ObjectModel;
|
||||
using Xamarin.Forms;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.Core.Models.Catalog;
|
||||
using eShopOnContainers.Core.Services.Catalog;
|
||||
using System.Windows.Input;
|
||||
using System.Linq;
|
||||
using eShopOnContainers.Core.Services.Basket;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels
|
||||
@ -88,9 +91,9 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
public ICommand AddCatalogItemCommand => new Command<CatalogItem>(AddCatalogItem);
|
||||
|
||||
public ICommand FilterCommand => new Command(async () => await FilterAsync());
|
||||
public ICommand FilterCommand => new Command(Filter);
|
||||
|
||||
public ICommand ClearFilterCommand => new Command(async () => await ClearFilterAsync());
|
||||
public ICommand ClearFilterCommand => new Command(ClearFilter);
|
||||
|
||||
public override async Task InitializeAsync(object navigationData)
|
||||
{
|
||||
@ -110,7 +113,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem);
|
||||
}
|
||||
|
||||
private async Task FilterAsync()
|
||||
private async void Filter()
|
||||
{
|
||||
if (Brand == null && Type == null)
|
||||
{
|
||||
@ -126,7 +129,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
IsBusy = false;
|
||||
}
|
||||
|
||||
private async Task ClearFilterAsync()
|
||||
private async void ClearFilter()
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
using eShopOnContainers.Core.Models.Navigation;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
using System.Threading.Tasks;
|
||||
@ -138,7 +138,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
await _basketService.ClearBasketAsync(_shippingAddress.Id.ToString(), authToken);
|
||||
|
||||
// Reset Basket badge
|
||||
var basketViewModel = ViewModelLocator.Resolve<BasketViewModel>();
|
||||
var basketViewModel = ViewModelLocator.Instance.Resolve<BasketViewModel>();
|
||||
basketViewModel.BadgeCount = 0;
|
||||
|
||||
// Navigate to Orders
|
||||
|
@ -4,7 +4,7 @@ using eShopOnContainers.Core.Services.Identity;
|
||||
using eShopOnContainers.Core.Services.OpenUrl;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
using eShopOnContainers.Core.Validations;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using IdentityModel.Client;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
@ -133,9 +133,10 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
public override Task InitializeAsync(object navigationData)
|
||||
{
|
||||
if (navigationData is LogoutParameter)
|
||||
if(navigationData is LogoutParameter)
|
||||
{
|
||||
var logoutParameter = (LogoutParameter)navigationData;
|
||||
|
||||
if (logoutParameter.Logout)
|
||||
{
|
||||
Logout();
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using eShopOnContainers.Core.Models.Navigation;
|
||||
using Xamarin.Forms;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using eShopOnContainers.Core.Models.Orders;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using eShopOnContainers.Core.Services.Catalog;
|
||||
using eShopOnContainers.Core.Services.Basket;
|
||||
using eShopOnContainers.Core.Services.Order;
|
||||
|
@ -3,7 +3,7 @@ using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Core.Models.Orders;
|
||||
using eShopOnContainers.Core.Models.User;
|
||||
using eShopOnContainers.Core.Services.Order;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
using System.Threading.Tasks;
|
||||
@ -71,7 +71,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
private void MockServices()
|
||||
{
|
||||
ViewModelLocator.UpdateDependencies(!UseAzureServices);
|
||||
ViewModelLocator.Instance.UpdateDependencies(!UseAzureServices);
|
||||
UpdateInfo();
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.BasketView"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
x:Class="eShopOnContainers.Core.Views.BasketView"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
Title="Cart">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.CatalogView"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
|
||||
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
|
||||
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
Title="Catalog">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -47,8 +47,7 @@ namespace eShopOnContainers.Core.Views
|
||||
{
|
||||
base.OnBindingContextChanged();
|
||||
|
||||
if (_filterView != null)
|
||||
_filterView.BindingContext = BindingContext;
|
||||
_filterView.BindingContext = BindingContext;
|
||||
}
|
||||
|
||||
private void OnFilterChanged(object sender, EventArgs e)
|
||||
|
@ -1,10 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.CheckoutView"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
Title="Checkout">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -2,11 +2,9 @@
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.LoginView"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
|
||||
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true">
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core">
|
||||
<ContentPage.Title>
|
||||
<OnPlatform
|
||||
x:TypeArguments="x:String"
|
||||
|
@ -1,14 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.MainView"
|
||||
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core"
|
||||
BarBackgroundColor="{StaticResource DarkGreenColor}"
|
||||
BackgroundColor="{StaticResource BackgroundColor}"
|
||||
BarTextColor="{StaticResource WhiteColor}"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true">
|
||||
BarTextColor="{StaticResource WhiteColor}">
|
||||
<TabbedPage.Title>
|
||||
<OnPlatform
|
||||
x:TypeArguments="x:String"
|
||||
|
@ -1,5 +1,6 @@
|
||||
using eShopOnContainers.Core.ViewModels;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace eShopOnContainers.Core.Views
|
||||
@ -31,9 +32,17 @@ namespace eShopOnContainers.Core.Views
|
||||
}
|
||||
});
|
||||
|
||||
await ((CatalogViewModel)HomeView.BindingContext).InitializeAsync(null);
|
||||
await ((BasketViewModel)BasketView.BindingContext).InitializeAsync(null);
|
||||
await ((ProfileViewModel)ProfileView.BindingContext).InitializeAsync(null);
|
||||
var homeViewModel = ViewModelLocator.Instance.Resolve<CatalogViewModel>();
|
||||
await homeViewModel.InitializeAsync(null);
|
||||
HomeView.BindingContext = homeViewModel;
|
||||
|
||||
var basketViewModel = ViewModelLocator.Instance.Resolve<BasketViewModel>();
|
||||
await basketViewModel.InitializeAsync(null);
|
||||
BasketView.BindingContext = basketViewModel;
|
||||
|
||||
var profileViewModel = ViewModelLocator.Instance.Resolve<ProfileViewModel>();
|
||||
await profileViewModel.InitializeAsync(null);
|
||||
ProfileView.BindingContext = profileViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.OrderDetailView"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
x:Class="eShopOnContainers.Core.Views.OrderDetailView"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
|
||||
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
Title="{Binding Order.OrderNumber}">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.ProfileView"
|
||||
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
xmlns:views="clr-namespace:eShopOnContainers.Core.Views;assembly=eShopOnContainers.Core"
|
||||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
Title="My profile">
|
||||
Title="My profile">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="eShopOnContainers.Core.Views.SettingsView"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
x:Class="eShopOnContainers.Core.Views.SettingsView"
|
||||
xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core"
|
||||
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
|
||||
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"
|
||||
Title="Settings">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
@ -60,6 +60,7 @@
|
||||
<Compile Include="Converters\ToUpperConverter.cs" />
|
||||
<Compile Include="Effects\LineColorEffect.cs" />
|
||||
<Compile Include="Exceptions\ServiceAuthenticationException.cs" />
|
||||
<Compile Include="Extensions\AnimationExtension.cs" />
|
||||
<Compile Include="Extensions\ObservableExtension.cs" />
|
||||
<Compile Include="GlobalSettings.cs" />
|
||||
<Compile Include="Helpers\EasingHelper.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user