From 4962bc4aebdfc54135dc50d5d6e17446d2a1de76 Mon Sep 17 00:00:00 2001 From: Cleiton Felipe de Moraes Date: Thu, 19 Sep 2019 00:11:01 -0300 Subject: [PATCH 1/2] First update carouselview --- .../CarouselViewChallenge.Android.csproj | 3 + .../CarouselViewChallenge.iOS.csproj | 3 + .../CarouselViewChallenge.csproj | 7 +-- .../CarouselViewChallenge/Models/Character.cs | 12 ++++ .../Services/IService.cs | 11 ++++ .../ViewModels/RickAndMorthyViewModel.cs | 37 +++++++++++ .../Views/CarouselViewChallengePage.xaml | 62 +++++++++++++++++-- .../Views/CarouselViewChallengePage.xaml.cs | 54 +++++++++++++++- 8 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 CarouselViewChallenge/CarouselViewChallenge/Models/Character.cs create mode 100644 CarouselViewChallenge/CarouselViewChallenge/Services/IService.cs create mode 100644 CarouselViewChallenge/CarouselViewChallenge/ViewModels/RickAndMorthyViewModel.cs diff --git a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj index 82e6221..2f3d8ab 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj @@ -53,6 +53,9 @@ + + 2.2.29 + diff --git a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj index 155cd56..a9c2da9 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj @@ -129,6 +129,9 @@ + + 2.2.29 + diff --git a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj index 198ec7f..a65b436 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -6,14 +6,11 @@ + - - - - WelcomePage.xaml diff --git a/CarouselViewChallenge/CarouselViewChallenge/Models/Character.cs b/CarouselViewChallenge/CarouselViewChallenge/Models/Character.cs new file mode 100644 index 0000000..dc5d477 --- /dev/null +++ b/CarouselViewChallenge/CarouselViewChallenge/Models/Character.cs @@ -0,0 +1,12 @@ +namespace CarouselViewChallenge.Models +{ + public class Character + { + public int id { get; set; } + public string name { get; set; } + public string status { get; set; } + public string species { get; set; } + public string gender { get; set; } + public string image { get; set; } + } +} diff --git a/CarouselViewChallenge/CarouselViewChallenge/Services/IService.cs b/CarouselViewChallenge/CarouselViewChallenge/Services/IService.cs new file mode 100644 index 0000000..62e18cf --- /dev/null +++ b/CarouselViewChallenge/CarouselViewChallenge/Services/IService.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CarouselViewChallenge.Services +{ + public interface IService + { + + } +} diff --git a/CarouselViewChallenge/CarouselViewChallenge/ViewModels/RickAndMorthyViewModel.cs b/CarouselViewChallenge/CarouselViewChallenge/ViewModels/RickAndMorthyViewModel.cs new file mode 100644 index 0000000..a91a3bf --- /dev/null +++ b/CarouselViewChallenge/CarouselViewChallenge/ViewModels/RickAndMorthyViewModel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Text; +using CarouselViewChallenge.Models; + +namespace CarouselViewChallenge.ViewModels +{ + public class RickAndMorthyViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private ObservableCollection _characters; + + public ObservableCollection Characters + { + get + { + return _characters; + } + set + { + if (_characters != value) + { + _characters = value; + OnPropertyChanged(new PropertyChangedEventArgs("Characters")); + } + } + } + + private void OnPropertyChanged(PropertyChangedEventArgs eventArgs) + { + PropertyChanged?.Invoke(this, eventArgs); + } + } +} diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml index 1a7cc0d..a900874 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml @@ -4,10 +4,60 @@ xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage"> - - - - + x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage" + xmlns:vm="clr-namespace:CarouselViewChallenge.ViewModels" + Title="{Binding Title}"> + + + + + + + + + + + + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs index 38f2e9f..afdb010 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs @@ -1,5 +1,8 @@ -using System; +using CarouselViewChallenge.Models; +using CarouselViewChallenge.ViewModels; +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,9 +15,58 @@ namespace CarouselViewChallenge.Views [XamlCompilation(XamlCompilationOptions.Compile)] public partial class CarouselViewChallengePage : ContentPage { + public RickAndMorthyViewModel VM { get; set; } public CarouselViewChallengePage() { InitializeComponent(); + VM = new RickAndMorthyViewModel(); + VM.Characters = new ObservableCollection + { + new Character + { + image = "https://rickandmortyapi.com/api/character/avatar/1.jpeg", + name = "Rick Sanchez", + species = "Human", + status = "Alive", + gender = "Male" + }, + new Character + { + image = "https://rickandmortyapi.com/api/character/avatar/2.jpeg", + name = "Morty Smith", + species = "Human", + status = "Alive", + gender = "Male" + }, + new Character + { + image = "https://rickandmortyapi.com/api/character/avatar/3.jpeg", + name = "Summer Smith", + species = "Human", + status = "Alive", + gender = "Female" + }, + new Character + { + image = "https://rickandmortyapi.com/api/character/avatar/4.jpeg", + name = "Beth Smith", + species = "Human", + status = "Alive", + gender = "Female" + }, + new Character + { + image = "https://rickandmortyapi.com/api/character/avatar/5.jpeg", + name = "Jerry Smith", + species = "Human", + status = "Alive", + gender = "Male" + } + + + }; + BindingContext = VM; + } } } \ No newline at end of file From cda02cc0140c15b6f369fac45449371afce99320 Mon Sep 17 00:00:00 2001 From: Cleiton Felipe de Moraes Date: Sat, 21 Sep 2019 22:43:02 -0300 Subject: [PATCH 2/2] Apply CarouselView in sample app list Rick and Morthy characters --- .../CarouselViewChallenge.Android.csproj | 6 +- .../CarouselViewChallenge.iOS.csproj | 6 +- .../CarouselViewChallenge.csproj | 4 +- .../Views/CarouselViewChallengePage.xaml | 84 +++++++------------ .../Views/CarouselViewChallengePage.xaml.cs | 20 +++-- 5 files changed, 51 insertions(+), 69 deletions(-) diff --git a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj index 2f3d8ab..e8fb840 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj @@ -53,12 +53,12 @@ - - 2.2.29 - + + 1.2.1 + diff --git a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj index a9c2da9..9e76057 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj @@ -129,11 +129,11 @@ - - 2.2.29 - + + 1.2.1 + diff --git a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj index a65b436..5671c02 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj @@ -6,9 +6,9 @@ - - + + diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml index a900874..ac68e80 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml @@ -6,58 +6,38 @@ mc:Ignorable="d" x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage" xmlns:vm="clr-namespace:CarouselViewChallenge.ViewModels" + xmlns:yummy="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView" Title="{Binding Title}"> - - - - - - - + + + + + + + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs index afdb010..8e68286 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs @@ -18,8 +18,10 @@ public partial class CarouselViewChallengePage : ContentPage public RickAndMorthyViewModel VM { get; set; } public CarouselViewChallengePage() { + InitializeComponent(); VM = new RickAndMorthyViewModel(); + VM.Characters = new ObservableCollection { new Character @@ -40,11 +42,11 @@ public CarouselViewChallengePage() }, new Character { - image = "https://rickandmortyapi.com/api/character/avatar/3.jpeg", - name = "Summer Smith", - species = "Human", - status = "Alive", - gender = "Female" + image = "https://rickandmortyapi.com/api/character/avatar/212.jpeg", + name = "Magma-Q", + species = "Alien, Alphabetrian", + status = "Dead", + gender = "Male" }, new Character { @@ -56,11 +58,11 @@ public CarouselViewChallengePage() }, new Character { - image = "https://rickandmortyapi.com/api/character/avatar/5.jpeg", - name = "Jerry Smith", - species = "Human", + image = "https://rickandmortyapi.com/api/character/avatar/376.jpeg", + name = "Veronica Ann Bennet", + species = "Alien, Gazorpian", status = "Alive", - gender = "Male" + gender = "Female" }