Skip to content

Commit 0094111

Browse files
author
Javier Suárez Ruiz
committed
Added loading image
Review mobile apps UI Changes in Basket API integration
1 parent 10204f7 commit 0094111

18 files changed

Lines changed: 241 additions & 126 deletions

File tree

src/Mobile/eShopOnContainers/eShopOnContainers.Core/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<converters:ItemTappedEventArgsConverter x:Key="ItemTappedEventArgsConverter" />
105105
<converters:InverseCountToBoolConverter x:Key="InverseCountToBoolConverter" />
106106
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
107+
<converters:ItemsToHeightConverter x:Key="ItemsToHeightConverter" />
107108
<converters:ToUpperConverter x:Key="ToUpperConverter" />
108109

109110
<!-- STYLES -->
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Globalization;
3+
using Xamarin.Forms;
4+
5+
namespace eShopOnContainers.Core.Converters
6+
{
7+
public class ItemsToHeightConverter : IValueConverter
8+
{
9+
private const int ItemHeight = 144;
10+
11+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
12+
{
13+
if(value is int)
14+
{
15+
return System.Convert.ToInt32(value) * ItemHeight;
16+
}
17+
18+
return 0;
19+
}
20+
21+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
return null;
24+
}
25+
}
26+
}

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/BasketView.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<RowDefinition Height="60" />
5656
</Grid.RowDefinitions>
5757
<!-- CART ITEMS -->
58-
<ScrollView
58+
<Grid
5959
Grid.Row="0">
6060
<Grid>
6161
<Grid.RowDefinitions>
@@ -73,7 +73,8 @@
7373
<!-- ITEMS -->
7474
<ListView
7575
Grid.Row="1"
76-
ItemsSource="{Binding BasketItems}"
76+
ItemsSource="{Binding BasketItems}"
77+
HeightRequest="{Binding BasketItems.Count, Converter={StaticResource ItemsToHeightConverter}}"
7778
HasUnevenRows="True"
7879
SeparatorVisibility="None"
7980
VerticalOptions="FillAndExpand"
@@ -102,7 +103,7 @@
102103
Style="{StaticResource CartTotalStyle}"/>
103104
</StackLayout>
104105
</Grid>
105-
</ScrollView>
106+
</Grid>
106107
<!-- CHECKOUT -->
107108
<Grid
108109
Grid.Row="1"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/FiltersView.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<RowDefinition Height="Auto" />
7070
<RowDefinition Height="Auto" />
7171
</Grid.RowDefinitions>
72+
<!-- BRAND -->
7273
<controls:BindablePicker
7374
Grid.Row="0"
7475
Title="BRAND"
@@ -83,6 +84,7 @@
8384
WinPhone="36"/>
8485
</controls:BindablePicker.HeightRequest>
8586
</controls:BindablePicker>
87+
<!-- TYPE -->
8688
<controls:BindablePicker
8789
Grid.Row="1"
8890
Title="TYPE"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/MainView.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
</ToolbarItem.Icon>
2222
</ToolbarItem>
2323
</ContentPage.ToolbarItems>
24+
<!-- CATALOG -->
2425
<views:CatalogView
2526
x:Name="HomeView">
2627
<views:CatalogView.Icon>
@@ -31,6 +32,7 @@
3132
WinPhone="Assets\menu_filter.png"/>
3233
</views:CatalogView.Icon>
3334
</views:CatalogView>
35+
<!-- PROFILE -->
3436
<views:ProfileView
3537
x:Name="ProfileView">
3638
<views:ProfileView.Icon>
@@ -41,6 +43,7 @@
4143
WinPhone="Assets\menu_profile.png"/>
4244
</views:ProfileView.Icon>
4345
</views:ProfileView>
46+
<!-- BASKET -->
4447
<views:BasketView
4548
x:Name="BasketView"
4649
controls:CustomTabbedPage.BadgeText="{Binding BadgeCount}"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/SettingsView.xaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
Grid.Column="0"
9090
Grid.ColumnSpan="2"
9191
BackgroundColor="Gray"/>
92-
<StackLayout
92+
<StackLayout
9393
Grid.Column="0"
9494
Grid.Row="1">
9595
<Label
@@ -100,7 +100,8 @@
100100
Text="{Binding Description}"
101101
Style="{StaticResource SettingsDescriptionStyle}"/>
102102
</StackLayout>
103-
<controls:ToggleButton
103+
<!-- ON / OFF -->
104+
<controls:ToggleButton
104105
Grid.Column="1"
105106
Grid.Row="1"
106107
Animate="True"
@@ -109,14 +110,14 @@
109110
Style="{StaticResource SettingsToggleButtonStyle}">
110111
<controls:ToggleButton.CheckedImage>
111112
<OnPlatform x:TypeArguments="ImageSource"
112-
Android="switchOn"
113-
iOS="switchOn"
113+
Android="switch_on.png"
114+
iOS="switchOn.png"
114115
WinPhone="Assets/switchOn.png"/>
115116
</controls:ToggleButton.CheckedImage>
116117
<controls:ToggleButton.UnCheckedImage>
117118
<OnPlatform x:TypeArguments="ImageSource"
118-
Android="switchOff"
119-
iOS="switchOff"
119+
Android="switch_off.png"
120+
iOS="switchOff.png"
120121
WinPhone="Assets/switchOff.png"/>
121122
</controls:ToggleButton.UnCheckedImage>
122123
</controls:ToggleButton>

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/BasketItemTemplate.xaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656

