From aa102cd91b1bae61a1e57e15a6a75a056d95674f Mon Sep 17 00:00:00 2001 From: Sandip Kumbhar Date: Wed, 1 May 2019 15:25:06 +0530 Subject: [PATCH 1/2] Done --- .../CollectionViewChallenge.Android.csproj | 3 + .../MainActivity.cs | 3 +- .../AppDelegate.cs | 3 +- .../CollectionViewChallenge.iOS.csproj | 3 + .../CollectionViewChallenge.csproj | 9 +- .../CollectionViewChallenge/Models/Pizza.cs | 13 ++ .../ViewModels/CVChallangeVM.cs | 55 +++++++ .../Views/CollectionViewChallengePage.xaml | 135 +++++++++++++++--- .../Views/HomePage.xaml | 67 +++++++++ .../Views/HomePage.xaml.cs | 20 +++ 10 files changed, 287 insertions(+), 24 deletions(-) create mode 100644 CollectionViewChallenge/CollectionViewChallenge/Models/Pizza.cs create mode 100644 CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs create mode 100644 CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml create mode 100644 CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml.cs diff --git a/CollectionViewChallenge/CollectionViewChallenge.Android/CollectionViewChallenge.Android.csproj b/CollectionViewChallenge/CollectionViewChallenge.Android/CollectionViewChallenge.Android.csproj index d2c42fc..49f055c 100644 --- a/CollectionViewChallenge/CollectionViewChallenge.Android/CollectionViewChallenge.Android.csproj +++ b/CollectionViewChallenge/CollectionViewChallenge.Android/CollectionViewChallenge.Android.csproj @@ -52,6 +52,9 @@ + + 2.4.5.909-pre + diff --git a/CollectionViewChallenge/CollectionViewChallenge.Android/MainActivity.cs b/CollectionViewChallenge/CollectionViewChallenge.Android/MainActivity.cs index 72e1935..b6f4b5f 100644 --- a/CollectionViewChallenge/CollectionViewChallenge.Android/MainActivity.cs +++ b/CollectionViewChallenge/CollectionViewChallenge.Android/MainActivity.cs @@ -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) { diff --git a/CollectionViewChallenge/CollectionViewChallenge.iOS/AppDelegate.cs b/CollectionViewChallenge/CollectionViewChallenge.iOS/AppDelegate.cs index 3d2ece2..b22fd63 100644 --- a/CollectionViewChallenge/CollectionViewChallenge.iOS/AppDelegate.cs +++ b/CollectionViewChallenge/CollectionViewChallenge.iOS/AppDelegate.cs @@ -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); } diff --git a/CollectionViewChallenge/CollectionViewChallenge.iOS/CollectionViewChallenge.iOS.csproj b/CollectionViewChallenge/CollectionViewChallenge.iOS/CollectionViewChallenge.iOS.csproj index 49a7105..4540f38 100644 --- a/CollectionViewChallenge/CollectionViewChallenge.iOS/CollectionViewChallenge.iOS.csproj +++ b/CollectionViewChallenge/CollectionViewChallenge.iOS/CollectionViewChallenge.iOS.csproj @@ -133,6 +133,9 @@ + + 2.4.5.909-pre + diff --git a/CollectionViewChallenge/CollectionViewChallenge/CollectionViewChallenge.csproj b/CollectionViewChallenge/CollectionViewChallenge/CollectionViewChallenge.csproj index 3ccfc60..887ac3a 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/CollectionViewChallenge.csproj +++ b/CollectionViewChallenge/CollectionViewChallenge/CollectionViewChallenge.csproj @@ -11,6 +11,7 @@ + @@ -19,10 +20,8 @@ MSBuild:UpdateDesignTimeXaml - - - - - + + MSBuild:UpdateDesignTimeXaml + \ No newline at end of file diff --git a/CollectionViewChallenge/CollectionViewChallenge/Models/Pizza.cs b/CollectionViewChallenge/CollectionViewChallenge/Models/Pizza.cs new file mode 100644 index 0000000..03ffb70 --- /dev/null +++ b/CollectionViewChallenge/CollectionViewChallenge/Models/Pizza.cs @@ -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; } + } +} diff --git a/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs b/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs new file mode 100644 index 0000000..31883b6 --- /dev/null +++ b/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs @@ -0,0 +1,55 @@ +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 NewPizza { get; set; } + public ObservableCollection BestSellers { get; set; } + + public event PropertyChangedEventHandler PropertyChanged; + + public CVChallangeVM() + { + NewPizza = new ObservableCollection(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(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"} + }); + + //HomePage = new Command(async () => await HomePageFunc()); + //MenuPage = new Command(async() => await MenuPageFunc()); + } + + //public ICommand HomePage { private set; get; } + + //public async Task HomePageFunc() + //{ + // await Navigation.PushModalAsync(new HomePage()); + //} + + //public ICommand MenuPage { private set; get; } + + //public async Task MenuPageFunc() + //{ + //} + } +} diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml index f2da7f7..865d5a5 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml @@ -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"> + + + - - - - - - This is a CollectionView! - Your feedback on the experience of converting a ListView to a CollectionView is incredibly appreciated. - Here are three general questions: - 1. How was the experience of converting your existing ListView to a CollectionView? - 2. How is the performance compared to the ListView? - 3. Is there a specific piece of functionality that you'd like to see? - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml b/CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml new file mode 100644 index 0000000..983a855 --- /dev/null +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml.cs b/CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml.cs new file mode 100644 index 0000000..f1f106d --- /dev/null +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/HomePage.xaml.cs @@ -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(); + } + } +} \ No newline at end of file From 71f122c652eab963e163dca93ff61cae16ec1e3c Mon Sep 17 00:00:00 2001 From: Sandip Kumbhar Date: Wed, 1 May 2019 15:34:25 +0530 Subject: [PATCH 2/2] CollectionViewChallange Commit --- .../ViewModels/CVChallangeVM.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs b/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs index 31883b6..99ad5ef 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs +++ b/CollectionViewChallenge/CollectionViewChallenge/ViewModels/CVChallangeVM.cs @@ -35,21 +35,8 @@ public CVChallangeVM() new Pizza { Name = "Chicken Tikka", ImagePath="https://l1.pizzainindia.com/assets/osc/ABAAA/images/products/originals/IndianTandooriChickenTikka.jpg"} }); - //HomePage = new Command(async () => await HomePageFunc()); - //MenuPage = new Command(async() => await MenuPageFunc()); + } - - //public ICommand HomePage { private set; get; } - - //public async Task HomePageFunc() - //{ - // await Navigation.PushModalAsync(new HomePage()); - //} - - //public ICommand MenuPage { private set; get; } - - //public async Task MenuPageFunc() - //{ - //} + } }