Added Setting access from Login View (Xamarin)

This commit is contained in:
Javier Suárez Ruiz 2017-01-09 13:31:56 +01:00
parent 7ad7a24a6e
commit 7b7c68d85c
14 changed files with 383 additions and 317 deletions

View File

@ -1,4 +1,5 @@
using eShopOnContainers.Services; using eShopOnContainers.Core.Helpers;
using eShopOnContainers.Services;
using eShopOnContainers.ViewModels.Base; using eShopOnContainers.ViewModels.Base;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
@ -25,7 +26,7 @@ namespace eShopOnContainers
private void InitApp() private void InitApp()
{ {
UseMockServices = true; UseMockServices = Settings.UseMocks;
ViewModelLocator.Instance.UpdateDependencies(UseMockServices); ViewModelLocator.Instance.UpdateDependencies(UseMockServices);
} }

View File

@ -8,7 +8,7 @@
public GlobalSetting() public GlobalSetting()
{ {
AuthToken = "INSERT AUTHENTICATION TOKEN"; AuthToken = "INSERT AUTHENTICATION TOKEN";
BaseEndpoint = "http://10.106.144.28"; BaseEndpoint = "http://13.88.8.119";
} }
public static GlobalSetting Instance public static GlobalSetting Instance

View File

@ -1,3 +1,4 @@
using eShopOnContainers.ViewModels.Base;
using Plugin.Settings; using Plugin.Settings;
using Plugin.Settings.Abstractions; using Plugin.Settings.Abstractions;
@ -22,8 +23,12 @@ namespace eShopOnContainers.Core.Helpers
private const string AccessToken = "access_token"; private const string AccessToken = "access_token";
private const string IdToken = "id_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 AccessTokenDefault = string.Empty;
private static readonly string IdTokenDefault = 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 #endregion
@ -51,5 +56,30 @@ namespace eShopOnContainers.Core.Helpers
AppSettings.AddOrUpdateValue<string>(IdToken, value); 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);
}
}
} }
} }

View File

@ -9,13 +9,6 @@ using eShopOnContainers.Core.Services.Basket;
using eShopOnContainers.Core.Services.Identity; using eShopOnContainers.Core.Services.Identity;
using eShopOnContainers.Core.Services.Order; using eShopOnContainers.Core.Services.Order;
using eShopOnContainers.Core.Services.User; 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 namespace eShopOnContainers.ViewModels.Base
{ {

View File

@ -9,7 +9,6 @@ using System.Windows.Input;
using System.Linq; using System.Linq;
using eShopOnContainers.Core.Services.Basket; using eShopOnContainers.Core.Services.Basket;
using eShopOnContainers.Core.Helpers; using eShopOnContainers.Core.Helpers;
using System;
using eShopOnContainers.Core.Services.User; using eShopOnContainers.Core.Services.User;
namespace eShopOnContainers.Core.ViewModels namespace eShopOnContainers.Core.ViewModels
@ -121,6 +120,7 @@ namespace eShopOnContainers.Core.ViewModels
private void AddCatalogItem(CatalogItem catalogItem) private void AddCatalogItem(CatalogItem catalogItem)
{ {
// Add new item to Basket
MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem); MessagingCenter.Send(this, MessengerKeys.AddProduct, catalogItem);
} }
@ -133,7 +133,7 @@ namespace eShopOnContainers.Core.ViewModels
IsBusy = true; IsBusy = true;
// Filter // Filter catalog products
MessagingCenter.Send(this, MessengerKeys.Filter); MessagingCenter.Send(this, MessengerKeys.Filter);
Products = await _productsService.FilterAsync(Brand.Id, Type.Id); Products = await _productsService.FilterAsync(Brand.Id, Type.Id);

View File

@ -4,7 +4,6 @@ using eShopOnContainers.Core.Services.Identity;
using eShopOnContainers.Core.Services.OpenUrl; using eShopOnContainers.Core.Services.OpenUrl;
using eShopOnContainers.Core.Services.User; using eShopOnContainers.Core.Services.User;
using eShopOnContainers.Core.Validations; using eShopOnContainers.Core.Validations;
using eShopOnContainers.Core.ViewModels.Base;
using eShopOnContainers.ViewModels.Base; using eShopOnContainers.ViewModels.Base;
using IdentityModel.Client; using IdentityModel.Client;
using System; using System;
@ -40,8 +39,7 @@ namespace eShopOnContainers.Core.ViewModels
_userName = new ValidatableObject<string>(); _userName = new ValidatableObject<string>();
_password = new ValidatableObject<string>(); _password = new ValidatableObject<string>();
IsMock = ViewModelLocator.Instance.UseMockService; InvalidateMock();
AddValidations(); AddValidations();
} }
@ -214,7 +212,7 @@ namespace eShopOnContainers.Core.ViewModels
LoginUrl = logoutRequest; LoginUrl = logoutRequest;
} }
if(ViewModelLocator.Instance.UseMockService) if(Settings.UseMocks)
{ {
Settings.AuthAccessToken = string.Empty; Settings.AuthAccessToken = string.Empty;
Settings.AuthIdToken = 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" }); _userName.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Username should not be empty" });
_password.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Password should not be empty" }); _password.Validations.Add(new IsNotNullOrEmptyRule<string> { ValidationMessage = "Password should not be empty" });
} }
public void InvalidateMock()
{
IsMock = Settings.UseMocks;
}
} }
} }

