Finished UWP tab renderer (Badges)
Change dynamically services (DI)
This commit is contained in:
parent
06abfa83dc
commit
7d55e943fb
@ -4,6 +4,6 @@
|
||||
{
|
||||
public const string RegisterWebsite = "http://104.40.62.65/Account/Register";
|
||||
|
||||
public const string CatalogEndpoint = "http://104.40.62.65:5101/api/v1/catalog";
|
||||
public const string CatalogEndpoint = "http://104.40.62.65:5101/";
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace eShopOnContainers.Core.Models.Catalog
|
||||
{
|
||||
public class CatalogRoot
|
||||
{
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public int Count { get; set; }
|
||||
public List<CatalogItem> Data { get; set; }
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using eShopOnContainers.Core.Models.Catalog;
|
||||
using eShopOnContainers.Core.Services.RequestProvider;
|
||||
using System.Collections.Generic;
|
||||
using eShopOnContainers.Core.Extensions;
|
||||
|
||||
namespace eShopOnContainers.Core.Services.Catalog
|
||||
@ -12,6 +11,18 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
private readonly IRequestProvider _requestProvider;
|
||||
|
||||
private ObservableCollection<CatalogBrand> MockCatalogBrand = new ObservableCollection<CatalogBrand>
|
||||
{
|
||||
new CatalogBrand { CatalogBrandId = 1, Name = "Azure" },
|
||||
new CatalogBrand { CatalogBrandId = 2, Name = "Visual Studio" }
|
||||
};
|
||||
|
||||
private ObservableCollection<CatalogType> MockCatalogType = new ObservableCollection<CatalogType>
|
||||
{
|
||||
new CatalogType { CatalogTypeId = 1, Name = "Mug" },
|
||||
new CatalogType { CatalogTypeId = 2, Name = "T-Shirt" }
|
||||
};
|
||||
|
||||
public CatalogService(IRequestProvider requestProvider)
|
||||
{
|
||||
_requestProvider = requestProvider;
|
||||
@ -26,19 +37,16 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
{
|
||||
UriBuilder builder = new UriBuilder(GlobalSetting.CatalogEndpoint);
|
||||
|
||||
builder.Path = "/items";
|
||||
builder.Path = "api/v1/catalog/items";
|
||||
|
||||
string uri = builder.ToString();
|
||||
|
||||
IEnumerable<CatalogItem> catalogItems =
|
||||
await _requestProvider.GetAsync<IEnumerable<CatalogItem>>(uri);
|
||||
System.Diagnostics.Debug.WriteLine(uri);
|
||||
|
||||
return catalogItems.ToObservableCollection();
|
||||
}
|
||||
CatalogRoot catalog =
|
||||
await _requestProvider.GetAsync<CatalogRoot>(uri);
|
||||
|
||||
public Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return catalog?.Data?.ToObservableCollection();
|
||||
}
|
||||
|
||||
public Task<CatalogItem> GetCatalogItemAsync(string id)
|
||||
@ -46,9 +54,18 @@ namespace eShopOnContainers.Core.Services.Catalog
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync()
|
||||
public async Task<ObservableCollection<CatalogBrand>> GetCatalogBrandAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
await Task.Delay(500);
|
||||
|
||||
return MockCatalogBrand;
|
||||
}
|
||||
|
||||
public async Task<ObservableCollection<CatalogType>> GetCatalogTypeAsync()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
|
||||
return MockCatalogType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ namespace eShopOnContainers.Core.Services.RequestProvider
|
||||
await HandleResponse(response);
|
||||
|
||||
string serialized = await response.Content.ReadAsStringAsync();
|
||||
TResult result = await Task.Run(() => JsonConvert.DeserializeObject<TResult>(serialized, _serializerSettings));
|
||||
TResult result = await Task.Run(() =>
|
||||
JsonConvert.DeserializeObject<TResult>(serialized, _serializerSettings));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -6,11 +6,13 @@ using System;
|
||||
using eShopOnContainers.Core.Services.Catalog;
|
||||
using eShopOnContainers.Core.Services.OpenUrl;
|
||||
using eShopOnContainers.Core.Services.User;
|
||||
using eShopOnContainers.Core.Services.RequestProvider;
|
||||
|
||||
namespace eShopOnContainers.ViewModels.Base
|
||||
{
|
||||
public class ViewModelLocator
|
||||
{
|
||||
private bool _useMockService;
|
||||
private readonly IUnityContainer _unityContainer;
|
||||
|
||||
private static readonly ViewModelLocator _instance = new ViewModelLocator();
|
||||
@ -20,6 +22,12 @@ namespace eShopOnContainers.ViewModels.Base
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public bool UseMockService
|
||||
{
|
||||
get { return _useMockService; }
|
||||
set { _useMockService = value; ; }
|
||||
}
|
||||
|
||||
protected ViewModelLocator()
|
||||
{
|
||||
_unityContainer = new UnityContainer();
|
||||
@ -28,6 +36,7 @@ namespace eShopOnContainers.ViewModels.Base
|
||||
_unityContainer.RegisterType<IDialogService, DialogService>();
|
||||
RegisterSingleton<INavigationService, NavigationService>();
|
||||
_unityContainer.RegisterType<IOpenUrlService, OpenUrlService>();
|
||||
_unityContainer.RegisterType<IRequestProvider, RequestProvider>();
|
||||
|
||||
_unityContainer.RegisterType<ICatalogService, CatalogMockService>();
|
||||
_unityContainer.RegisterType<IOrdersService, OrdersMockService>();
|
||||
@ -44,6 +53,26 @@ namespace eShopOnContainers.ViewModels.Base
|
||||
_unityContainer.RegisterType<SettingsViewModel>();
|
||||
}
|
||||
|
||||
public void UpdateServices(bool useMockServices)
|
||||
{
|
||||
if (!useMockServices)
|
||||
{
|
||||
_unityContainer.RegisterInstance<ICatalogService>(new CatalogMockService());
|
||||
_unityContainer.RegisterInstance<IOrdersService>(new OrdersMockService());
|
||||
_unityContainer.RegisterInstance<IUserService>(new UserMockService());
|
||||
|
||||
UseMockService = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var requestProvider = Resolve<IRequestProvider>();
|
||||
_unityContainer.RegisterInstance<ICatalogService>(new CatalogService(requestProvider));
|
||||
|
||||
UseMockService = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T Resolve<T>()
|
||||
{
|
||||
return _unityContainer.Resolve<T>();
|
||||
|
@ -1,9 +1,33 @@
|
||||
using eShopOnContainers.ViewModels.Base;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels
|
||||
{
|
||||
public class SettingsViewModel : ViewModelBase
|
||||
{
|
||||
private bool _useMockServices;
|
||||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
UseMockServices = ViewModelLocator.Instance.UseMockService;
|
||||
}
|
||||
|
||||
public bool UseMockServices
|
||||
{
|
||||
get { return _useMockServices; }
|
||||
set
|
||||
{
|
||||
_useMockServices = value;
|
||||
RaisePropertyChanged(() => UseMockServices);
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand MockServicesCommand => new Command(MockServices);
|
||||
|
||||
private void MockServices()
|
||||
{
|
||||
ViewModelLocator.Instance.UpdateServices(UseMockServices);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -77,7 +77,9 @@
|
||||
<controls:ToggleButton
|
||||
Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Animate="True"
|
||||
Animate="True"
|
||||
Checked="{Binding UseMockServices, Mode=TwoWay}"
|
||||
Command="{Binding MockServicesCommand}"
|
||||
Style="{StaticResource SettingsToggleButtonStyle}">
|
||||
<controls:ToggleButton.CheckedImage>
|
||||
<OnPlatform x:TypeArguments="ImageSource"
|
||||
|
@ -4,7 +4,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
@ -65,6 +65,7 @@
|
||||
<Compile Include="Helpers\EasingHelper.cs" />
|
||||
<Compile Include="Helpers\NumericHelper.cs" />
|
||||
<Compile Include="Models\Catalog\CatalogBrand.cs" />
|
||||
<Compile Include="Models\Catalog\CatalogRoot.cs" />
|
||||
<Compile Include="Models\Catalog\CatalogType.cs" />
|
||||
<Compile Include="Models\Navigation\TabParameter.cs" />
|
||||
<Compile Include="Models\Orders\Order.cs" />
|
||||
@ -193,8 +194,8 @@
|
||||
<HintPath>..\..\packages\modernhttpclient.2.4.2\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SlideOverKit, Version=1.0.6135.18790, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
@ -6,7 +6,7 @@
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="modernhttpclient" version="2.4.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="SlideOverKit" version="2.1.4" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
|
||||
<package id="StyleCop.MSBuild" version="5.0.0-alpha01" targetFramework="portable45-net45+win8+wp8+wpa81" developmentDependency="true" />
|
||||
|
@ -16,7 +16,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
|
@ -93,6 +93,7 @@
|
||||
<HintPath>..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -107,8 +108,8 @@
|
||||
</Reference>
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.9.0.2-beta1\lib\netstandard1.1\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="OkHttp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
@ -4,11 +4,34 @@
|
||||
<package id="Acr.UserDialogs" version="6.3.1" targetFramework="monoandroid70" />
|
||||
<package id="AndHUD" version="1.2.0" targetFramework="monoandroid70" />
|
||||
<package id="CommonServiceLocator" version="1.3" targetFramework="monoandroid70" />
|
||||
<package id="Microsoft.CSharp" version="4.0.1" targetFramework="monoandroid70" />
|
||||
<package id="modernhttpclient" version="2.4.2" targetFramework="monoandroid70" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="monoandroid70" />
|
||||
<package id="Newtonsoft.Json" version="9.0.2-beta1" targetFramework="monoandroid70" />
|
||||
<package id="SlideOverKit" version="2.1.4" targetFramework="monoandroid70" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="monoandroid70" />
|
||||
<package id="StyleCop.MSBuild" version="5.0.0-alpha01" targetFramework="monoandroid70" developmentDependency="true" />
|
||||
<package id="System.Collections" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Dynamic.Runtime" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Globalization" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.IO" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.Linq" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.ObjectModel" version="4.0.12" targetFramework="monoandroid70" />
|
||||
<package id="System.Reflection" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="monoandroid70" />
|
||||
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="monoandroid70" />
|
||||
<package id="System.Runtime" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.Runtime.Numerics" version="4.0.1" targetFramework="monoandroid70" />
|
||||
<package id="System.Runtime.Serialization.Primitives" version="4.1.1" targetFramework="monoandroid70" />
|
||||
<package id="System.Text.Encoding" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Text.Encoding.Extensions" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="monoandroid70" />
|
||||
<package id="System.Threading" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="monoandroid70" />
|
||||
<package id="Unity" version="4.0.1" targetFramework="monoandroid70" />
|
||||
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid70" />
|
||||
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid70" />
|
||||
|
@ -6,6 +6,14 @@
|
||||
<assemblyIdentity name="xunit.runner.utility.dotnet" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.3444" newVersion="2.2.0.3444" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
</dict>
|
||||
<dict/>
|
||||
</plist>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="xunit.runner.utility.dotnet" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@ -58,6 +58,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -3,12 +3,22 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:eShopOnContainers.UWP"
|
||||
xmlns:converters="using:eShopOnContainers.Windows.Converters"
|
||||
xmlns:controls="using:eShopOnContainers.Windows.Controls"
|
||||
RequestedTheme="Light">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
<!-- COLORS -->
|
||||
<Color x:Key="NativeAccentColor">#00A69C</Color>
|
||||
<Color x:Key="NativeLightGreenColor">#83D01B</Color>
|
||||
|
||||
<!-- CONVERTERS -->
|
||||
<converters:TabIconConverter x:Key="TabIconConverter" />
|
||||
<converters:TabBadgeColorConverter x:Key="TabBadgeColorConverter" />
|
||||
<converters:TabBadgeTextConverter x:Key="TabBadgeTextConverter" />
|
||||
|
||||
<!-- STYLES -->
|
||||
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
|
||||
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
|
||||
@ -594,6 +604,18 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="TabbedPageHeaderTemplate">
|
||||
<Grid>
|
||||
<ContentPresenter>
|
||||
<controls:TabItem
|
||||
Label="{Binding Title}"
|
||||
Icon="{Binding Icon, Converter={StaticResource TabIconConverter}}"
|
||||
BadgeColor="{Binding Converter={StaticResource TabBadgeColorConverter}}"
|
||||
BadgeText="{Binding Converter={StaticResource TabBadgeTextConverter}}"/>
|
||||
</ContentPresenter>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<UserControl
|
||||
x:Name="Control"
|
||||
x:Class="eShopOnContainers.Windows.Controls.TabItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
@ -11,13 +12,22 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
<Style x:Key="TabMainPanelStyle" TargetType="StackPanel">
|
||||
<Setter Property="Height" Value="48" />
|
||||
<Setter Property="Width" Value="60" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TabIconStyle" TargetType="Image">
|
||||
<Setter Property="Height" Value="20" />
|
||||
<Setter Property="Width" Value="20" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="0,12,0,0" />
|
||||
<Setter Property="Margin" Value="0, 4" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TabTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="FontFamily" Value="Segoe UI" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="LineStackingStrategy" Value="BlockLineHeight" />
|
||||
<Setter Property="LineHeight" Value="14" />
|
||||
<Setter Property="MaxLines" Value="2" />
|
||||
@ -27,14 +37,16 @@
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TabBadgeStyle" TargetType="Grid">
|
||||
<Setter Property="Height" Value="24" />
|
||||
<Setter Property="Width" Value="24" />
|
||||
<Setter Property="Height" Value="16" />
|
||||
<Setter Property="Width" Value="16" />
|
||||
<Setter Property="CornerRadius" Value="24" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="Margin" Value="6, 0, 0, 6" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="BadgeTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="FontSize" Value="10" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
@ -43,22 +55,23 @@
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<StackPanel
|
||||
Style="{StaticResource TabMainPanelStyle}">
|
||||
<!-- TAB ICON -->
|
||||
<Image
|
||||
Source="{Binding Icon}"
|
||||
Source="{Binding ElementName=Control, Path=Icon}"
|
||||
Style="{StaticResource TabIconStyle}"/>
|
||||
<!-- TAB TEXT -->
|
||||
<TextBlock
|
||||
Text="{Binding Label}"
|
||||
Text="{Binding ElementName=Control, Path=Label}"
|
||||
Style="{StaticResource TabTextStyle}" />
|
||||
</StackPanel>
|
||||
<!-- TAB BADGE -->
|
||||
<Grid
|
||||
Background="{Binding BadgeColor}"
|
||||
Background="{Binding ElementName=Control, Path=BadgeColor}"
|
||||
Style="{StaticResource TabBadgeStyle}">
|
||||
<TextBlock
|
||||
Text="{Binding BadgeText}"
|
||||
Text="{Binding ElementName=Control, Path=BadgeText}"
|
||||
Style="{StaticResource BadgeTextStyle}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace eShopOnContainers.Windows.Controls
|
||||
{
|
||||
@ -26,14 +27,14 @@ namespace eShopOnContainers.Windows.Controls
|
||||
public static readonly DependencyProperty BadgeTextProperty =
|
||||
DependencyProperty.Register("BadgeText", typeof(string), typeof(TabItem), null);
|
||||
|
||||
public string BadgeColor
|
||||
public SolidColorBrush BadgeColor
|
||||
{
|
||||
get { return GetValue(BadgeColorProperty) as string; }
|
||||
get { return GetValue(BadgeColorProperty) as SolidColorBrush; }
|
||||
set { SetValue(BadgeColorProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty BadgeColorProperty =
|
||||
DependencyProperty.Register("BadgeColor", typeof(string), typeof(TabItem), null);
|
||||
DependencyProperty.Register("BadgeColor", typeof(SolidColorBrush), typeof(TabItem), null);
|
||||
|
||||
public string Label
|
||||
{
|
||||
@ -44,8 +45,6 @@ namespace eShopOnContainers.Windows.Controls
|
||||
public TabItem()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
this.DataContext = this;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using eShopOnContainers.Core.Controls;
|
||||
using eShopOnContainers.Windows.Helpers;
|
||||
using System;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Xamarin.Forms;
|
||||
using UI = Windows.UI;
|
||||
|
||||
namespace eShopOnContainers.Windows.Converters
|
||||
{
|
||||
public class TabBadgeColorConverter : UI.Xaml.Data.IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is Page)
|
||||
{
|
||||
var badgeColor = CustomTabbedPage.GetBadgeColor((Page)value);
|
||||
|
||||
var color = ColorHelper.XamarinFormColorToWindowsColor(badgeColor);
|
||||
|
||||
return new SolidColorBrush(color);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using eShopOnContainers.Core.Controls;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
using UI = Windows.UI;
|
||||
|
||||
namespace eShopOnContainers.Windows.Converters
|
||||
{
|
||||
public class TabBadgeTextConverter : UI.Xaml.Data.IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is Page)
|
||||
{
|
||||
var badgeText = CustomTabbedPage.GetBadgeText((Page)value);
|
||||
|
||||
return badgeText;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
using UI = Windows.UI;
|
||||
|
||||
namespace eShopOnContainers.Windows.Converters
|
||||
{
|
||||
public class TabIconConverter : UI.Xaml.Data.IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is FileImageSource)
|
||||
{
|
||||
return string.Format("ms-appx:///{0}", ((FileImageSource)value).File);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,375 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace eShopOnContainers.Windows.Extensions
|
||||
{
|
||||
public static class VisualTreeExtensions
|
||||
{
|
||||
internal static IEnumerable<DependencyObject> GetVisualChildren(this DependencyObject parent)
|
||||
{
|
||||
Debug.Assert(parent != null, "The parent cannot be null!");
|
||||
var childCount = VisualTreeHelper.GetChildrenCount(parent);
|
||||
for (int counter = 0; counter < childCount; counter++)
|
||||
{
|
||||
yield return VisualTreeHelper.GetChild(parent, counter);
|
||||
}
|
||||
}
|
||||
|
||||
internal static IEnumerable<FrameworkElement> GetLogicalChildrenBreathFirst(this FrameworkElement parent)
|
||||
{
|
||||
Debug.Assert(parent != null, "The parent cannot be null!");
|
||||
var queue =
|
||||
new Queue<FrameworkElement>(parent.GetVisualChildren().OfType<FrameworkElement>());
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var element = queue.Dequeue();
|
||||
yield return element;
|
||||
foreach (var visualChild in element.GetVisualChildren().OfType<FrameworkElement>())
|
||||
{
|
||||
queue.Enqueue(visualChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static IEnumerable<FrameworkElement> GetVisualAncestors(this FrameworkElement node)
|
||||
{
|
||||
var parent = node.GetVisualParent();
|
||||
while (parent != null)
|
||||
{
|
||||
yield return parent;
|
||||
parent = parent.GetVisualParent();
|
||||
}
|
||||
}
|
||||
|
||||
internal static FrameworkElement GetVisualParent(this FrameworkElement node)
|
||||
{
|
||||
return VisualTreeHelper.GetParent(node) as FrameworkElement;
|
||||
}
|
||||
|
||||
internal static T GetParentByType<T>(this DependencyObject element)
|
||||
where T : FrameworkElement
|
||||
{
|
||||
Debug.Assert(element != null, "The element cannot be null!");
|
||||
var parent = VisualTreeHelper.GetParent(element);
|
||||
while (parent != null)
|
||||
{
|
||||
var result = parent as T;
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
parent = VisualTreeHelper.GetParent(parent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static T GetFirstDescendantOfType<T>(this DependencyObject start) where T : DependencyObject
|
||||
{
|
||||
return start.GetDescendantsOfType<T>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetDescendantsOfType<T>(this DependencyObject start) where T : DependencyObject
|
||||
{
|
||||
return start.GetDescendants().OfType<T>();
|
||||
}
|
||||
|
||||
public static IEnumerable<DependencyObject> GetDescendants(this DependencyObject start)
|
||||
{
|
||||
if (start == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var queue = new Queue<DependencyObject>();
|
||||
|
||||
var popup = start as Popup;
|
||||
|
||||
if (popup != null)
|
||||
{
|
||||
if (popup.Child != null)
|
||||
{
|
||||
queue.Enqueue(popup.Child);
|
||||
yield return popup.Child;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var count = VisualTreeHelper.GetChildrenCount(start);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(start, i);
|
||||
queue.Enqueue(child);
|
||||
yield return child;
|
||||
}
|
||||
}
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var parent = queue.Dequeue();
|
||||
|
||||
popup = parent as Popup;
|
||||
|
||||
if (popup != null)
|
||||
{
|
||||
if (popup.Child != null)
|
||||
{
|
||||
queue.Enqueue(popup.Child);
|
||||
yield return popup.Child;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var count = VisualTreeHelper.GetChildrenCount(parent);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(parent, i);
|
||||
yield return child;
|
||||
queue.Enqueue(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<DependencyObject> GetChildren(this DependencyObject parent)
|
||||
{
|
||||
var popup = parent as Popup;
|
||||
|
||||
if (popup?.Child != null)
|
||||
{
|
||||
yield return popup.Child;
|
||||
yield break;
|
||||
}
|
||||
|
||||
var count = VisualTreeHelper.GetChildrenCount(parent);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(parent, i);
|
||||
yield return child;
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<DependencyObject> GetChildrenByZIndex(
|
||||
this DependencyObject parent)
|
||||
{
|
||||
int i = 0;
|
||||
var indexedChildren =
|
||||
parent.GetChildren().Cast<FrameworkElement>().Select(
|
||||
child => new { Index = i++, ZIndex = Canvas.GetZIndex(child), Child = child });
|
||||
|
||||
return
|
||||
from indexedChild in indexedChildren
|
||||
orderby indexedChild.ZIndex, indexedChild.Index
|
||||
select indexedChild.Child;
|
||||
}
|
||||
|
||||
public static T GetFirstAncestorOfType<T>(this DependencyObject start) where T : DependencyObject
|
||||
{
|
||||
return start.GetAncestorsOfType<T>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetAncestorsOfType<T>(this DependencyObject start) where T : DependencyObject
|
||||
{
|
||||
return start.GetAncestors().OfType<T>();
|
||||
}
|
||||
|
||||
public static IEnumerable<DependencyObject> GetAncestors(this DependencyObject start)
|
||||
{
|
||||
var parent = VisualTreeHelper.GetParent(start);
|
||||
|
||||
while (parent != null)
|
||||
{
|
||||
yield return parent;
|
||||
parent = VisualTreeHelper.GetParent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<DependencyObject> GetSiblings(this DependencyObject start)
|
||||
{
|
||||
var parent = VisualTreeHelper.GetParent(start);
|
||||
|
||||
if (parent == null)
|
||||
{
|
||||
yield return start;
|
||||
}
|
||||
else
|
||||
{
|
||||
var count = VisualTreeHelper.GetChildrenCount(parent);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(parent, i);
|
||||
yield return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsInVisualTree(this DependencyObject dob)
|
||||
{
|
||||
if (DesignMode.DesignModeEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: consider making it work with Popups too.
|
||||
if (Window.Current == null)
|
||||
{
|
||||
// This may happen when a picker or CameraCaptureUI etc. is open.
|
||||
return false;
|
||||
}
|
||||
|
||||
return Window.Current.Content != null && dob.GetAncestors().Contains(Window.Current.Content);
|
||||
}
|
||||
|
||||
public static Point GetPosition(this FrameworkElement dob, Point origin = new Point(), FrameworkElement relativeTo = null)
|
||||
{
|
||||
if (DesignMode.DesignModeEnabled)
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
||||
if (relativeTo == null)
|
||||
{
|
||||
relativeTo = Window.Current.Content as FrameworkElement;
|
||||
}
|
||||
|
||||
if (relativeTo == null)
|
||||
{
|
||||
throw new InvalidOperationException("Element not in visual tree.");
|
||||
}
|
||||
|
||||
var absoluteOrigin = new Point(relativeTo.ActualWidth * origin.X, relativeTo.ActualHeight * origin.X);
|
||||
|
||||
if (dob == relativeTo)
|
||||
{
|
||||
return absoluteOrigin;
|
||||
}
|
||||
|
||||
var ancestors = dob.GetAncestors().ToArray();
|
||||
|
||||
if (!ancestors.Contains(relativeTo))
|
||||
{
|
||||
throw new InvalidOperationException("Element not in visual tree.");
|
||||
}
|
||||
|
||||
return
|
||||
dob
|
||||
.TransformToVisual(relativeTo)
|
||||
.TransformPoint(absoluteOrigin);
|
||||
}
|
||||
|
||||
public static Rect GetBoundingRect(this FrameworkElement dob, FrameworkElement relativeTo = null)
|
||||
{
|
||||
if (DesignMode.DesignModeEnabled)
|
||||
{
|
||||
return Rect.Empty;
|
||||
}
|
||||
|
||||
if (relativeTo == null)
|
||||
{
|
||||
relativeTo = Window.Current.Content as FrameworkElement;
|
||||
}
|
||||
|
||||
if (relativeTo == null)
|
||||
{
|
||||
throw new InvalidOperationException("Element not in visual tree.");
|
||||
}
|
||||
|
||||
if (dob == relativeTo)
|
||||
{
|
||||
return new Rect(0, 0, relativeTo.ActualWidth, relativeTo.ActualHeight);
|
||||
}
|
||||
|
||||
var ancestors = dob.GetAncestors().ToArray();
|
||||
|
||||
if (!ancestors.Contains(relativeTo))
|
||||
{
|
||||
throw new InvalidOperationException("Element not in visual tree.");
|
||||
}
|
||||
|
||||
var topLeft =
|
||||
dob
|
||||
.TransformToVisual(relativeTo)
|
||||
.TransformPoint(new Point());
|
||||
var topRight =
|
||||
dob
|
||||
.TransformToVisual(relativeTo)
|
||||
.TransformPoint(
|
||||
new Point(
|
||||
dob.ActualWidth,
|
||||
0));
|
||||
var bottomLeft =
|
||||
dob
|
||||
.TransformToVisual(relativeTo)
|
||||
.TransformPoint(
|
||||
new Point(
|
||||
0,
|
||||
dob.ActualHeight));
|
||||
var bottomRight =
|
||||
dob
|
||||
.TransformToVisual(relativeTo)
|
||||
.TransformPoint(
|
||||
new Point(
|
||||
dob.ActualWidth,
|
||||
dob.ActualHeight));
|
||||
|
||||
var minX = new[] { topLeft.X, topRight.X, bottomLeft.X, bottomRight.X }.Min();
|
||||
var maxX = new[] { topLeft.X, topRight.X, bottomLeft.X, bottomRight.X }.Max();
|
||||
var minY = new[] { topLeft.Y, topRight.Y, bottomLeft.Y, bottomRight.Y }.Min();
|
||||
var maxY = new[] { topLeft.Y, topRight.Y, bottomLeft.Y, bottomRight.Y }.Max();
|
||||
|
||||
return new Rect(minX, minY, maxX - minX, maxY - minY);
|
||||
}
|
||||
|
||||
private static void ExploreTree(List<DependencyObject> list, DependencyObject obj)
|
||||
{
|
||||
if (list != null && obj != null)
|
||||
{
|
||||
int childrens = VisualTreeHelper.GetChildrenCount(obj);
|
||||
for (int x = 0; x < childrens; x++)
|
||||
{
|
||||
DependencyObject tmp = VisualTreeHelper.GetChild(obj, x);
|
||||
list.Add(tmp);
|
||||
ExploreTree(list, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<DependencyObject> GetVisualTree(DependencyObject obj)
|
||||
{
|
||||
var tmp = new List<DependencyObject>();
|
||||
ExploreTree(tmp, obj);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public static T FindNameInVisualTree<T>(DependencyObject root, string name)
|
||||
{
|
||||
T res = default(T);
|
||||
List<DependencyObject> tree = null;
|
||||
tree = GetVisualTree(root);
|
||||
for (int x = 0; x < tree.Count; x++)
|
||||
{
|
||||
if (tree[x] is FrameworkElement)
|
||||
{
|
||||
if (((FrameworkElement)tree[x]).Name == name)
|
||||
{
|
||||
res = (T)((object)tree[x]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using Xamarin.Forms;
|
||||
using UI = Windows.UI;
|
||||
|
||||
namespace eShopOnContainers.Windows.Helpers
|
||||
{
|
||||
public static class ColorHelper
|
||||
{
|
||||
public static UI.Color XamarinFormColorToWindowsColor(Color xamarinColor)
|
||||
{
|
||||
return UI.Color.FromArgb((byte)(xamarinColor.A * 255),
|
||||
(byte)(xamarinColor.R * 255),
|
||||
(byte)(xamarinColor.G * 255),
|
||||
(byte)(xamarinColor.B * 255));
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
</Grid>
|
||||
|
@ -1,8 +1,14 @@
|
||||
using eShopOnContainers.Windows.Renderers;
|
||||
using eShopOnContainers.Core.Controls;
|
||||
using eShopOnContainers.Windows.Controls;
|
||||
using eShopOnContainers.Windows.Extensions;
|
||||
using eShopOnContainers.Windows.Helpers;
|
||||
using eShopOnContainers.Windows.Renderers;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.Platform.UWP;
|
||||
using Xaml = Windows.UI.Xaml;
|
||||
|
||||
[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedPageRenderer))]
|
||||
namespace eShopOnContainers.Windows.Renderers
|
||||
@ -16,7 +22,7 @@ namespace eShopOnContainers.Windows.Renderers
|
||||
|
||||
if (Control == null)
|
||||
{
|
||||
Debug.WriteLine("No TabLayout found. Badge not added.");
|
||||
Debug.WriteLine("No FormsPivot found. Badge not added.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -28,7 +34,47 @@ namespace eShopOnContainers.Windows.Renderers
|
||||
|
||||
private void AddTabBadge(int tabIndex)
|
||||
{
|
||||
|
||||
var element = Element.Children[tabIndex];
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
|
||||
var dataTemplate = Xaml.Application.Current.Resources["TabbedPageHeaderTemplate"] as
|
||||
Xaml.DataTemplate;
|
||||
|
||||
Control.HeaderTemplate = dataTemplate;
|
||||
|
||||
element.PropertyChanged += OnTabbedPagePropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnTabbedPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
var element = sender as Element;
|
||||
|
||||
if (element == null)
|
||||
return;
|
||||
|
||||
var tabItems = Control.GetDescendantsOfType<TabItem>();
|
||||
var tabItem = tabItems.FirstOrDefault(t => t.Label == ((Page)element).Title);
|
||||
|
||||
if(tabItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == CustomTabbedPage.BadgeTextProperty.PropertyName)
|
||||
{
|
||||
tabItem.BadgeText = CustomTabbedPage.GetBadgeText(element);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == CustomTabbedPage.BadgeColorProperty.PropertyName)
|
||||
{
|
||||
tabItem.BadgeColor = new Xaml.Media.SolidColorBrush(
|
||||
ColorHelper.XamarinFormColorToWindowsColor(
|
||||
CustomTabbedPage.GetBadgeColor(element)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -32,6 +32,5 @@ namespace eShopOnContainers.Windows.Renderers
|
||||
base.Dispose(disposing);
|
||||
_handler = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,12 @@
|
||||
<Compile Include="Controls\TabItem.xaml.cs">
|
||||
<DependentUpon>TabItem.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Converters\TabBadgeColorConverter.cs" />
|
||||
<Compile Include="Converters\TabBadgeTextConverter.cs" />
|
||||
<Compile Include="Converters\TabIconConverter.cs" />
|
||||
<Compile Include="Effects\EntryLineColorEffect.cs" />
|
||||
<Compile Include="Extensions\VisualTreeExtensions.cs" />
|
||||
<Compile Include="Helpers\ColorHelper.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -2,6 +2,7 @@
|
||||
"dependencies": {
|
||||
"Acr.UserDialogs": "6.3.1",
|
||||
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
|
||||
"Newtonsoft.Json": "9.0.1",
|
||||
"SlideOverKit": "2.1.4",
|
||||
"StyleCop.MSBuild": "5.0.0-alpha01",
|
||||
"Unity": "4.0.1",
|
||||
|
@ -4,7 +4,7 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
|
@ -181,8 +181,8 @@
|
||||
<HintPath>..\..\packages\modernhttpclient.2.4.2\lib\Xamarin.iOS10\ModernHttpClient.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SlideOverKit, Version=1.0.6135.18790, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
@ -4,7 +4,7 @@
|
||||
<package id="Acr.UserDialogs" version="6.3.1" targetFramework="xamarinios10" />
|
||||
<package id="CommonServiceLocator" version="1.3" targetFramework="xamarinios10" />
|
||||
<package id="modernhttpclient" version="2.4.2" targetFramework="xamarinios10" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="xamarinios10" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="xamarinios10" />
|
||||
<package id="SlideOverKit" version="2.1.4" targetFramework="xamarinios10" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="xamarinios10" />
|
||||
<package id="StyleCop.MSBuild" version="5.0.0-alpha01" targetFramework="xamarinios10" developmentDependency="true" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user