Browse Source

Adapt UI to UWP App

pull/49/merge
Javier Suárez Ruiz 8 years ago
parent
commit
a158233b94
19 changed files with 345 additions and 39 deletions
  1. +33
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml
  2. +86
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/CartButton.xaml
  3. +12
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/CartButton.xaml.cs
  4. +1
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Effects/LineColorEffect.cs
  5. +2
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs
  6. +2
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CustomNavigationPage.xaml
  7. +25
    -9
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/FiltersView.xaml
  8. +17
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml
  9. +1
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/MainView.xaml
  10. +1
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/OrderDetailView.xaml
  11. +1
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/OrderItemTemplate.xaml
  12. +4
    -21
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/ProductTemplate.xaml
  13. +9
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj
  14. +46
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Windows/App.xaml
  15. BIN
      src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Assets/circle_button_background.png
  16. +2
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Effects/EntryLineColorEffect.cs
  17. +0
    -1
      src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Renderers/CustomTabbedPageRenderer.cs
  18. +1
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj
  19. +102
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Renderers/CustomTabbedPageRenderer.cs

+ 33
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml View File

@ -136,6 +136,39 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style x:Key="UwpEntryStyle"
TargetType="{x:Type Entry}">
<Setter Property="FontFamily"
Value="{StaticResource MontserratRegular}" />
<Setter Property="TextColor"
Value="{StaticResource BlackColor}" />
<Setter Property="PlaceholderColor"
Value="{StaticResource BlackColor}" />
<Setter Property="FontSize"
Value="{StaticResource LargeSize}" />
<Setter Property="HorizontalOptions"
Value="FillAndExpand" />
<Setter Property="FontAttributes"
Value="Bold" />
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="Opacity"
Value="0.6" />
<Setter Property="effects:LineColorEffect.ApplyLineColor"
Value="True" />
<Setter Property="effects:LineColorEffect.LineColor"
Value="Gray" />
<Style.Triggers>
<Trigger TargetType="Entry"
Property="IsFocused"
Value="True">
<Setter Property="Opacity" Value="1" />
<Setter Property="effects:LineColorEffect.LineColor"
Value="{StaticResource GreenColor}" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="NavigationPage"> <Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="{StaticResource GreenColor}"/> <Setter Property="BarBackgroundColor" Value="{StaticResource GreenColor}"/>
<Setter Property="BarTextColor" Value="{StaticResource WhiteColor}"/> <Setter Property="BarTextColor" Value="{StaticResource WhiteColor}"/>


+ 86
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/CartButton.xaml View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="eShopOnContainers.Core.Controls.CartButton">
<ContentView.Resources>
<ResourceDictionary>
<Style x:Key="AddButtonStyle"
TargetType="{x:Type Grid}">
<Setter Property="HeightRequest"
Value="42" />
<Setter Property="WidthRequest"
Value="42" />
<Setter Property="HorizontalOptions"
Value="Center" />
<Setter Property="VerticalOptions"
Value="End" />
<Setter Property="Margin"
Value="0, 0, 0, 24" />
</Style>
<Style x:Key="AddBackgroundImageStyle"
TargetType="{x:Type Image}">
<Setter Property="HorizontalOptions"
Value="Center" />
<Setter Property="VerticalOptions"
Value="Center" />
<Setter Property="HeightRequest"
Value="128" />
<Setter Property="WidthRequest"
Value="128" />
</Style>
<Style x:Key="AddImageStyle"
TargetType="{x:Type Image}">
<Setter Property="HeightRequest"
Value="24" />
<Setter Property="WidthRequest"
Value="24" />
</Style>
</ResourceDictionary>
</ContentView.Resources>
<ContentView.Content>
<Grid>
<!-- IOS & ANDROID -->
<Grid
Style="{StaticResource AddButtonStyle}">
<Grid.IsVisible>
<OnPlatform
x:TypeArguments="x:Boolean"
Android="True"
iOS="True"
WinPhone="False"/>
</Grid.IsVisible>
<BoxView
BackgroundColor="{StaticResource LightGreenColor}"
StyleClass="Circle" />
<Image
Aspect="AspectFit"
Source="product_add"
Style="{StaticResource AddImageStyle}">
<Image.Margin>
<OnPlatform
x:TypeArguments="Thickness"
Android="5, 12, 12, 12"
iOS="6, 12, 12, 12"/>
</Image.Margin>
</Image>
</Grid>
<!-- UWP -->
<Grid>
<Image
Source="Assets/circle_button_background.png"
Aspect="AspectFit"
Style="{StaticResource AddBackgroundImageStyle}" />
<Image
Aspect="AspectFit"
Source="Assets\product_add.png"
Style="{StaticResource AddImageStyle}"
Margin="12" />
</Grid>
</Grid>
</ContentView.Content>
</ContentView>