View File

@ -3,14 +3,11 @@ 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;
@ -24,10 +21,5 @@ namespace eShopOnContainers.Core.ViewModels
return base.InitializeAsync(navigationData); return base.InitializeAsync(navigationData);
} }
private void Settings()
{
NavigationService.NavigateToAsync<SettingsViewModel>();
}
} }
} }

View File

@ -2,6 +2,7 @@
using System.Windows.Input; using System.Windows.Input;
using Xamarin.Forms; using Xamarin.Forms;
using System.Threading.Tasks; using System.Threading.Tasks;
using eShopOnContainers.Core.Helpers;
namespace eShopOnContainers.Core.ViewModels namespace eShopOnContainers.Core.ViewModels
{ {
@ -14,7 +15,7 @@ namespace eShopOnContainers.Core.ViewModels
public SettingsViewModel() public SettingsViewModel()
{ {
UseAzureServices = !ViewModelLocator.Instance.UseMockService; UseAzureServices = !Settings.UseMocks;
} }
public string Title public string Title
@ -43,6 +44,9 @@ namespace eShopOnContainers.Core.ViewModels
set set
{ {
_useAzureServices = value; _useAzureServices = value;
// Save use mocks services to local storage
Settings.UseMocks = !_useAzureServices;
RaisePropertyChanged(() => UseAzureServices); RaisePropertyChanged(() => UseAzureServices);
} }
} }
@ -75,7 +79,7 @@ namespace eShopOnContainers.Core.ViewModels
{ {
UpdateInfo(); UpdateInfo();
Endpoint = GlobalSetting.Instance.BaseEndpoint; Endpoint = Settings.UrlBase;
return base.InitializeAsync(navigationData); return base.InitializeAsync(navigationData);
} }
@ -96,8 +100,8 @@ namespace eShopOnContainers.Core.ViewModels
private void UpdateEndpoint(string endpoint) private void UpdateEndpoint(string endpoint)
{ {
// Update remote endpoint // Update remote endpoint (save to local storage)
GlobalSetting.Instance.BaseEndpoint = endpoint; Settings.UrlBase = endpoint;
} }
} }
} }

View File

