Removed unused code from NavigationService.
This commit is contained in:
parent
33009ceb33
commit
4a073b96d8
@ -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<TViewModel>(object parameter) where TViewModel : ViewModelBase;
|
||||
|
||||
Task NavigateToAsync(Type viewModelType);
|
||||
|
||||
Task NavigateToAsync(Type viewModelType, object parameter);
|
||||
|
||||
Task NavigateBackAsync();
|
||||
|
||||
Task RemoveLastFromBackStackAsync();
|
||||
|
||||
Task RemoveBackStackAsync();
|
||||
|
@ -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)
|
||||
public Task RemoveLastFromBackStackAsync()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user