+ 12
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Controls/CartButton.xaml.cs View File

@ -0,0 +1,12 @@
using Xamarin.Forms;
namespace eShopOnContainers.Core.Controls
{
public partial class CartButton : ContentView
{
public CartButton()
{
InitializeComponent();
}
}
}

+ 1
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Effects/LineColorEffect.cs View File

@ -59,7 +59,7 @@ namespace eShopOnContainers.Core.Effects
class EntryLineColorEffect : RoutingEffect class EntryLineColorEffect : RoutingEffect
{ {
public EntryLineColorEffect() : base("BikeSharing.EntryLineColorEffect")
public EntryLineColorEffect() : base("eShopOnContainers.EntryLineColorEffect")
{ {
} }
} }


+ 2
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/ViewModels/MainViewModel.cs View File

@ -10,6 +10,8 @@ namespace eShopOnContainers.Core.ViewModels
{ {
public override Task InitializeAsync(object navigationData) public override Task InitializeAsync(object navigationData)
{ {
IsBusy = true;
if (navigationData is TabParameter) if (navigationData is TabParameter)
{ {
var tabIndex = ((TabParameter)navigationData).TabIndex; var tabIndex = ((TabParameter)navigationData).TabIndex;


+ 2
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CustomNavigationPage.xaml View File

@ -2,5 +2,7 @@
<NavigationPage xmlns="http://xamarin.com/schemas/2014/forms" <NavigationPage 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"
x:Class="eShopOnContainers.Core.Views.CustomNavigationPage" x:Class="eShopOnContainers.Core.Views.CustomNavigationPage"
BarBackgroundColor="{StaticResource GreenColor}"
BarTextColor="{StaticResource WhiteColor}"
BackgroundColor="Transparent"> BackgroundColor="Transparent">
</NavigationPage> </NavigationPage>

+ 25
- 9
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/FiltersView.xaml View File

@ -62,23 +62,39 @@
RowSpacing="0" RowSpacing="0"
Margin="48, 24"> Margin="48, 24">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="60" />
<RowDefinition Height="60" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<controls:BindablePicker
<controls:BindablePicker
Grid.Row="0" Grid.Row="0"
Title="BRAND"
ItemsSource="{Binding Brands}"
Title="BRAND"
ItemsSource="{Binding Brands}"
SelectedItem="{Binding Brand, Mode=TwoWay}" SelectedItem="{Binding Brand, Mode=TwoWay}"
Style="{StaticResource FilterPickerStyle}"/>
<controls:BindablePicker
Style="{StaticResource FilterPickerStyle}">
<controls:BindablePicker.HeightRequest>
<OnPlatform
x:TypeArguments="x:Double"
Android="48"
iOS="48"
WinPhone="36"/>
</controls:BindablePicker.HeightRequest>
</controls:BindablePicker>
<controls:BindablePicker
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>
<OnPlatform
x:TypeArguments="x:Double"
Android="48"
iOS="48"
WinPhone="36"/>
</controls:BindablePicker.HeightRequest>
</controls:BindablePicker>
<Button <Button
Grid.Row="2" Grid.Row="2"
Text="Apply" Text="Apply"


+ 17
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/LoginView.xaml View File

@ -124,13 +124,28 @@
Text="User name or email" Text="User name or email"
Style="{StaticResource HeaderLabelStyle}"/> Style="{StaticResource HeaderLabelStyle}"/>
<Entry <Entry
Text="{Binding UserName.Value, Mode=TwoWay}"/>
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 <Label
Text="Password" Text="Password"
Style="{StaticResource HeaderLabelStyle}"/> Style="{StaticResource HeaderLabelStyle}"/>
<Entry <Entry
IsPassword="True" IsPassword="True"
Text="{Binding Password.Value, Mode=TwoWay}" />
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> </StackLayout>
<!-- LOGIN BUTTON --> <!-- LOGIN BUTTON -->
<Grid <Grid


+ 1
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/MainView.xaml View File

@ -6,6 +6,7 @@
xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core" xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core"
BarBackgroundColor="{StaticResource DarkGreenColor}" BarBackgroundColor="{StaticResource DarkGreenColor}"
BackgroundColor="{StaticResource BackgroundColor}" BackgroundColor="{StaticResource BackgroundColor}"
BarTextColor="{StaticResource WhiteColor}"
Title="eShop on Containers"> Title="eShop on Containers">
<views:CatalogView <views:CatalogView
x:Name="HomeView"> x:Name="HomeView">


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

@ -195,7 +195,7 @@
Grid.Row="2" Grid.Row="2"
Opacity="0"> Opacity="0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListView <ListView
@ -203,7 +203,6 @@
ItemsSource="{Binding Order.OrderItems}" ItemsSource="{Binding Order.OrderItems}"
HasUnevenRows="True" HasUnevenRows="True"
SeparatorVisibility="None" SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
CachingStrategy="RecycleElement"> CachingStrategy="RecycleElement">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>


+ 1
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/OrderItemTemplate.xaml View File

@ -57,6 +57,7 @@
</ContentView.Resources> </ContentView.Resources>
<ContentView.Content> <ContentView.Content>
<Grid <Grid
HeightRequest="120"
BackgroundColor="{StaticResource BackgroundColor}"> BackgroundColor="{StaticResource BackgroundColor}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />


+ 4
- 21
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/ProductTemplate.xaml View File

@ -3,6 +3,7 @@
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:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
xmlns:controls="clr-namespace:eShopOnContainers.Core.Controls;assembly=eShopOnContainers.Core"
x:Class="eShopOnContainers.Core.Views.Templates.ProductTemplate"> x:Class="eShopOnContainers.Core.Views.Templates.ProductTemplate">
<ContentView.Resources> <ContentView.Resources>
<ResourceDictionary> <ResourceDictionary>
@ -80,27 +81,9 @@
Grid.Row="0" Grid.Row="0"
Grid.RowSpan="2" Grid.RowSpan="2"
Style="{StaticResource AddButtonStyle}"> Style="{StaticResource AddButtonStyle}">
<BoxView
BackgroundColor="{StaticResource LightGreenColor}"
StyleClass="Circle"/>
<Image
Aspect="AspectFit"
Style="{StaticResource AddImageStyle}">
<Image.Margin>
<OnPlatform
x:TypeArguments="Thickness"
Android="5, 12, 12, 12"
iOS="6, 12, 12, 12"
WinPhone="8, 12, 12, 12"/>
</Image.Margin>
<Image.Source>
<OnPlatform
x:TypeArguments="ImageSource"
Android="product_add"
iOS="product_add"
WinPhone="Assets\product_add.png"/>
</Image.Source>
</Image>
<controls:CartButton>
</controls:CartButton>
</Grid> </Grid>
<Label <Label
Grid.Row="1" Grid.Row="1"


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

@ -45,6 +45,9 @@
<Compile Include="Behaviors\Base\BindableBehavior.cs" /> <Compile Include="Behaviors\Base\BindableBehavior.cs" />
<Compile Include="Behaviors\EventToCommandBehavior.cs" /> <Compile Include="Behaviors\EventToCommandBehavior.cs" />
<Compile Include="Controls\BindablePicker.cs" /> <Compile Include="Controls\BindablePicker.cs" />
<Compile Include="Controls\CartButton.xaml.cs">
<DependentUpon>CartButton.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\CustomTabbedPage.cs" /> <Compile Include="Controls\CustomTabbedPage.cs" />
<Compile Include="Converters\CountToBoolConverter.cs" /> <Compile Include="Converters\CountToBoolConverter.cs" />
<Compile Include="Converters\DatetimeConverter.cs" /> <Compile Include="Converters\DatetimeConverter.cs" />
@ -294,6 +297,12 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Controls\CartButton.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" /> <Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">


+ 46
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Windows/App.xaml View File

@ -239,6 +239,52 @@
<Style TargetType="PivotItem"> <Style TargetType="PivotItem">
<Setter Property="Margin" Value="0" /> <Setter Property="Margin" Value="0" />
</Style> </Style>
<Style TargetType="ListViewItem">
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="IsHoldingEnabled" Value="True"/>
<Setter Property="Padding" Value="12,0,12,0"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}"/>
<Setter Property="MinHeight" Value="{ThemeResource ListViewItemMinHeight}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<ListViewItemPresenter
ContentTransitions="{TemplateBinding ContentTransitions}"
SelectionCheckMarkVisualEnabled="True"
CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
PointerOverBackground="{ThemeResource SystemControlHighlightListLowBrush}"
PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
SelectedBackground="Red"
SelectedForeground="Transparent"
SelectedPointerOverBackground="Transparent"
PressedBackground="Transparent"
SelectedPressedBackground="Transparent"
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
ContentMargin="{TemplateBinding Padding}"
CheckMode="Inline"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>


BIN
src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Assets/circle_button_background.png View File

Before After
Width: 128  |  Height: 128  |  Size: 2.9 KiB

+ 2
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Effects/EntryLineColorEffect.cs View File

@ -10,6 +10,7 @@ using Windows.UI.Xaml.Controls;
using eShopOnContainers.Windows.Effects; using eShopOnContainers.Windows.Effects;
using eShopOnContainers.Core.Effects; using eShopOnContainers.Core.Effects;
[assembly: ResolutionGroupName("eShopOnContainers")]
[assembly: ExportEffect(typeof(EntryLineColorEffect), "EntryLineColorEffect")] [assembly: ExportEffect(typeof(EntryLineColorEffect), "EntryLineColorEffect")]
namespace eShopOnContainers.Windows.Effects namespace eShopOnContainers.Windows.Effects
{ {
@ -51,7 +52,7 @@ namespace eShopOnContainers.Windows.Effects
var lineColor = XamarinFormColorToWindowsColor(LineColorEffect.GetLineColor(Element)); var lineColor = XamarinFormColorToWindowsColor(LineColorEffect.GetLineColor(Element));
control.BorderBrush = new Media.SolidColorBrush(lineColor); control.BorderBrush = new Media.SolidColorBrush(lineColor);
var style = App.Current.Resources["FormTextBoxStyle"] as Xaml.Style;
var style = Xaml.Application.Current.Resources["FormTextBoxStyle"] as Xaml.Style;
control.Style = style; control.Style = style;
} }
} }


+ 0
- 1
src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Renderers/CustomTabbedPageRenderer.cs View File

@ -9,6 +9,5 @@ namespace eShopOnContainers.Windows.Renderers
[Preserve] [Preserve]
public class CustomTabbedPageRenderer : TabbedPageRenderer public class CustomTabbedPageRenderer : TabbedPageRenderer
{ {
} }
} }

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

@ -120,6 +120,7 @@
<None Include="Windows_TemporaryKey.pfx" /> <None Include="Windows_TemporaryKey.pfx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Assets\circle_button_background.png" />
<Content Include="Assets\fake_product_01.png" /> <Content Include="Assets\fake_product_01.png" />
<Content Include="Assets\fake_product_02.png" /> <Content Include="Assets\fake_product_02.png" />
<Content Include="Assets\fake_product_03.png" /> <Content Include="Assets\fake_product_03.png" />


+ 102
- 2
src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Renderers/CustomTabbedPageRenderer.cs View File

@ -1,10 +1,110 @@
using Foundation;
using eShopOnContainers.Core.Controls;
using eShopOnContainers.iOS.Renderers;
using Foundation;
using System.Threading.Tasks;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS; using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedPageRenderer))]
namespace eShopOnContainers.iOS.Renderers namespace eShopOnContainers.iOS.Renderers
{ {
[Preserve] [Preserve]
public class CustomTabbedPageRenderer : TabbedRenderer public class CustomTabbedPageRenderer : TabbedRenderer
{ {
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
for (var i = 0; i < TabBar.Items.Length; i++)
{
AddTabBadge(i);
}
Element.ChildAdded += OnTabAdded;
Element.ChildRemoved += OnTabRemoved;
}
private void AddTabBadge(int tabIndex)
{
var element = Tabbed.Children[tabIndex];
element.PropertyChanged += OnTabbedPagePropertyChanged;
if (TabBar.Items.Length > tabIndex)
{
var tabBarItem = TabBar.Items[tabIndex];
UpdateTabBadgeText(tabBarItem, element);
var tabColor = CustomTabbedPage.GetBadgeColor(element);
if (tabColor != Color.Default)
{
tabBarItem.BadgeColor = tabColor.ToUIColor();
}
}
}
private void UpdateTabBadgeText(UITabBarItem tabBarItem, Element element)
{
var text = CustomTabbedPage.GetBadgeText(element);
tabBarItem.BadgeValue = string.IsNullOrEmpty(text) ? null : text;
}
private void OnTabbedPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
var page = sender as Page;
if (page == null)
return;
if (e.PropertyName == CustomTabbedPage.BadgeTextProperty.PropertyName)
{
var tabIndex = Tabbed.Children.IndexOf(page);
if (tabIndex < TabBar.Items.Length)
UpdateTabBadgeText(TabBar.Items[tabIndex], page);
return;
}
if (e.PropertyName == CustomTabbedPage.BadgeColorProperty.PropertyName)
{
var tabIndex = Tabbed.Children.IndexOf(page);
if (tabIndex < TabBar.Items.Length)
TabBar.Items[tabIndex].BadgeColor = CustomTabbedPage.GetBadgeColor(page).ToUIColor();
}
}
private async void OnTabAdded(object sender, ElementEventArgs e)
{
await Task.Delay(10);
var page = e.Element as Page;
if (page == null)
return;
var tabIndex = Tabbed.Children.IndexOf(page);
AddTabBadge(tabIndex);
}
private void OnTabRemoved(object sender, ElementEventArgs e)
{
e.Element.PropertyChanged -= OnTabbedPagePropertyChanged;
}
protected override void Dispose(bool disposing)
{
if (Tabbed != null)
{
foreach (var tab in Tabbed.Children)
{
tab.PropertyChanged -= OnTabbedPagePropertyChanged;
}
Tabbed.ChildAdded -= OnTabAdded;
Tabbed.ChildRemoved -= OnTabRemoved;
}
base.Dispose(disposing);
}
} }
}
}

Loading…
Cancel
Save