@ -5,286 +5,334 @@
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core" xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core"
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core" xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core"
xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core"> xmlns:behaviors="clr-namespace:eShopOnContainers.Core.Behaviors;assembly=eShopOnContainers.Core">
<ContentPage.Title> <ContentPage.Title>
<OnPlatform <OnPlatform
x:TypeArguments="x:String" x:TypeArguments="x:String"
iOS="eShop on Containers" iOS="eShop on Containers"
WinPhone="eShop on Containers"/> WinPhone="eShop on Containers"/>
</ContentPage.Title> </ContentPage.Title>
<ContentPage.Resources> <ContentPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<Style x:Key="TitleLabelStyle" <Style x:Key="TitleLabelStyle"
TargetType="{x:Type Label}"> TargetType="{x:Type Label}">
<Setter Property="FontFamily" <Setter Property="FontFamily"
Value="{StaticResource MontserratRegular}" /> Value="{StaticResource MontserratRegular}" />
<Setter Property="FontAttributes" <Setter Property="FontAttributes"
Value="Bold" /> Value="Bold" />
<Setter Property="FontSize" <Setter Property="FontSize"
Value="{StaticResource MediumSize}" /> Value="{StaticResource MediumSize}" />
<Setter Property="HorizontalOptions" <Setter Property="HorizontalOptions"
Value="Center" /> Value="Center" />
<Setter Property="Margin" <Setter Property="Margin"
Value="0, 12" /> Value="0, 12" />
</Style> </Style>
<Style x:Key="HeaderLabelStyle" <Style x:Key="HeaderLabelStyle"
TargetType="{x:Type Label}"> TargetType="{x:Type Label}">
<Setter Property="FontFamily" <Setter Property="FontFamily"
Value="{StaticResource MontserratRegular}" /> Value="{StaticResource MontserratRegular}" />
<Setter Property="FontSize" <Setter Property="FontSize"
Value="{StaticResource LittleSize}" /> Value="{StaticResource LittleSize}" />
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource GreenColor}" /> Value="{StaticResource GreenColor}" />
<Setter Property="HorizontalOptions" <Setter Property="HorizontalOptions"
Value="Start" /> Value="Start" />
</Style> </Style>
<Style x:Key="LoginButtonStyle" <Style x:Key="LoginButtonStyle"
TargetType="{x:Type Label}"> TargetType="{x:Type Label}">
<Setter Property="FontFamily" <Setter Property="FontFamily"
Value="{StaticResource MontserratRegular}" /> Value="{StaticResource MontserratRegular}" />
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource WhiteColor}" /> Value="{StaticResource WhiteColor}" />
<Setter Property="HorizontalOptions" <Setter Property="HorizontalOptions"
Value="Center" /> Value="Center" />
<Setter Property="VerticalOptions" <Setter Property="VerticalOptions"
Value="Center" /> Value="Center" />
</Style> </Style>
<Style x:Key="LoginPanelStyle" <Style x:Key="LoginPanelStyle"
TargetType="{x:Type Grid}"> TargetType="{x:Type Grid}">
<Setter Property="HeightRequest" <Setter Property="HeightRequest"
Value="60" /> Value="60" />
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource LightGreenColor}" /> Value="{StaticResource LightGreenColor}" />
<Setter Property="HorizontalOptions" <Setter Property="HorizontalOptions"
Value="FillAndExpand" /> Value="FillAndExpand" />
<Setter Property="VerticalOptions" <Setter Property="VerticalOptions"
Value="FillAndExpand" /> Value="FillAndExpand" />
</Style> </Style>
<Style x:Key="RegisterPanelStyle" <Style x:Key="RegisterPanelStyle"
TargetType="{x:Type Grid}" TargetType="{x:Type Grid}"
BasedOn="{StaticResource LoginPanelStyle}"> BasedOn="{StaticResource LoginPanelStyle}">
<Setter Property="BackgroundColor" <Setter Property="BackgroundColor"
Value="{StaticResource BlackColor}" /> Value="{StaticResource GreenColor}" />
</Style> </Style>
<animations:StoryBoard <Style x:Key="SettingsPanelStyle"
x:Key="LoginAnimation" TargetType="{x:Type Grid}"
Target="{x:Reference LoginPanel}"> BasedOn="{StaticResource LoginPanelStyle}">
<animations:FadeInAnimation <Setter Property="BackgroundColor"
Direction="Up" Value="{StaticResource BlackColor}" />
Duration="1500" /> </Style>
</animations:StoryBoard>
</ResourceDictionary> <Style x:Key="SettingsImageStyle"
</ContentPage.Resources> TargetType="{x:Type Image}">
<ContentPage.Triggers> <Setter Property="Margin"
<EventTrigger Value="12" />
Event="Appearing"> </Style>
<triggers:BeginAnimation
Animation="{StaticResource LoginAnimation}" /> <animations:StoryBoard
</EventTrigger> x:Key="LoginAnimation"
</ContentPage.Triggers> Target="{x:Reference LoginPanel}">
<Grid <animations:FadeInAnimation
Direction="Up"
Duration="1500" />
</animations:StoryBoard>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Triggers>
<EventTrigger
Event="Appearing">
<triggers:BeginAnimation
Animation="{StaticResource LoginAnimation}" />
</EventTrigger>
</ContentPage.Triggers>
<Grid
BackgroundColor="{StaticResource BackgroundColor}"> BackgroundColor="{StaticResource BackgroundColor}">
<!-- MOCK AUTH --> <!-- MOCK AUTH -->
<Grid
x:Name="LoginPanel"
IsVisible="{Binding IsMock}"
Padding="0"
ColumnSpacing="0"
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<!-- LOGIN / REGISTER -->
<Grid
Grid.Row="0"
Margin="48, 24">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackLayout
Grid.Column="0"
Orientation="Horizontal"
HorizontalOptions="Center">
<Label
Text="["
TextColor="{StaticResource LightGreenColor}"/>
<Label
Text="LOGIN"
FontAttributes="Bold"/>
<Label
Text="]"
TextColor="{StaticResource LightGreenColor}"/>
</StackLayout>
<Grid <Grid
Grid.Column="1" x:Name="LoginPanel"
HorizontalOptions="Center"> IsVisible="{Binding IsMock}"
<Label Padding="0"
Text="REGISTER" ColumnSpacing="0"
TextColor="Gray"/> RowSpacing="0">
<Grid.GestureRecognizers> <Grid.RowDefinitions>
<TapGestureRecognizer <RowDefinition Height="Auto" />
Command="{Binding RegisterCommand}" <RowDefinition Height="Auto" />
NumberOfTapsRequired="1" /> <RowDefinition Height="*" />
</Grid.GestureRecognizers> <RowDefinition Height="60" />
</Grid.RowDefinitions>
<!-- LOGIN / REGISTER / SETTINGS -->
<Grid
Grid.Row="0"
Margin="48, 24">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackLayout
Grid.Column="0"
Orientation="Horizontal"
HorizontalOptions="Center">
<Label
Text="["
TextColor="{StaticResource LightGreenColor}"/>
<Label
Text="LOGIN"
FontAttributes="Bold"/>
<Label
Text="]"
TextColor="{StaticResource LightGreenColor}"/>
</StackLayout>
<Grid
Grid.Column="1"
HorizontalOptions="Center">
<Label
Text="REGISTER"
TextColor="Gray"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding RegisterCommand}"
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
Grid.Row="1"
Text="ARE YOU REGISTERED?"
Style="{StaticResource TitleLabelStyle}"/>
<!-- LOGIN FORM -->
<StackLayout
Grid.Row="2"
Margin="24">
<Label
Text="User name or email"
Style="{StaticResource HeaderLabelStyle}"/>
<Entry
Text="{Binding UserName.Value, Mode=TwoWay}">
<Entry.Style>
<OnPlatform x:TypeArguments="Style"
iOS="{StaticResource EntryStyle}"
Android="{StaticResource EntryStyle}"
WinPhone="{StaticResource UwpEntryStyle}"/>
</Entry.Style>
</Entry>
<Label
Text="Password"
Style="{StaticResource HeaderLabelStyle}"/>
<Entry
IsPassword="True"
Text="{Binding Password.Value, Mode=TwoWay}"
Style="{StaticResource EntryStyle}">
<Entry.Style>
<OnPlatform x:TypeArguments="Style"
iOS="{StaticResource EntryStyle}"
Android="{StaticResource EntryStyle}"
WinPhone="{StaticResource UwpEntryStyle}"/>
</Entry.Style>
</Entry>
</StackLayout>
<!-- LOGIN BUTTON -->
<Grid
BackgroundColor="{StaticResource LightGreenColor}"
Grid.Row="3"
Padding="0"
ColumnSpacing="0"
RowSpacing="0">
<Label
Text="[ LOGIN ]"
Style="{StaticResource LoginButtonStyle}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding MockSignInCommand}"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>
</Grid> </Grid>
</Grid> <!-- AUTH -->
<!-- INFO --> <Grid
<Label ColumnSpacing="0"
Grid.Row="1" RowSpacing="0"
Text="ARE YOU REGISTERED?" IsVisible="{Binding IsMock, Converter={StaticResource InverseBoolConverter}}">
Style="{StaticResource TitleLabelStyle}"/> <Grid.RowDefinitions>
<!-- LOGIN FORM --> <RowDefinition Height="*" />
<StackLayout <RowDefinition Height="60" />
Grid.Row="2" </Grid.RowDefinitions>
Margin="24"> <Grid.ColumnDefinitions>
<Label <ColumnDefinition />
Text="User name or email" <ColumnDefinition />
Style="{StaticResource HeaderLabelStyle}"/> <ColumnDefinition Width="64" />
<Entry </Grid.ColumnDefinitions>
Text="{Binding UserName.Value, Mode=TwoWay}"> <!-- BANNER -->
<Entry.Style> <Image
<OnPlatform x:TypeArguments="Style" x:Name="Banner"
iOS="{StaticResource EntryStyle}" Grid.Row="0"
Android="{StaticResource EntryStyle}" Grid.Column="0"
WinPhone="{StaticResource UwpEntryStyle}"/> Grid.ColumnSpan="3"
</Entry.Style> Aspect="AspectFill">
</Entry> <Image.Source>
<Label <OnPlatform
Text="Password" x:TypeArguments="ImageSource"
Style="{StaticResource HeaderLabelStyle}"/> Android="banner.png"
<Entry iOS="banner.png"
IsPassword="True" WinPhone="Assets\banner.png"/>
Text="{Binding Password.Value, Mode=TwoWay}" </Image.Source>
Style="{StaticResource EntryStyle}"> </Image>
<Entry.Style> <Grid
<OnPlatform x:TypeArguments="Style" Grid.Row="0"
iOS="{StaticResource EntryStyle}" Grid.Column="0"
Android="{StaticResource EntryStyle}" Grid.ColumnSpan="3"
WinPhone="{StaticResource UwpEntryStyle}"/> BackgroundColor="{StaticResource BlackColor}"
</Entry.Style> Opacity="0.5"/>
</Entry> <!-- LOG IN BUTTON -->
</StackLayout> <Grid
<!-- LOGIN BUTTON --> Grid.Column="0"
<Grid Grid.Row="1"
BackgroundColor="{StaticResource LightGreenColor}" Style="{StaticResource LoginPanelStyle}">
Grid.Row="3" <Label
Padding="0" Text="[ LOGIN ]"
ColumnSpacing="0" Style="{StaticResource LoginButtonStyle}"/>
RowSpacing="0"> <Grid.GestureRecognizers>
<Label <TapGestureRecognizer
Text="[ LOGIN ]" Command="{Binding SignInCommand}"
Style="{StaticResource LoginButtonStyle}"/> NumberOfTapsRequired="1" />
<Grid.GestureRecognizers> </Grid.GestureRecognizers>
<TapGestureRecognizer </Grid>
Command="{Binding MockSignInCommand}" <!-- REGISTER BUTTON -->
NumberOfTapsRequired="1" /> <Grid
</Grid.GestureRecognizers> Grid.Column="1"
</Grid> Grid.Row="1"
Style="{StaticResource RegisterPanelStyle}">
<Label
Text="[ REGISTER ]"
Style="{StaticResource LoginButtonStyle}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding RegisterCommand}"
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="3"
Grid.Row="0"
Grid.RowSpan="2"
IsVisible="{Binding IsLogin}">
<WebView
Source="{Binding LoginUrl}"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All">
<WebView.Behaviors>
<behaviors:WebViewNavigationBehavior
NavigateCommand="{Binding NavigateCommand}"/>
</WebView.Behaviors>
</WebView>
</AbsoluteLayout>
</Grid>
<!-- INDICATOR -->
<ActivityIndicator
Color="{StaticResource LightGreenColor}"
IsRunning="{Binding IsBusy}"
IsVisible="{Binding IsBusy}"
VerticalOptions="Center"
HorizontalOptions="Center">
<ActivityIndicator.WidthRequest>
<OnPlatform
x:TypeArguments="x:Double"
iOS="100"
Android="100"
WinPhone="400" />
</ActivityIndicator.WidthRequest>
</ActivityIndicator>
</Grid> </Grid>
<!-- AUTH -->
<Grid
ColumnSpacing="0"
RowSpacing="0"
IsVisible="{Binding IsMock, Converter={StaticResource InverseBoolConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- BANNER -->
<Image
x:Name="Banner"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Aspect="AspectFill">
<Image.Source>
<OnPlatform
x:TypeArguments="ImageSource"
Android="banner.png"
iOS="banner.png"
WinPhone="Assets\banner.png"/>
</Image.Source>
</Image>
<Grid
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
BackgroundColor="{StaticResource BlackColor}"
Opacity="0.5"/>
<!-- LOG IN BUTTON -->
<Grid
Grid.Column="0"
Grid.Row="1"
Style="{StaticResource LoginPanelStyle}">
<Label
Text="[ LOGIN ]"
Style="{StaticResource LoginButtonStyle}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding SignInCommand}"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>
<!-- REGISTER BUTTON -->
<Grid
Grid.Column="1"
Grid.Row="1"
Style="{StaticResource RegisterPanelStyle}">
<Label
Text="[ REGISTER ]"
Style="{StaticResource LoginButtonStyle}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding RegisterCommand}"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>
<!-- WEBVIEW -->
<AbsoluteLayout
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="0"
Grid.RowSpan="2"
IsVisible="{Binding IsLogin}">
<WebView
Source="{Binding LoginUrl}"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All">
<WebView.Behaviors>
<behaviors:WebViewNavigationBehavior
NavigateCommand="{Binding NavigateCommand}"/>
</WebView.Behaviors>
</WebView>
</AbsoluteLayout>
</Grid>
<!-- INDICATOR -->
<ActivityIndicator
Color="{StaticResource LightGreenColor}"
IsRunning="{Binding IsBusy}"
IsVisible="{Binding IsBusy}"
VerticalOptions="Center"
HorizontalOptions="Center">
<ActivityIndicator.WidthRequest>
<OnPlatform
x:TypeArguments="x:Double"
iOS="100"
Android="100"
WinPhone="400" />
</ActivityIndicator.WidthRequest>
</ActivityIndicator>
</Grid>
</ContentPage> </ContentPage>

View File

@ -1,4 +1,5 @@
using System; using eShopOnContainers.Core.ViewModels;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
@ -22,6 +23,13 @@ namespace eShopOnContainers.Core.Views
_animate = true; _animate = true;
await AnimateIn(); await AnimateIn();
var vm = BindingContext as LoginViewModel;
if(vm != null)
{
vm.InvalidateMock();
}
} }
protected override void OnDisappearing() protected override void OnDisappearing()

View File

@ -13,19 +13,6 @@
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">

View File

@ -16,7 +16,7 @@
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk> <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion> <TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
<AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis> <AndroidSupportedAbis>armeabi,armeabi-v7a,x86</AndroidSupportedAbis>
<AndroidStoreUncompressedFileExtensions /> <AndroidStoreUncompressedFileExtensions />

View File

@ -16,7 +16,7 @@
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion> <TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>

View File

@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("eShopOnContainers.UWP")] [assembly: AssemblyTitle("eShopOnContainers.UWP")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("eShopOnContainers.UWP")] [assembly: AssemblyProduct("eShopOnContainers.UWP")]
[assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyCopyright("Copyright Microsoft © 2017")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]