Recover Settings access inside Xamarin App
This commit is contained in:
parent
f696ea6f5a
commit
f2bd7e4cb6
@ -1,4 +1,6 @@
|
|||||||
using eShopOnContainers.Services;
|
using eShopOnContainers.Core;
|
||||||
|
using eShopOnContainers.Core.Helpers;
|
||||||
|
using eShopOnContainers.Services;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace eShopOnContainers.ViewModels.Base
|
namespace eShopOnContainers.ViewModels.Base
|
||||||
@ -28,6 +30,7 @@ namespace eShopOnContainers.ViewModels.Base
|
|||||||
{
|
{
|
||||||
DialogService = ViewModelLocator.Instance.Resolve<IDialogService>();
|
DialogService = ViewModelLocator.Instance.Resolve<IDialogService>();
|
||||||
NavigationService = ViewModelLocator.Instance.Resolve<INavigationService>();
|
NavigationService = ViewModelLocator.Instance.Resolve<INavigationService>();
|
||||||
|
GlobalSetting.Instance.BaseEndpoint = Settings.UrlBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task InitializeAsync(object navigationData)
|
public virtual Task InitializeAsync(object navigationData)
|
||||||
|
@ -3,11 +3,14 @@ using eShopOnContainers.ViewModels.Base;
|
|||||||
using eShopOnContainers.Core.Models.Navigation;
|
using eShopOnContainers.Core.Models.Navigation;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using eShopOnContainers.Core.ViewModels.Base;
|
using eShopOnContainers.Core.ViewModels.Base;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace eShopOnContainers.Core.ViewModels
|
namespace eShopOnContainers.Core.ViewModels
|
||||||
{
|
{
|
||||||
public class MainViewModel : ViewModelBase
|
public class MainViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
public ICommand SettingsCommand => new Command(Settings);
|
||||||
|
|
||||||
public override Task InitializeAsync(object navigationData)
|
public override Task InitializeAsync(object navigationData)
|
||||||
{
|
{
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
@ -21,5 +24,10 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
|
|
||||||
return base.InitializeAsync(navigationData);
|
return base.InitializeAsync(navigationData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Settings()
|
||||||
|
{
|
||||||
|
NavigationService.NavigateToAsync<SettingsViewModel>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -102,7 +102,6 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
{
|
{
|
||||||
// Update remote endpoint (save to local storage)
|
// Update remote endpoint (save to local storage)
|
||||||
Settings.UrlBase = endpoint;
|
Settings.UrlBase = endpoint;
|
||||||
GlobalSetting.Instance.BaseEndpoint = Settings.UrlBase;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,8 +18,6 @@ namespace eShopOnContainers.Core.Views
|
|||||||
|
|
||||||
protected override async void OnAppearing()
|
protected override async void OnAppearing()
|
||||||
{
|
{
|
||||||
GlobalSetting.Instance.BaseEndpoint = Settings.UrlBase;
|
|
||||||
|
|
||||||
var content = this.Content;
|
var content = this.Content;
|
||||||
this.Content = null;
|
this.Content = null;
|
||||||
this.Content = content;
|
this.Content = content;
|
||||||
|
@ -13,6 +13,19 @@
|
|||||||
iOS="eShop on Containers"
|
iOS="eShop on Containers"
|
||||||
WinPhone="eShop on Containers"/>
|
WinPhone="eShop on Containers"/>
|
||||||
</TabbedPage.Title>
|
</TabbedPage.Title>
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<ToolbarItem
|
||||||
|
Command="{Binding SettingsCommand}"
|
||||||
|
Text="Settings">
|
||||||
|
<ToolbarItem.Icon>
|
||||||
|
<OnPlatform
|
||||||
|
x:TypeArguments="FileImageSource"
|
||||||
|
WinPhone="Assets/app_settings.png"
|
||||||
|
Android="app_settings"
|
||||||
|
iOS="app_settings"/>
|
||||||
|
</ToolbarItem.Icon>
|
||||||
|
</ToolbarItem>
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
<!-- CATALOG -->
|
<!-- CATALOG -->
|
||||||
<views:CatalogView
|
<views:CatalogView
|
||||||
x:Name="HomeView">
|
x:Name="HomeView">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user