Browse Source

Merge pull request #185 from dotnet-architecture/xamarin

Minor fixes to Xamarin client.
pull/223/head
David Britch 7 years ago
committed by GitHub
parent
commit
cee9125c50
11 changed files with 26 additions and 159 deletions
  1. +2
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs
  2. +0
    -130
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/BindablePicker.cs
  3. +2
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketMockService.cs
  4. +5
    -5
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs
  5. +2
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderMockService.cs
  6. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs
  7. +1
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CatalogView.xaml
  8. +11
    -12
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/FiltersView.xaml
  9. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml.cs
  10. +0
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj
  11. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj

+ 2
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs View File

@ -18,7 +18,7 @@ namespace eShopOnContainers
InitApp();
if (Device.OS == TargetPlatform.Windows)
if (Device.RuntimePlatform == Device.Windows)
{
InitNavigation();
}
@ -40,7 +40,7 @@ namespace eShopOnContainers
{
base.OnStart();
if (Device.OS != TargetPlatform.Windows)
if (Device.RuntimePlatform != Device.Windows)
{
await InitNavigation();
}


+ 0
- 130
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/BindablePicker.cs View File

@ -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();
}
}
}

+ 2
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketMockService.cs View File

@ -12,8 +12,8 @@ namespace eShopOnContainers.Core.Services.Basket
BuyerId = "9245fe4a-d402-451c-b9ed-9c1a04247482",
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 = "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 = "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.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 }
}
};


+ 5
- 5
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs View File

@ -24,11 +24,11 @@ namespace eShopOnContainers.Core.Services.Catalog
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.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.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.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.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.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.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.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.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.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()


+ 2
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderMockService.cs View File

@ -53,8 +53,8 @@ namespace eShopOnContainers.Core.Services.Order
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.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.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.RuntimePlatform != Device.Windows ? "fake_product_03.png" : "Assets/fake_product_03.png" }
};
private static List<CardType> MockCardTypes = new List<CardType>()


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs View File

@ -102,7 +102,7 @@ namespace eShopOnContainers.Core.ViewModels
private async Task FilterAsync()
{
if (Brand == null && Type == null)
if (Brand == null || Type == null)
{
return;
}


+ 1
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CatalogView.xaml View File

@ -60,8 +60,7 @@
</Grid.RowDefinitions>
<!-- FILTERS -->
<Grid
BackgroundColor="{StaticResource LightGreenColor}"
IsEnabled="{Binding Products.Count, Converter={StaticResource CountToBoolConverter}}">
BackgroundColor="{StaticResource LightGreenColor}">
<Label
Text="FILTER"
Style="{StaticResource FilterLabelStyle}"/>


+ 11
- 12
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/FiltersView.xaml View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<slideOverKit:SlideMenuView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:slideOverKit="clr-namespace:SlideOverKit"
xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core"
xmlns:slideOverKit="clr-namespace:SlideOverKit"
x:Class="eShopOnContainers.Core.Views.FiltersView"
MenuOrientations="TopToBottom"
BackgroundColor="{StaticResource BackgroundColor}"
@ -13,7 +12,7 @@
<ResourceDictionary>
<Style x:Key="FilterPickerStyle"
TargetType="{x:Type controls:BindablePicker}">
TargetType="{x:Type Picker}">
<Setter Property="HeightRequest"
Value="48" />
<Setter Property="BackgroundColor"
@ -70,35 +69,35 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- BRAND -->
<controls:BindablePicker
<Picker
Grid.Row="0"
Title="BRAND"
ItemsSource="{Binding Brands}"
SelectedItem="{Binding Brand, Mode=TwoWay}"
Style="{StaticResource FilterPickerStyle}">
<controls:BindablePicker.HeightRequest>
<Picker.HeightRequest>
<OnPlatform
x:TypeArguments="x:Double"
Android="48"
iOS="48"
WinPhone="36"/>
</controls:BindablePicker.HeightRequest>
</controls:BindablePicker>
</Picker.HeightRequest>
</Picker>
<!-- TYPE -->
<controls:BindablePicker
<Picker
Grid.Row="1"
Title="TYPE"
ItemsSource="{Binding Types}"
SelectedItem="{Binding Type, Mode=TwoWay}"
Style="{StaticResource FilterPickerStyle}">
<controls:BindablePicker.HeightRequest>
<Picker.HeightRequest>
<OnPlatform
x:TypeArguments="x:Double"
Android="48"
iOS="48"
WinPhone="36"/>
</controls:BindablePicker.HeightRequest>
</controls:BindablePicker>
</Picker.HeightRequest>
</Picker>
<Button
Grid.Row="2"
Text="Apply"


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml.cs View File

@ -41,7 +41,7 @@ namespace eShopOnContainers.Core.Views
public async Task AnimateIn()
{
if (Device.OS == TargetPlatform.Windows)
if (Device.RuntimePlatform == Device.Windows)
{
return;
}


+ 0
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj View File

@ -47,7 +47,6 @@
<Compile Include="Controls\AddBasketButton.xaml.cs">
<DependentUpon>AddBasketButton.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\BindablePicker.cs" />
<Compile Include="Controls\CustomTabbedPage.cs" />
<Compile Include="Controls\ToggleButton.cs" />
<Compile Include="Converters\CountToBoolConverter.cs" />


+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj View File

@ -26,7 +26,7 @@
<MtouchArch>i386, x86_64</MtouchArch>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchDebug>True</MtouchDebug>
<MtouchSdkVersion>10.1</MtouchSdkVersion>
<MtouchSdkVersion>10.2</MtouchSdkVersion>
<MtouchProfiling>False</MtouchProfiling>
<MtouchFastDev>False</MtouchFastDev>
<MtouchUseLlvm>False</MtouchUseLlvm>


Loading…
Cancel
Save