Browse Source

More UI changes related with Cart in mobile apps

pull/49/merge
Javier Suárez Ruiz 8 years ago
parent
commit
e631701ff3
5 changed files with 162 additions and 41 deletions
  1. +4
    -2
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml
  2. +26
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Converters/CountToBoolConverter.cs
  3. +26
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Converters/InverseCountToBoolConverter.cs
  4. +104
    -39
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CartView.xaml
  5. +2
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj

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

@ -98,11 +98,13 @@
WinPhone="48"/>
<!-- CONVERTERS -->
<converters:ToUpperConverter x:Key="ToUpperConverter" />
<converters:CountToBoolConverter x:Key="CountToBoolConverter" />
<converters:DatetimeConverter x:Key="DatetimeConverter" />
<converters:ImageConverter x:Key="ImageConverter" />
<converters:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter" />
<converters:InverseCountToBoolConverter x:Key="InverseCountToBoolConverter" />
<converters:ToUpperConverter x:Key="ToUpperConverter" />
<!-- STYLES -->
<Style x:Key="EntryStyle"
TargetType="{x:Type Entry}">


+ 26
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Converters/CountToBoolConverter.cs View File

@ -0,0 +1,26 @@
using System;
using System.Globalization;
using Xamarin.Forms;
namespace eShopOnContainers.Core.Converters
{
public class CountToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int)
{
int count = System.Convert.ToInt32(value);
return count > 0;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 26
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Converters/InverseCountToBoolConverter.cs View File

@ -0,0 +1,26 @@
using System;
using System.Globalization;
using Xamarin.Forms;
namespace eShopOnContainers.Core.Converters
{
public class InverseCountToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int)
{
int count = System.Convert.ToInt32(value);
return count == 0;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

+ 104
- 39
src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/CartView.xaml View File

@ -16,52 +16,117 @@
<Setter Property="HorizontalOptions"
Value="End" />
</Style>
<Style x:Key="CheckoutButtonStyle"
TargetType="{x:Type Label}">
<Setter Property="FontFamily"
Value="{StaticResource MontserratRegular}" />
<Setter Property="TextColor"
Value="{StaticResource WhiteColor}" />
<Setter Property="HorizontalOptions"
Value="Center" />
<Setter Property="VerticalOptions"
Value="Center" />
</Style>
<Style x:Key="ShoppingCartStyle"
TargetType="{x:Type Label}">
<Setter Property="FontFamily"
Value="{StaticResource MontserratRegular}" />
<Setter Property="FontSize"
Value="{StaticResource MediumSize}" />
<Setter Property="TextColor"
Value="Black" />
<Setter Property="HorizontalOptions"
Value="Center" />
<Setter Property="Margin"
Value="0, 12" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView>
<Grid
BackgroundColor="{StaticResource BackgroundColor}">
<Grid
BackgroundColor="{StaticResource BackgroundColor}">
<!-- SHOPPING CART -->
<Grid
IsVisible="{Binding OrderItems.Count, Converter={StaticResource CountToBoolConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<!-- CART ITEMS -->
<Grid
<ScrollView
Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView
ItemsSource="{Binding OrderItems}"
HasUnevenRows="True"
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<templates:OrderItemTemplate />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout
Grid.Row="1"
Margin="0,0,0,24">
<Label
Grid.Row="0"
Text="TOTAL"
TextColor="{StaticResource BlackColor}"
Style="{StaticResource CartTotalStyle}"/>
<Label
Grid.Row="1"
Text="{Binding Total, StringFormat='${0:N}'}"
TextColor="{StaticResource GreenColor}"
Style="{StaticResource CartTotalStyle}"/>
</StackLayout>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- HEADER -->
<Grid
Grid.Row="0">
<Label
Text="SHOPPING CART"
Style="{StaticResource ShoppingCartStyle}"/>
</Grid>
<!-- ITEMS -->
<ListView
Grid.Row="1"
ItemsSource="{Binding OrderItems}"
HasUnevenRows="True"
SeparatorVisibility="None"
VerticalOptions="FillAndExpand"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<templates:OrderItemTemplate />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- TOTAL -->
<StackLayout
Grid.Row="2"
Margin="0,0,0,24">
<Label
Grid.Row="0"
Text="TOTAL"
TextColor="{StaticResource BlackColor}"
Style="{StaticResource CartTotalStyle}"/>
<Label
Grid.Row="1"
Text="{Binding Total, StringFormat='${0:N}'}"
TextColor="{StaticResource GreenColor}"
Style="{StaticResource CartTotalStyle}"/>
</StackLayout>
</Grid>
</ScrollView>
<!-- CHECKOUT -->
<Grid
Grid.Row="1"
BackgroundColor="{StaticResource LightGreenColor}"
Padding="0"
ColumnSpacing="0"
RowSpacing="0">
<Label
Text="[ CHECKOUT ]"
Style="{StaticResource CheckoutButtonStyle}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding CheckoutCommand}"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>
</Grid>
</ScrollView>
<!-- EMPTY SHOPPING CART -->
<Grid
IsVisible="{Binding OrderItems.Count, Converter={StaticResource InverseCountToBoolConverter}}">
<Label
Text="EMPTY SHOPPING CART"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Grid>
</Grid>
</ContentPage>

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

@ -46,8 +46,10 @@
<Compile Include="Behaviors\EventToCommandBehavior.cs" />
<Compile Include="Controls\BindablePicker.cs" />
<Compile Include="Controls\CustomTabbedPage.cs" />
<Compile Include="Converters\CountToBoolConverter.cs" />
<Compile Include="Converters\DatetimeConverter.cs" />
<Compile Include="Converters\ImageConverter.cs" />
<Compile Include="Converters\InverseCountToBoolConverter.cs" />
<Compile Include="Converters\ItemTappedConverter.cs" />
<Compile Include="Converters\ToUpperConverter.cs" />
<Compile Include="Effects\LineColorEffect.cs" />


Loading…
Cancel
Save