diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/INavigationService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/INavigationService.cs index 64ef7d807..6a1bbcf6d 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/INavigationService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/INavigationService.cs @@ -1,5 +1,4 @@ using eShopOnContainers.Core.ViewModels.Base; -using System; using System.Threading.Tasks; namespace eShopOnContainers.Services @@ -12,12 +11,6 @@ namespace eShopOnContainers.Services Task NavigateToAsync(object parameter) where TViewModel : ViewModelBase; - Task NavigateToAsync(Type viewModelType); - - Task NavigateToAsync(Type viewModelType, object parameter); - - Task NavigateBackAsync(); - Task RemoveLastFromBackStackAsync(); Task RemoveBackStackAsync(); diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/NavigationService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/NavigationService.cs index 38cdaee8d..4a6c0ef6c 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/NavigationService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Navigation/NavigationService.cs @@ -12,14 +12,6 @@ namespace eShopOnContainers.Services { public class NavigationService : INavigationService { - protected Application CurrentApplication - { - get - { - return Application.Current; - } - } - public Task InitializeAsync() { if(string.IsNullOrEmpty(Settings.AuthAccessToken)) @@ -38,32 +30,9 @@ namespace eShopOnContainers.Services return InternalNavigateToAsync(typeof(TViewModel), parameter); } - public Task NavigateToAsync(Type viewModelType) - { - return InternalNavigateToAsync(viewModelType, null); - } - - public Task NavigateToAsync(Type viewModelType, object parameter) - { - return InternalNavigateToAsync(viewModelType, parameter); - } - - public async Task NavigateBackAsync() - { - if (CurrentApplication.MainPage is CatalogView) - { - var mainPage = CurrentApplication.MainPage as CatalogView; - await mainPage.Navigation.PopAsync(); - } - else if (CurrentApplication.MainPage != null) - { - await CurrentApplication.MainPage.Navigation.PopAsync(); - } - } - - public virtual Task RemoveLastFromBackStackAsync() + public Task RemoveLastFromBackStackAsync() { - var mainPage = CurrentApplication.MainPage as CustomNavigationView; + var mainPage = Application.Current.MainPage as CustomNavigationView; if (mainPage != null) { @@ -74,9 +43,9 @@ namespace eShopOnContainers.Services return Task.FromResult(true); } - public virtual Task RemoveBackStackAsync() + public Task RemoveBackStackAsync() { - var mainPage = CurrentApplication.MainPage as CustomNavigationView; + var mainPage = Application.Current.MainPage as CustomNavigationView; if (mainPage != null) { @@ -90,31 +59,31 @@ namespace eShopOnContainers.Services return Task.FromResult(true); } - protected virtual async Task InternalNavigateToAsync(Type viewModelType, object parameter) + private async Task InternalNavigateToAsync(Type viewModelType, object parameter) { Page page = CreatePage(viewModelType, parameter); if (page is LoginView) { - CurrentApplication.MainPage = new CustomNavigationView(page); + Application.Current.MainPage = new CustomNavigationView(page); } else - { - var navigationPage = CurrentApplication.MainPage as CustomNavigationView; + { + var navigationPage = Application.Current.MainPage as CustomNavigationView; if (navigationPage != null) { await navigationPage.PushAsync(page); } else { - CurrentApplication.MainPage = new CustomNavigationView(page); + Application.Current.MainPage = new CustomNavigationView(page); } } await (page.BindingContext as ViewModelBase).InitializeAsync(parameter); } - protected Type GetPageTypeForViewModel(Type viewModelType) + private Type GetPageTypeForViewModel(Type viewModelType) { var viewName = viewModelType.FullName.Replace("Model", string.Empty); var viewModelAssemblyName = viewModelType.GetTypeInfo().Assembly.FullName; @@ -123,7 +92,7 @@ namespace eShopOnContainers.Services return viewType; } - protected Page CreatePage(Type viewModelType, object parameter) + private Page CreatePage(Type viewModelType, object parameter) { Type pageType = GetPageTypeForViewModel(viewModelType); if (pageType == null) diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs index a1c9352de..592d6b831 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs @@ -2,7 +2,6 @@ using eShopOnContainers.Core.ViewModels.Base; using eShopOnContainers.Core.Models.Navigation; using Xamarin.Forms; -using eShopOnContainers.Core.ViewModels.Base; using System.Windows.Input; namespace eShopOnContainers.Core.ViewModels