Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.5.909-pre</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" />
<PackageReference Include="Xamarin.Android.Support.ViewPager" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ protected override void OnCreate(Bundle savedInstanceState)
global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental");
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true);
LoadApplication(new App());
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental");
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
FFImageLoading.Forms.Platform.CachedImageRenderer.Init();
LoadApplication(new App());

return base.FinishedLaunching(app, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.FFImageLoading.Forms">
<Version>2.4.5.909-pre</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.FFImageLoading.Forms" Version="2.4.5.909-pre" />
<PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
</ItemGroup>
Expand All @@ -19,10 +20,8 @@
<EmbeddedResource Update="Views\CollectionViewChallengePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
<Folder Include="ViewModels\" />
<EmbeddedResource Update="Views\HomePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions CollectionViewChallenge/CollectionViewChallenge/Models/Pizza.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CollectionViewChallenge.Models
{
public class Pizza
{
public string Name { get; set; }
public string ImagePath { get; set; }
public string Type { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using CollectionViewChallenge.Models;
using CollectionViewChallenge.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;

namespace CollectionViewChallenge.ViewModels
{
public class CVChallangeVM : INotifyPropertyChanged
{
public ObservableCollection<Pizza> NewPizza { get; set; }
public ObservableCollection<Pizza> BestSellers { get; set; }

public event PropertyChangedEventHandler PropertyChanged;

public CVChallangeVM()
{
NewPizza = new ObservableCollection<Pizza>(new[] {
new Pizza { Name = "Crinkle Fries", ImagePath="https://l1.pizzainindia.com/themes/OLO_v2.1/images/deal/p-1.jpg"},
new Pizza { Name = "Crunchy Strip", ImagePath="https://l1.pizzainindia.com/themes/OLO_v2.1/images/deal/p-2.jpg"},
new Pizza { Name = "Crunchy Strip", ImagePath="https://l1.pizzainindia.com/themes/OLO_v2.1/images/deal/p-3.jpg"},
new Pizza { Name = "Crunchy Strip", ImagePath="https://l1.pizzainindia.com/themes/OLO_v2.1/images/deal/p-4.jpg"}
});


BestSellers = new ObservableCollection<Pizza>(new[] {
new Pizza { Name = "Peri Peri Chicken", ImagePath="https://l1.pizzainindia.com/assets/osc/ABAAA/images/products/originals/AfricanPeriPeriVegNonVeg.jpg"},
new Pizza { Name = "Barbecue Chicken", ImagePath="https://l1.pizzainindia.com/assets/osc/ABAAA/images/products/originals/AussieBarbequeNonVeg.jpg"},
new Pizza { Name = "Jerk Chicken", ImagePath="https://l1.pizzainindia.com/assets/osc/ABAAA/images/products/originals/JamaicanJerkNonVeg.jpg"},
new Pizza { Name = "Chicken Tikka", ImagePath="https://l1.pizzainindia.com/assets/osc/ABAAA/images/products/originals/IndianTandooriChickenTikka.jpg"}
});


}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,131 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ViewModel="clr-namespace:CollectionViewChallenge.ViewModels"
xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
xmlns:Hmodel="clr-namespace:CollectionViewChallenge.Models"
mc:Ignorable="d"
x:Class="CollectionViewChallenge.Views.CollectionViewChallengePage">
<ContentPage.BindingContext>
<ViewModel:CVChallangeVM></ViewModel:CVChallangeVM>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout>
<!-- Use your own layout and functionality here! -->
<CollectionView>
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>This is a CollectionView!</x:String>
<x:String>Your feedback on the experience of converting a ListView to a CollectionView is incredibly appreciated.</x:String>
<x:String>Here are three general questions:</x:String>
<x:String>1. How was the experience of converting your existing ListView to a CollectionView?</x:String>
<x:String>2. How is the performance compared to the ListView?</x:String>
<x:String>3. Is there a specific piece of functionality that you'd like to see?</x:String>
</x:Array>
</CollectionView.ItemsSource>
<Grid Margin="5,10">

<Grid.RowDefinitions>
<RowDefinition Height="150"/>
<RowDefinition Height="40"/>
<RowDefinition Height="200"/>
<RowDefinition Height="40"/>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>




<ffimageloading:CachedImage
Grid.Row="0"
Source="https://www.dominos.co.in/theme2/front/images/home/Dom_EVO2_Brand_Desktop_1366x452.jpg" Aspect="Fill" />

<Label Text="Whats New"
Grid.Row="1"
FontSize="16"
FontAttributes="Bold"
VerticalTextAlignment="Center"
/>
<CollectionView
Grid.Row="2"
ItemsSource="{Binding NewPizza}"
ItemsLayout="{x:Static ListItemsLayout.HorizontalList}"
>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="5">
<Label Text="{Binding .}" d:Text="Design Time Data" FontSize="10"/>
</StackLayout>



<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>

<ffimageloading:CachedImage

Grid.Row="0"
Grid.Column="0"
Aspect="Fill"

DownsampleToViewSize="true"
Source = "{Binding ImagePath}">
</ffimageloading:CachedImage>

<Label Text="{Binding Name}"
HeightRequest="30"

Grid.Row="1"
Grid.Column="0"
FontSize="16"
FontAttributes="Bold" HorizontalTextAlignment="Center"/>

</Grid>

</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>


<Label Text="Bestsellers"
Grid.Row="3"
FontSize="16"
FontAttributes="Bold"
VerticalTextAlignment="Center"
/>
<CollectionView
Grid.Row="4"
ItemsSource="{Binding BestSellers}"
ItemsLayout="{x:Static ListItemsLayout.HorizontalList}"
>
<CollectionView.ItemTemplate>
<DataTemplate>



<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>

<ffimageloading:CachedImage

Grid.Row="0"
Grid.Column="0"
Aspect="Fill"

DownsampleToViewSize="true"
Source = "{Binding ImagePath}">
</ffimageloading:CachedImage>

<Label Text="{Binding Name}"
HeightRequest="30"

Grid.Row="1"
Grid.Column="0"
FontSize="16"
FontAttributes="Bold" HorizontalTextAlignment="Center"/>

</Grid>

</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>

</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
x:Class="CollectionViewChallenge.Views.HomePage">
<ContentPage.Content>
<Grid>

<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<ffimageloading:CachedImage
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Grid.Row="0"
DownsampleToViewSize="true"
Source = "https://api.dominos.co.in/prod-olo-api/images/brandOfferImages/worldcup_pizza_banner.jpg">
</ffimageloading:CachedImage>

<Label Text="Whats New"
Grid.Row="1"
FontSize="16"
FontAttributes="Bold" />
<CollectionView
Grid.Row="2"
ItemsSource="{Binding ActionMovies}"
ItemsLayout="{x:Static ListItemsLayout.HorizontalList}"
>
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame HasShadow="True"
Margin="10, 0"
Padding="5"
BackgroundColor="Beige">
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="35" />
</Grid.RowDefinitions>

<ffimageloading:CachedImage
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Grid.Row="0"
DownsampleToViewSize="true"
Source = "{Binding ImagePath}">
</ffimageloading:CachedImage>

<Label Text="{Binding Name}"
Grid.Row="1"
FontSize="16"
FontAttributes="Bold" />

</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>

</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace CollectionViewChallenge.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class HomePage : ContentPage
{
public HomePage()
{
InitializeComponent();
}
}
}