Merge pull request #185 from dotnet-architecture/xamarin
Minor fixes to Xamarin client.
This commit is contained in:
commit
b851b01ad6
@ -18,7 +18,7 @@ namespace eShopOnContainers
|
|||||||
|
|
||||||
InitApp();
|
InitApp();
|
||||||
|
|
||||||
if (Device.OS == TargetPlatform.Windows)
|
if (Device.RuntimePlatform == Device.Windows)
|
||||||
{
|
{
|
||||||
InitNavigation();
|
InitNavigation();
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ namespace eShopOnContainers
|
|||||||
{
|
{
|
||||||
base.OnStart();
|
base.OnStart();
|
||||||
|
|
||||||
if (Device.OS != TargetPlatform.Windows)
|
if (Device.RuntimePlatform != Device.Windows)
|
||||||
{
|
{
|
||||||
await InitNavigation();
|
await InitNavigation();
|
||||||
}
|
}
|
||||||
|
@ -1,130 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using Xamarin.Forms;
|
|
||||||
|
|
||||||
namespace eShopOnContainers.Core.Controls
|
|
||||||
{
|
|
||||||
public class BindablePicker : Picker
|
|
||||||
{
|
|
||||||
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource",
|
|
||||||
typeof(IEnumerable), typeof(BindablePicker), null, propertyChanged: OnItemsSourceChanged);
|
|
||||||
|
|
||||||
public static readonly BindableProperty SelectedItemProperty = BindableProperty.Create("SelectedItem",
|
|
||||||
typeof(object), typeof(BindablePicker), null, BindingMode.TwoWay, propertyChanged: OnSelectedItemChanged);
|
|
||||||
|
|
||||||
public static readonly BindableProperty ItemSelectedCommandProperty = BindableProperty.Create("ItemSelectedCommand",
|
|
||||||
typeof(ICommand), typeof(BindablePicker), null);
|
|
||||||
|
|
||||||
public BindablePicker()
|
|
||||||
{
|
|
||||||
SelectedIndexChanged += (o, e) =>
|
|
||||||
{
|
|
||||||
if (SelectedIndex < 0 || ItemsSource == null || !ItemsSource.GetEnumerator().MoveNext())
|
|
||||||
{
|
|
||||||
SelectedItem = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = 0;
|
|
||||||
|
|
||||||
foreach (var item in ItemsSource)
|
|
||||||
{
|
|
||||||
if (index == SelectedIndex)
|
|
||||||
{
|
|
||||||
SelectedItem = item;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable ItemsSource
|
|
||||||
{
|
|
||||||
get { return (IEnumerable)GetValue(ItemsSourceProperty); }
|
|
||||||
set { SetValue(ItemsSourceProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object SelectedItem
|
|
||||||
{
|
|
||||||
get { return GetValue(SelectedItemProperty); }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (SelectedItem != value)
|
|
||||||
{
|
|
||||||
SetValue(SelectedItemProperty, value);
|
|
||||||
InternalUpdateSelectedIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICommand ItemSelectedCommand
|
|
||||||
{
|
|
||||||
get { return (ICommand)GetValue(ItemSelectedCommandProperty); }
|
|
||||||
set { SetValue(ItemSelectedCommandProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler<SelectedItemChangedEventArgs> ItemSelected;
|
|
||||||
|
|
||||||
private void InternalUpdateSelectedIndex()
|
|
||||||
{
|
|
||||||
var selectedIndex = -1;
|
|
||||||
if (ItemsSource != null)
|
|
||||||
{
|
|
||||||
var index = 0;
|
|
||||||
|
|
||||||
foreach (var item in ItemsSource)
|
|
||||||
{
|
|
||||||
string strItem = item?.ToString();
|
|
||||||
|
|
||||||
if (item != null && SelectedItem != null
|
|
||||||
&& !string.IsNullOrEmpty(strItem)
|
|
||||||
&& item.ToString().Equals(SelectedItem.ToString()))
|
|
||||||
{
|
|
||||||
selectedIndex = index;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectedIndex = selectedIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
|
|
||||||
{
|
|
||||||
var boundPicker = (BindablePicker)bindable;
|
|
||||||
|
|
||||||
if (Equals(newValue, null) && !Equals(oldValue, null))
|
|
||||||
return;
|
|
||||||
|
|
||||||
boundPicker.Items.Clear();
|
|
||||||
|
|
||||||
if (!Equals(newValue, null))
|
|
||||||
{
|
|
||||||
foreach (var item in (IEnumerable)newValue)
|
|
||||||
boundPicker.Items.Add(item.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
boundPicker.InternalUpdateSelectedIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnSelectedItemChanged(BindableObject bindable, object oldValue, object newValue)
|
|
||||||
{
|
|
||||||
var boundPicker = (BindablePicker)bindable;
|
|
||||||
|
|
||||||
boundPicker.ItemSelected?.Invoke(boundPicker,
|
|
||||||
new SelectedItemChangedEventArgs(newValue));
|
|
||||||
|
|
||||||
if(boundPicker.ItemSelectedCommand != null)
|
|
||||||
{
|
|
||||||
boundPicker.ItemSelectedCommand.Execute(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
boundPicker.InternalUpdateSelectedIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,8 +12,8 @@ namespace eShopOnContainers.Core.Services.Basket
|
|||||||
BuyerId = "9245fe4a-d402-451c-b9ed-9c1a04247482",
|
BuyerId = "9245fe4a-d402-451c-b9ed-9c1a04247482",
|
||||||
Items = new List<BasketItem>
|
Items = new List<BasketItem>
|
||||||
{
|
{
|
||||||
new BasketItem { Id = "1", PictureUrl = Device.OS != TargetPlatform.Windows ? "fake_product_01.png" : "Assets/fake_product_01.png", ProductId = Common.Common.MockCatalogItemId01, ProductName = ".NET Bot Blue Sweatshirt (M)", Quantity = 1, UnitPrice = 19.50M },
|
new BasketItem { Id = "1", PictureUrl = Device.RuntimePlatform != Device.Windows ? "fake_product_01.png" : "Assets/fake_product_01.png", ProductId = Common.Common.MockCatalogItemId01, ProductName = ".NET Bot Blue Sweatshirt (M)", Quantity = 1, UnitPrice = 19.50M },
|
||||||
new BasketItem { Id = "2", PictureUrl = Device.OS != TargetPlatform.Windows ? "fake_product_04.png" : "Assets/fake_product_04.png", ProductId = Common.Common.MockCatalogItemId04, ProductName = ".NET Black Cupt", Quantity = 1, UnitPrice = 17.00M }
|
new BasketItem { Id = "2", PictureUrl = Device.RuntimePlatform != Device.Windows ? "fake_product_04.png" : "Assets/fake_product_04.png", ProductId = Common.Common.MockCatalogItemId04, ProductName = ".NET Black Cupt", Quantity = 1, UnitPrice = 17.00M }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ namespace eShopOnContainers.Core.Services.Catalog
|
|||||||
|
|
||||||
private ObservableCollection<CatalogItem> MockCatalog = new ObservableCollection<CatalogItem>
|
private ObservableCollection<CatalogItem> MockCatalog = new ObservableCollection<CatalogItem>
|
||||||
{
|
{
|
||||||
new CatalogItem { Id = Common.Common.MockCatalogItemId01, PictureUri = Device.OS != TargetPlatform.Windows ? "fake_product_01.png" : "Assets/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
new CatalogItem { Id = Common.Common.MockCatalogItemId01, PictureUri = Device.RuntimePlatform != Device.Windows ? "fake_product_01.png" : "Assets/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
||||||
new CatalogItem { Id = Common.Common.MockCatalogItemId02, PictureUri = Device.OS != TargetPlatform.Windows ? "fake_product_02.png" : "Assets/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
new CatalogItem { Id = Common.Common.MockCatalogItemId02, PictureUri = Device.RuntimePlatform != Device.Windows ? "fake_product_02.png" : "Assets/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
||||||
new CatalogItem { Id = Common.Common.MockCatalogItemId03, PictureUri = Device.OS != TargetPlatform.Windows ? "fake_product_03.png" : "Assets/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
new CatalogItem { Id = Common.Common.MockCatalogItemId03, PictureUri = Device.RuntimePlatform != Device.Windows ? "fake_product_03.png" : "Assets/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 2, CatalogType = "T-Shirt" },
|
||||||
new CatalogItem { Id = Common.Common.MockCatalogItemId04, PictureUri = Device.OS != TargetPlatform.Windows ? "fake_product_04.png" : "Assets/fake_product_04.png", Name = ".NET Black Cupt", Price = 17.00M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 1, CatalogType = "Mug" },
|
new CatalogItem { Id = Common.Common.MockCatalogItemId04, PictureUri = Device.RuntimePlatform != Device.Windows ? "fake_product_04.png" : "Assets/fake_product_04.png", Name = ".NET Black Cupt", Price = 17.00M, CatalogBrandId = 2, CatalogBrand = "Visual Studio", CatalogTypeId = 1, CatalogType = "Mug" },
|
||||||
new CatalogItem { Id = Common.Common.MockCatalogItemId05, PictureUri = Device.OS != TargetPlatform.Windows ? "fake_product_05.png" : "Assets/fake_product_05.png", Name = "Azure Black Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 1, CatalogBrand = "Azure", CatalogTypeId = 2, CatalogType = "T-Shirt" }
|
new CatalogItem { Id = Common.Common.MockCatalogItemId05, PictureUri = Device.RuntimePlatform != Device.Windows ? "fake_product_05.png" : "Assets/fake_product_05.png", Name = "Azure Black Sweatshirt (M)", Price = 19.50M, CatalogBrandId = 1, CatalogBrand = "Azure", CatalogTypeId = 2, CatalogType = "T-Shirt" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public async Task<ObservableCollection<CatalogItem>> GetCatalogAsync()
|
public async Task<ObservableCollection<CatalogItem>> GetCatalogAsync()
|
||||||
|
@ -53,8 +53,8 @@ namespace eShopOnContainers.Core.Services.Order
|
|||||||
|
|
||||||
private static List<OrderItem> MockOrderItems = new List<OrderItem>()
|
private static List<OrderItem> MockOrderItems = new List<OrderItem>()
|
||||||
{
|
{
|
||||||
new OrderItem { OrderId = Guid.NewGuid(), ProductId = Common.Common.MockCatalogItemId01, Discount = 15, ProductName = ".NET Bot Blue Sweatshirt (M)", Quantity = 1, UnitPrice = 16.50M, PictureUrl = Device.OS != TargetPlatform.Windows ? "fake_product_01.png" : "Assets/fake_product_01.png" },
|
new OrderItem { OrderId = Guid.NewGuid(), ProductId = Common.Common.MockCatalogItemId01, Discount = 15, ProductName = ".NET Bot Blue Sweatshirt (M)", Quantity = 1, UnitPrice = 16.50M, PictureUrl = Device.RuntimePlatform != Device.Windows ? "fake_product_01.png" : "Assets/fake_product_01.png" },
|
||||||
new OrderItem { OrderId = Guid.NewGuid(), ProductId = Common.Common.MockCatalogItemId03, Discount = 0, ProductName = ".NET Bot Black Sweatshirt (M)", Quantity = 2, UnitPrice = 19.95M, PictureUrl = Device.OS != TargetPlatform.Windows ? "fake_product_03.png" : "Assets/fake_product_03.png" }
|
new OrderItem { OrderId = Guid.NewGuid(), ProductId = Common.Common.MockCatalogItemId03, Discount = 0, ProductName = ".NET Bot Black Sweatshirt (M)", Quantity = 2, UnitPrice = 19.95M, PictureUrl = Device.RuntimePlatform != Device.Windows ? "fake_product_03.png" : "Assets/fake_product_03.png" }
|
||||||
};
|
};
|
||||||
|
|
||||||
private static List<CardType> MockCardTypes = new List<CardType>()
|
private static List<CardType> MockCardTypes = new List<CardType>()
|
||||||
|
@ -102,7 +102,7 @@ namespace eShopOnContainers.Core.ViewModels
|
|||||||
|
|
||||||
private async Task FilterAsync()
|
private async Task FilterAsync()
|
||||||
{
|
{
|
||||||
if (Brand == null && Type == null)
|
if (Brand == null || Type == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,7 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!-- FILTERS -->
|
<!-- FILTERS -->
|
||||||
<Grid
|
<Grid
|
||||||
BackgroundColor="{StaticResource LightGreenColor}"
|
BackgroundColor="{StaticResource LightGreenColor}">
|
||||||
IsEnabled="{Binding Products.Count, Converter={StaticResource CountToBoolConverter}}">
|
|
||||||
<Label
|
<Label
|
||||||
Text="FILTER"
|
Text="FILTER"
|
||||||
Style="{StaticResource FilterLabelStyle}"/>
|
Style="{StaticResource FilterLabelStyle}"/>
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<slideOverKit:SlideMenuView
|
<slideOverKit:SlideMenuView
|
||||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:slideOverKit="clr-namespace:SlideOverKit"
|
xmlns:slideOverKit="clr-namespace:SlideOverKit"
|
||||||
xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core"
|
|
||||||
x:Class="eShopOnContainers.Core.Views.FiltersView"
|
x:Class="eShopOnContainers.Core.Views.FiltersView"
|
||||||
MenuOrientations="TopToBottom"
|
MenuOrientations="TopToBottom"
|
||||||
BackgroundColor="{StaticResource BackgroundColor}"
|
BackgroundColor="{StaticResource BackgroundColor}"
|
||||||
@ -13,7 +12,7 @@
|
|||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|
||||||
<Style x:Key="FilterPickerStyle"
|
<Style x:Key="FilterPickerStyle"
|
||||||
TargetType="{x:Type controls:BindablePicker}">
|
TargetType="{x:Type Picker}">
|
||||||
<Setter Property="HeightRequest"
|
<Setter Property="HeightRequest"
|
||||||
Value="48" />
|
Value="48" />
|
||||||
<Setter Property="BackgroundColor"
|
<Setter Property="BackgroundColor"
|
||||||
@ -70,35 +69,35 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!-- BRAND -->
|
<!-- BRAND -->
|
||||||
<controls:BindablePicker
|
<Picker
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Title="BRAND"
|
Title="BRAND"
|
||||||
ItemsSource="{Binding Brands}"
|
ItemsSource="{Binding Brands}"
|
||||||
SelectedItem="{Binding Brand, Mode=TwoWay}"
|
SelectedItem="{Binding Brand, Mode=TwoWay}"
|
||||||
Style="{StaticResource FilterPickerStyle}">
|
Style="{StaticResource FilterPickerStyle}">
|
||||||
<controls:BindablePicker.HeightRequest>
|
<Picker.HeightRequest>
|
||||||
<OnPlatform
|
<OnPlatform
|
||||||
x:TypeArguments="x:Double"
|
x:TypeArguments="x:Double"
|
||||||
Android="48"
|
Android="48"
|
||||||
iOS="48"
|
iOS="48"
|
||||||
WinPhone="36"/>
|
WinPhone="36"/>
|
||||||
</controls:BindablePicker.HeightRequest>
|
</Picker.HeightRequest>
|
||||||
</controls:BindablePicker>
|
</Picker>
|
||||||
<!-- TYPE -->
|
<!-- TYPE -->
|
||||||
<controls:BindablePicker
|
<Picker
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Title="TYPE"
|
Title="TYPE"
|
||||||
ItemsSource="{Binding Types}"
|
ItemsSource="{Binding Types}"
|
||||||
SelectedItem="{Binding Type, Mode=TwoWay}"
|
SelectedItem="{Binding Type, Mode=TwoWay}"
|
||||||
Style="{StaticResource FilterPickerStyle}">
|
Style="{StaticResource FilterPickerStyle}">
|
||||||
<controls:BindablePicker.HeightRequest>
|
<Picker.HeightRequest>
|
||||||
<OnPlatform
|
<OnPlatform
|
||||||
x:TypeArguments="x:Double"
|
x:TypeArguments="x:Double"
|
||||||
Android="48"
|
Android="48"
|
||||||
iOS="48"
|
iOS="48"
|
||||||
WinPhone="36"/>
|
WinPhone="36"/>
|
||||||
</controls:BindablePicker.HeightRequest>
|
</Picker.HeightRequest>
|
||||||
</controls:BindablePicker>
|
</Picker>
|
||||||
<Button
|
<Button
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Text="Apply"
|
Text="Apply"
|
||||||
|
@ -41,7 +41,7 @@ namespace eShopOnContainers.Core.Views
|
|||||||
|
|
||||||
public async Task AnimateIn()
|
public async Task AnimateIn()
|
||||||
{
|
{
|
||||||
if (Device.OS == TargetPlatform.Windows)
|
if (Device.RuntimePlatform == Device.Windows)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj
Executable file → Normal file
1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj
Executable file → Normal file
@ -47,7 +47,6 @@
|
|||||||
<Compile Include="Controls\AddBasketButton.xaml.cs">
|
<Compile Include="Controls\AddBasketButton.xaml.cs">
|
||||||
<DependentUpon>AddBasketButton.xaml</DependentUpon>
|
<DependentUpon>AddBasketButton.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Controls\BindablePicker.cs" />
|
|
||||||
<Compile Include="Controls\CustomTabbedPage.cs" />
|
<Compile Include="Controls\CustomTabbedPage.cs" />
|
||||||
<Compile Include="Controls\ToggleButton.cs" />
|
<Compile Include="Controls\ToggleButton.cs" />
|
||||||
<Compile Include="Converters\CountToBoolConverter.cs" />
|
<Compile Include="Converters\CountToBoolConverter.cs" />
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<MtouchArch>i386, x86_64</MtouchArch>
|
<MtouchArch>i386, x86_64</MtouchArch>
|
||||||
<MtouchLink>SdkOnly</MtouchLink>
|
<MtouchLink>SdkOnly</MtouchLink>
|
||||||
<MtouchDebug>True</MtouchDebug>
|
<MtouchDebug>True</MtouchDebug>
|
||||||
<MtouchSdkVersion>10.1</MtouchSdkVersion>
|
<MtouchSdkVersion>10.2</MtouchSdkVersion>
|
||||||
<MtouchProfiling>False</MtouchProfiling>
|
<MtouchProfiling>False</MtouchProfiling>
|
||||||
<MtouchFastDev>False</MtouchFastDev>
|
<MtouchFastDev>False</MtouchFastDev>
|
||||||
<MtouchUseLlvm>False</MtouchUseLlvm>
|
<MtouchUseLlvm>False</MtouchUseLlvm>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user