diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs index 70759cc03..b6d93adfa 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml.cs @@ -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(); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/BindablePicker.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/BindablePicker.cs deleted file mode 100644 index 64ce79543..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/BindablePicker.cs +++ /dev/null @@ -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 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(); - } - } -} \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketMockService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketMockService.cs index f2f465a47..3c5a62e78 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketMockService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Basket/BasketMockService.cs @@ -12,8 +12,8 @@ namespace eShopOnContainers.Core.Services.Basket BuyerId = "9245fe4a-d402-451c-b9ed-9c1a04247482", Items = new List { - 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 } } }; diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs index d58b2b698..e37521d83 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Catalog/CatalogMockService.cs @@ -24,11 +24,11 @@ namespace eShopOnContainers.Core.Services.Catalog private ObservableCollection MockCatalog = new ObservableCollection { - 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> GetCatalogAsync() diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderMockService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderMockService.cs index 9d19d1ef6..6a2279500 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderMockService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Order/OrderMockService.cs @@ -53,8 +53,8 @@ namespace eShopOnContainers.Core.Services.Order private static List MockOrderItems = new List() { - 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 MockCardTypes = new List() diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs index abc7f70ac..0a4f52139 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/CatalogViewModel.cs @@ -102,7 +102,7 @@ namespace eShopOnContainers.Core.ViewModels private async Task FilterAsync() { - if (Brand == null && Type == null) + if (Brand == null || Type == null) { return; } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CatalogView.xaml b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CatalogView.xaml index d62ca11fc..d7d68d1f5 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CatalogView.xaml +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CatalogView.xaml @@ -60,8 +60,7 @@ + BackgroundColor="{StaticResource LightGreenColor}">