diff --git a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj index 82e6221..e8fb840 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj @@ -56,6 +56,9 @@ + + 1.2.1 + diff --git a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj index 155cd56..9e76057 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj @@ -131,6 +131,9 @@ + + 1.2.1 + diff --git a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj index 198ec7f..5671c02 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -7,11 +7,8 @@ - - - - - + + 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..ac68e80 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml @@ -4,10 +4,40 @@ 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" + 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 38f2e9f..8e68286 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,60 @@ 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/212.jpeg", + name = "Magma-Q", + species = "Alien, Alphabetrian", + status = "Dead", + gender = "Male" + }, + 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/376.jpeg", + name = "Veronica Ann Bennet", + species = "Alien, Gazorpian", + status = "Alive", + gender = "Female" + } + + + }; + BindingContext = VM; + } } } \ No newline at end of file