5757
<Style x:Key="QuantityPickerStyle"
5858
TargetType="{x:Type controls:BindablePicker}">
59-
<Setter Property="WidthRequest"
60-
Value="36" />
6159
<Setter Property="BackgroundColor"
6260
Value="Transparent" />
6361
<Setter Property="HorizontalOptions"
@@ -71,6 +69,13 @@
7169
<ContentView.Content>
7270
<Grid
7371
BackgroundColor="{StaticResource BackgroundColor}">
72+
<Grid.Padding>
73+
<OnPlatform
74+
x:TypeArguments="Thickness"
75+
Android="0"
76+
iOS="0"
77+
WinPhone="12, 0"/>
78+
</Grid.Padding>
7479
<Grid.ColumnDefinitions>
7580
<ColumnDefinition Width="Auto" />
7681
<ColumnDefinition Width="*" />
@@ -79,6 +84,7 @@
7984
<RowDefinition Height="*" />
8085
<RowDefinition Height="1" />
8186
</Grid.RowDefinitions>
87+
<!-- IMAGE -->
8288
<ffimageloading:CachedImage
8389
Grid.Column="0"
8490
Grid.Row="0"
@@ -91,6 +97,13 @@
9197
Aspect="AspectFit"
9298
VerticalOptions="Start"
9399
Margin="12,0,0,0">
100+
<ffimageloading:CachedImage.LoadingPlaceholder>
101+
<OnPlatform
102+
x:TypeArguments="ImageSource"
103+
iOS="default_product"
104+
Android="default_product"
105+
WinPhone="Assets/default_product.png"/>
106+
</ffimageloading:CachedImage.LoadingPlaceholder>
94107
<ffimageloading:CachedImage.ErrorPlaceholder>
95108
<OnPlatform
96109
x:TypeArguments="ImageSource"
@@ -108,6 +121,7 @@
108121
<RowDefinition />
109122
<RowDefinition />
110123
</Grid.RowDefinitions>
124+
<!-- NAME -->
111125
<Label
112126
Grid.Row="0"
113127
Text="{Binding ProductName, Converter={StaticResource ToUpperConverter}}"/>
@@ -117,6 +131,7 @@
117131
<ColumnDefinition />
118132
<ColumnDefinition />
119133
</Grid.ColumnDefinitions>
134+
<!-- PRICE -->
120135
<Label
121136
Grid.Column="0"
122137
Text="{Binding UnitPrice, StringFormat='${0:N}'}"
@@ -125,8 +140,17 @@
125140
Grid.Column="1"
126141
ItemsSource="{Binding Numbers}"
127142
SelectedItem="{Binding Quantity, Mode=TwoWay}"
128-
Style="{StaticResource QuantityPickerStyle}"/>
143+
Style="{StaticResource QuantityPickerStyle}">
144+
<controls:BindablePicker.WidthRequest>
145+
<OnPlatform
146+
x:TypeArguments="x:Double"
147+
Android="36"
148+
iOS="36"
149+
WinPhone="72"/>
150+
</controls:BindablePicker.WidthRequest>
151+
</controls:BindablePicker>
129152
</Grid>
153+
<!-- TOTAL -->
130154
<Label
131155
Grid.Row="2"
132156
Text="{Binding Total, StringFormat='${0:N}'}"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/OrderItemTemplate.xaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<Setter Property="HorizontalOptions"
4141
Value="End" />
4242
</Style>
43-
43+
4444
<Style x:Key="OrderTotalStyle"
4545
TargetType="{x:Type Label}">
4646
<Setter Property="FontFamily"
@@ -67,6 +67,7 @@
6767
<RowDefinition Height="*" />
6868
<RowDefinition Height="1" />
6969
</Grid.RowDefinitions>
70+
<!-- IMAGE -->
7071
<ffimageloading:CachedImage
7172
Grid.Column="0"
7273
Grid.Row="0"
@@ -79,6 +80,13 @@
7980
Aspect="AspectFit"
8081
VerticalOptions="Start"
8182
Margin="12,0,0,0">
83+
<ffimageloading:CachedImage.LoadingPlaceholder>
84+
<OnPlatform
85+
x:TypeArguments="ImageSource"
86+
iOS="default_product"
87+
Android="default_product"
88+
WinPhone="Assets/default_product.png"/>
89+
</ffimageloading:CachedImage.LoadingPlaceholder>
8290
<ffimageloading:CachedImage.ErrorPlaceholder>
8391
<OnPlatform
8492
x:TypeArguments="ImageSource"
@@ -96,6 +104,7 @@
96104
<RowDefinition />
97105
<RowDefinition />
98106
</Grid.RowDefinitions>
107+
<!-- NAME -->
99108
<Label
100109
Grid.Row="0"
101110
Text="{Binding ProductName, Converter={StaticResource ToUpperConverter}}"/>
@@ -105,6 +114,7 @@
105114
<ColumnDefinition />
106115
<ColumnDefinition />
107116
</Grid.ColumnDefinitions>
117+
<!-- PRICE -->
108118
<Label
109119
Grid.Column="0"
110120
Text="{Binding UnitPrice, StringFormat='${0:N}'}"
@@ -114,6 +124,7 @@
114124
Text="{Binding Quantity}"
115125
Style="{StaticResource OrderItemQuantityStyle}"/>
116126
</Grid>
127+
<!-- TOTAL -->
117128
<Label
118129
Grid.Row="2"
119130
Text="{Binding Total, StringFormat='${0:N}'}"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/Views/Templates/ProductTemplate.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,21 @@
7070
<RowDefinition Height="Auto" />
7171
<RowDefinition Height="Auto" />
7272
</Grid.RowDefinitions>
73+
<!-- IMAGE -->
7374
<ffimageloading:CachedImage
7475
Grid.Row="0"
7576
Source="{Binding PictureUri}"
7677
CacheDuration="30"
7778
CacheType="Disk"
7879
DownsampleToViewSize="True"
7980
Aspect="AspectFill">
81+
<ffimageloading:CachedImage.LoadingPlaceholder>
82+
<OnPlatform
83+
x:TypeArguments="ImageSource"
84+
iOS="default_product"
85+
Android="default_product"
86+
WinPhone="Assets/default_product.png"/>
87+
</ffimageloading:CachedImage.LoadingPlaceholder>
8088
<ffimageloading:CachedImage.ErrorPlaceholder>
8189
<OnPlatform
8290
x:TypeArguments="ImageSource"
@@ -91,10 +99,12 @@
9199
Style="{StaticResource AddButtonStyle}">
92100
<controls:AddBasketButton />
93101
</Grid>
102+
<!-- NAME -->
94103
<Label
95104
Grid.Row="1"
96105
Text="{Binding Name, Converter={StaticResource ToUpperConverter}}"
97106
Style="{StaticResource ProductNameStyle}"/>
107+
<!-- PRICE -->
98108
<Label
99109
Grid.Row="2"
100110
Text="{Binding Price, StringFormat='${0:N}'}"

src/Mobile/eShopOnContainers/eShopOnContainers.Core/eShopOnContainers.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="Converters\ImageConverter.cs" />
5656
<Compile Include="Converters\InverseBoolConverter.cs" />
5757
<Compile Include="Converters\InverseCountToBoolConverter.cs" />
58+
<Compile Include="Converters\ItemsToHeightConverter.cs" />
5859
<Compile Include="Converters\ItemTappedConverter.cs" />
5960
<Compile Include="Converters\ToUpperConverter.cs" />
6061
<Compile Include="Effects\LineColorEffect.cs" />

0 commit comments

Comments
 (0)