Skip to content

Commit

Permalink
Cherry pick MAUI.
Browse files Browse the repository at this point in the history
Replaced SfNumericUpDown by Stepper.
  • Loading branch information
a-einstein committed Apr 6, 2023
1 parent f7107a7 commit 4914221
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Xamarin.SfNumericUpDown" Version="21.1.38" />
<PackageReference Include="Xamarin.CommunityToolkit" Version="2.0.5" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.5" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
Expand Down
34 changes: 6 additions & 28 deletions Portable/RCS.PortableShop.Common/Styles/Stylesheet.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:RCS.PortableShop.Common.Controls;assembly=RCS.PortableShop.Common"
xmlns:numericUpDown="clr-namespace:Syncfusion.SfNumericUpDown.XForms;assembly=Syncfusion.SfNumericUpDown.XForms"
>

<!--Note that currently no form of nested or multiple merging exist. https://forums.xamarin.com/discussion/86308/multiple-merged-dictionaries?-->
Expand Down Expand Up @@ -114,6 +113,11 @@
<Setter Property="VerticalOptions" Value="{StaticResource LineVerticalOptions}"/>
</Style>

<Style x:Key="ValueEmphasisEntryStyle" TargetType="Entry">
<Setter Property="TextColor" Value="{StaticResource ValueTextColour}"/>
<Setter Property="FontAttributes" Value="Bold"/>
</Style>

<Style x:Key="InvalidEntryStyle" TargetType="Entry">
<Setter Property="BackgroundColor" Value="{StaticResource InvalidBackgroundColour}"/>
</Style>
Expand Down Expand Up @@ -169,30 +173,4 @@

<!--#endregion-->

<!--#region NumericUpDowns -->

<!--
Documentation:
https://help.syncfusion.com/xamarin/sfnumericupdown/overview
Note this need HorizontalOptions to prevent taking all width.
It is hard to reduce its size, because of its Buttons to start with.
WidthRequest needs to be considerable large to preserve the text area.
HeightRequest only crops it.
Related:
https://www.syncfusion.com/forums/128080/can-the-size-of-the-numericupdown-component-be-made-smaller
-->
<Style TargetType="numericUpDown:SfNumericUpDown">
<Setter Property="VerticalOptions" Value="{StaticResource LineVerticalOptions}"/>
<Setter Property="HorizontalOptions" Value="Start"/>
<Setter Property="WidthRequest" Value="130"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontAttribute" Value="Bold"/>
<Setter Property="TextColor" Value="{StaticResource ValueTextColour}"/>
<Setter Property="Minimum" Value="0"/>
<Setter Property="MaximumDecimalDigits" Value="0"/>
</Style>

<!--#endregion-->

</ResourceDictionary>
</ResourceDictionary>
42 changes: 18 additions & 24 deletions Portable/RCS.PortableShop/Views/CartView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:baseClasses="clr-namespace:RCS.PortableShop.Common.Views;assembly=RCS.PortableShop.Common"
xmlns:views="clr-namespace:RCS.PortableShop.Views;assembly=RCS.PortableShop"
xmlns:numericUpDown="clr-namespace:Syncfusion.SfNumericUpDown.XForms;assembly=Syncfusion.SfNumericUpDown.XForms"
xmlns:viewModels="clr-namespace:RCS.PortableShop.ViewModels"
d:BindingContext="{d:DesignInstance Type=viewModels:CartViewModel}"
mc:Ignorable="d"
Expand All @@ -31,32 +30,27 @@
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Style="{StaticResource ListItemStyle}" BackgroundColor="{StaticResource CartLevel1Colour}">
<!--Note this layout currently is aimed towards portrait orientation.-->
<StackLayout Orientation="Vertical">
<Label Text="{Binding Name}" Style="{StaticResource ValueEmphasisMediumLabelStyle}"/>
<Grid Style="{StaticResource ListItemStyle}" BackgroundColor="{StaticResource CartLevel1Colour}">
<!--Note this layout currently is aimed towards portrait orientation.-->
<StackLayout Orientation="Vertical">
<Label Text="{Binding Name}" Style="{StaticResource ValueEmphasisMediumLabelStyle}"/>

<StackLayout Orientation="Horizontal">
<Label Text="{Binding ProductSize}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding ProductSizeUnitMeasureCode}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding ProductColor}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding ProductListPrice, StringFormat='{}{0:C2}'}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding Value, StringFormat='{}{0:C2}'}" Style="{StaticResource ValueEmphasisLabelStyle}"/>
</StackLayout>

<StackLayout Orientation="Horizontal">
<!--
Note currently a big license message is displayed.
https://help.syncfusion.com/common/essential-studio/licensing/license-key
Note the defined style with comments.
-->
<numericUpDown:SfNumericUpDown Value="{Binding Quantity, Mode=TwoWay}"/>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding ProductSize}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding ProductSizeUnitMeasureCode}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding ProductColor}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding ProductListPrice, StringFormat='{}{0:C2}'}" Style="{StaticResource ValueLabelStyle}"/>
<Label Text="{Binding Value, StringFormat='{}{0:C2}'}" Style="{StaticResource ValueEmphasisLabelStyle}"/>
</StackLayout>

<Button ImageSource="Trash.png" Command="{Binding BindingContext.DeleteCommand, Source={x:Reference cartItemsListView}}" CommandParameter="{Binding}" Style="{StaticResource CartMinButtonStyle}" VerticalOptions="Start" HorizontalOptions="Start"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<!--TODO May become a separate control with style.-->
<Entry Text="{Binding Quantity, Mode=TwoWay}" Style="{StaticResource ValueEmphasisEntryStyle}"/>
<Stepper Value="{Binding Quantity, Mode=TwoWay}" Minimum="0" Maximum="10" Increment="1" BackgroundColor="White"/>
<Button ImageSource="Trash.png" Command="{Binding BindingContext.DeleteCommand, Source={x:Reference cartItemsListView}}" CommandParameter="{Binding}" Style="{StaticResource CartMinButtonStyle}" VerticalOptions="Start" HorizontalOptions="Start"/>
</StackLayout>
</Grid>
</StackLayout>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
Expand Down

0 comments on commit 4914221

Please sign in to comment.