Merge branch 'master' of https://github.com/dotnet/eShopOnContainers
This commit is contained in:
commit
afc5dffc2a
@ -1,4 +1,5 @@
|
||||
using eShopOnContainers.Services;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Services;
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
@ -25,7 +26,7 @@ namespace eShopOnContainers
|
||||
|
||||
private void InitApp()
|
||||
{
|
||||
UseMockServices = true;
|
||||
UseMockServices = Settings.UseMocks;
|
||||
|
||||
ViewModelLocator.Instance.UpdateDependencies(UseMockServices);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
public GlobalSetting()
|
||||
{
|
||||
AuthToken = "INSERT AUTHENTICATION TOKEN";
|
||||
BaseEndpoint = "http://10.106.144.28";
|
||||
BaseEndpoint = "http://13.88.8.119";
|
||||
}
|
||||
|
||||
public static GlobalSetting Instance
|
||||
|
@ -1,3 +1,4 @@
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using Plugin.Settings;
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
@ -22,8 +23,12 @@ namespace eShopOnContainers.Core.Helpers
|
||||
|
||||
private const string AccessToken = "access_token";
|
||||
private const string IdToken = "id_token";
|
||||
private const string IdUseMocks = "use_mocks";
|
||||
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.Instance.UseMockService;
|
||||
private static readonly string UrlBaseDefault = GlobalSetting.Instance.BaseEndpoint;
|
||||
|
||||
#endregion
|
||||
|
||||
@ -51,5 +56,30 @@ namespace eShopOnContainers.Core.Helpers
|
||||
AppSettings.AddOrUpdateValue<string>(IdToken, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool UseMocks
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppSettings.GetValueOrDefault<bool>(IdUseMocks, UseMocksDefault);
|
||||
}
|
||||
set
|
||||
{
|
||||
AppSettings.AddOrUpdateValue<bool>(IdUseMocks, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static string UrlBase
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppSettings.GetValueOrDefault<string>(IdUrlBase, UrlBaseDefault);
|
||||
}
|
||||
set
|
||||
{
|
||||
AppSettings.AddOrUpdateValue<string>(IdUrlBase, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,13 +9,6 @@ using eShopOnContainers.Core.Services.Basket;
|
||||
using eShopOnContainers.Core.Services.Identity;
|
||||
using eShopOnContainers.Core.Services.Order;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
using Xamarin.Forms;
|
||||
using System.Collections.Generic;
|
||||
using eShopOnContainers.Core.Models.Basket;
|
||||
using eShopOnContainers.Core.Models.Catalog;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using eShopOnContainers.Core;
|
||||
|
||||
namespace eShopOnContainers.ViewModels.Base
|
||||
{
|
||||
|
@ -9,7 +9,6 @@ using System.Windows.Input;
|
||||
using System.Linq;
|
||||
using eShopOnContainers.Core.Services.Basket;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using System;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels
|
||||
@ -121,6 +120,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
private void AddCatalogItem(CatalogItem catalogItem)
|
||||
{
|
||||
// Add new item to Basket
|
||||
MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
IsBusy = true;
|
||||
|
||||
// Filter
|
||||
// Filter catalog products
|
||||
MessagingCenter.Send(this, MessengerKeys.Filter);
|
||||
Products = await _productsService.FilterAsync(Brand.Id, Type.Id);
|
||||
|
||||
|
@ -4,7 +4,6 @@ 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;
|
||||
@ -40,8 +39,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
_userName = new ValidatableObject<string>();
|
||||
_password = new ValidatableObject<string>();
|
||||
|
||||
IsMock = ViewModelLocator.Instance.UseMockService;
|
||||
|
||||
InvalidateMock();
|
||||
AddValidations();
|
||||
}
|
||||
|
||||
@ -214,7 +212,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
LoginUrl = logoutRequest;
|
||||
}
|
||||
|
||||
if(ViewModelLocator.Instance.UseMockService)
|
||||
if(Settings.UseMocks)
|
||||
{
|
||||
Settings.AuthAccessToken = string.Empty;
|
||||
Settings.AuthIdToken = string.Empty;
|
||||
@ -266,5 +264,10 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
_userName.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Username should not be empty" });
|
||||
_password.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Password should not be empty" });
|
||||
}
|
||||
|
||||
public void InvalidateMock()
|
||||
{
|
||||
IsMock = Settings.UseMocks;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,14 +3,11 @@ using eShopOnContainers.ViewModels.Base;
|
||||
using eShopOnContainers.Core.Models.Navigation;
|
||||
using Xamarin.Forms;
|
||||
using eShopOnContainers.Core.ViewModels.Base;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
public ICommand SettingsCommand => new Command(Settings);
|
||||
|
||||
public override Task InitializeAsync(object navigationData)
|
||||
{
|
||||
IsBusy = true;
|
||||
@ -24,10 +21,5 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
return base.InitializeAsync(navigationData);
|
||||
}
|
||||
|
||||
private void Settings()
|
||||
{
|
||||
NavigationService.NavigateToAsync<SettingsViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
using System.Threading.Tasks;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels
|
||||
{
|
||||
@ -14,7 +15,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
UseAzureServices = !ViewModelLocator.Instance.UseMockService;
|
||||
UseAzureServices = !Settings.UseMocks;
|
||||
}
|
||||
|
||||
public string Title
|
||||
@ -43,6 +44,9 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
set
|
||||
{
|
||||
_useAzureServices = value;
|
||||
|
||||
// Save use mocks services to local storage
|
||||
Settings.UseMocks = !_useAzureServices;
|
||||
RaisePropertyChanged(() => UseAzureServices);
|
||||
}
|
||||
}
|
||||
@ -75,7 +79,7 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
{
|
||||
UpdateInfo();
|
||||
|
||||
Endpoint = GlobalSetting.Instance.BaseEndpoint;
|
||||
Endpoint = Settings.UrlBase;
|
||||
|
||||
return base.InitializeAsync(navigationData);
|
||||
}
|
||||
@ -89,15 +93,15 @@ namespace eShopOnContainers.Core.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
Title = "Use Azure Services";
|
||||
Description = "Azure Services are real objects that required a valid internet connection";
|
||||
Title = "Use Microservices/Containers from eShopOnContainers";
|
||||
Description = "When enabling the use of microservices/containers the Xamarin.Forms app will try to use real services deployed as Docker containers in the specified base IP that will need to be reachable through the network";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEndpoint(string endpoint)
|
||||
{
|
||||
// Update remote endpoint
|
||||
GlobalSetting.Instance.BaseEndpoint = endpoint;
|
||||
// Update remote endpoint (save to local storage)
|
||||
Settings.UrlBase = endpoint;
|
||||
}
|
||||
}
|
||||
}
|
@ -65,12 +65,25 @@
|
||||
</Style>
|
||||
|
||||
<Style x:Key="RegisterPanelStyle"
|
||||
TargetType="{x:Type Grid}"
|
||||
BasedOn="{StaticResource LoginPanelStyle}">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="{StaticResource GreenColor}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SettingsPanelStyle"
|
||||
TargetType="{x:Type Grid}"
|
||||
BasedOn="{StaticResource LoginPanelStyle}">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="{StaticResource BlackColor}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SettingsImageStyle"
|
||||
TargetType="{x:Type Image}">
|
||||
<Setter Property="Margin"
|
||||
Value="12" />
|
||||
</Style>
|
||||
|
||||
<animations:StoryBoard
|
||||
x:Key="LoginAnimation"
|
||||
Target="{x:Reference LoginPanel}">
|
||||
@ -103,13 +116,14 @@
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="60" />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- LOGIN / REGISTER -->
|
||||
<!-- LOGIN / REGISTER / SETTINGS -->
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Margin="48, 24">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackLayout
|
||||
Grid.Column="0"
|
||||
@ -137,6 +151,18 @@
|
||||
NumberOfTapsRequired="1" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
<StackLayout
|
||||
Grid.Column="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalOptions="Center">
|
||||
<Label
|
||||
Text="SETTINGS"/>
|
||||
<StackLayout.GestureRecognizers>
|
||||
<TapGestureRecognizer
|
||||
Command="{Binding SettingsCommand}"
|
||||
NumberOfTapsRequired="1" />
|
||||
</StackLayout.GestureRecognizers>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
<!-- INFO -->
|
||||
<Label
|
||||
@ -203,13 +229,14 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="64" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- BANNER -->
|
||||
<Image
|
||||
x:Name="Banner"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Aspect="AspectFill">
|
||||
<Image.Source>
|
||||
<OnPlatform
|
||||
@ -222,7 +249,7 @@
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.ColumnSpan="3"
|
||||
BackgroundColor="{StaticResource BlackColor}"
|
||||
Opacity="0.5"/>
|
||||
<!-- LOG IN BUTTON -->
|
||||
@ -253,10 +280,31 @@
|
||||
NumberOfTapsRequired="1" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
<!-- SETTINGS -->
|
||||
<Grid
|
||||
Grid.Column="2"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource SettingsPanelStyle}">
|
||||
<Image
|
||||
Style="{StaticResource SettingsImageStyle}">
|
||||
<Image.Source>
|
||||
<OnPlatform
|
||||
x:TypeArguments="ImageSource"
|
||||
WinPhone="Assets/app_settings.png"
|
||||
Android="app_settings"
|
||||
iOS="app_settings"/>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<Grid.GestureRecognizers>
|
||||
<TapGestureRecognizer
|
||||
Command="{Binding SettingsCommand}"
|
||||
NumberOfTapsRequired="1" />
|
||||
</Grid.GestureRecognizers>
|
||||
</Grid>
|
||||
<!-- WEBVIEW -->
|
||||
<AbsoluteLayout
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
IsVisible="{Binding IsLogin}">
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using eShopOnContainers.Core.ViewModels;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
@ -22,6 +23,13 @@ namespace eShopOnContainers.Core.Views
|
||||
|
||||
_animate = true;
|
||||
await AnimateIn();
|
||||
|
||||
var vm = BindingContext as LoginViewModel;
|
||||
|
||||
if(vm != null)
|
||||
{
|
||||
vm.InvalidateMock();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
|
@ -13,19 +13,6 @@
|
||||
iOS="eShop on Containers"
|
||||
WinPhone="eShop on Containers"/>
|
||||
</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 -->
|
||||
<views:CatalogView
|
||||
x:Name="HomeView">
|
||||
|
@ -16,7 +16,7 @@
|
||||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
|
||||
<AndroidStoreUncompressedFileExtensions />
|
||||
|
@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTitle("eShopOnContainers.UWP")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("eShopOnContainers.UWP")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyCopyright("Copyright Microsoft © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user