diff --git a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj index 1e33499..cfd5c97 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.Android/CarouselViewChallenge.Android.csproj @@ -32,6 +32,12 @@ prompt 4 None + false + false + false + false + + x86;x86_64 true @@ -54,8 +60,8 @@ - - + + @@ -101,4 +107,4 @@ - + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge.Android/Properties/AndroidManifest.xml b/CarouselViewChallenge/CarouselViewChallenge.Android/Properties/AndroidManifest.xml index f37a67c..6651615 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.Android/Properties/AndroidManifest.xml +++ b/CarouselViewChallenge/CarouselViewChallenge.Android/Properties/AndroidManifest.xml @@ -1,6 +1,6 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge.UWP/CarouselViewChallenge.UWP.csproj b/CarouselViewChallenge/CarouselViewChallenge.UWP/CarouselViewChallenge.UWP.csproj index 4b6b2c9..9d1a368 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.UWP/CarouselViewChallenge.UWP.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.UWP/CarouselViewChallenge.UWP.csproj @@ -145,9 +145,12 @@ + + 1.1.1 + - - + + @@ -159,4 +162,4 @@ 14.0 - + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj index 6241d2c..f5738b9 100644 --- a/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge.iOS/CarouselViewChallenge.iOS.csproj @@ -130,7 +130,7 @@ - + @@ -139,4 +139,4 @@ CarouselViewChallenge - + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj index a58ec88..ec2cce5 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj +++ b/CarouselViewChallenge/CarouselViewChallenge/CarouselViewChallenge.csproj @@ -6,8 +6,10 @@ + + - + diff --git a/CarouselViewChallenge/CarouselViewChallenge/ViewModels/PodcastsViewModel.cs b/CarouselViewChallenge/CarouselViewChallenge/ViewModels/PodcastsViewModel.cs new file mode 100644 index 0000000..bfc7bfe --- /dev/null +++ b/CarouselViewChallenge/CarouselViewChallenge/ViewModels/PodcastsViewModel.cs @@ -0,0 +1,142 @@ +namespace CarouselViewChallenge.ViewModels +{ + using System; + using System.Windows.Input; + using Xamarin.Forms; + using System.Collections.ObjectModel; + using System.ComponentModel; + + /// + /// The podcast info + /// + public class Podcast + { + public string Title { get; set; } + public FormattedString Description { get; set; } + public string Url { get; set; } + + public string ImageUrl { get; set; } + }; + + public class Episode + { + public string Title { get; set; } + public FormattedString Description { get; set; } + public string Url { get; set; } + + public string Duration { get; set; } + } + + /// + /// The Podcasts view model + /// + /// + public class PodcastsViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private ObservableCollection _episodes; + public ObservableCollection Episodes + { + get + { + return _episodes; + } + set + { + if (_episodes != value) + { + _episodes = value; + OnPropertyChanged(new PropertyChangedEventArgs("Podcasts")); + } + } + } + + private ObservableCollection _podcasts; + public ObservableCollection Podcasts + { + get + { + return _podcasts; + } + set + { + if (_podcasts != value) + { + _podcasts = value; + OnPropertyChanged(new PropertyChangedEventArgs("Podcasts")); + } + } + } + + public string PlayUrl { get; set; } + + public ICommand PlayCommand { get; private set; } + public ICommand GetEpisodes { get; private set; } + + public PodcastsViewModel() + { + Podcasts = new ObservableCollection(); + Episodes = new ObservableCollection(); + PlayCommand = new Command(Play); + GetEpisodes = new Command(LoadEpisodes); + + LoadPodcasts(); + } + + private void Play(string url) + { + PlayUrl = url; + } + + private void OnPropertyChanged(PropertyChangedEventArgs eventArgs) + { + PropertyChanged?.Invoke(this, eventArgs); + } + + private void LoadPodcasts() + { + var maxItems = 5; // Min:1 - max:200 + var country = "nl"; // Two-letter country code (ISO 3166-1 alpha-2) + + + var finder = new iTunesPodcastFinder.PodcastFinder(); + var results = finder.SearchPodcastsAsync("microsoft", maxItems); + + foreach (var item in results.Result) + { + + + Podcasts.Add( + new Podcast + { + Title = item.Name, + Description = item.Summary, + Url = item.FeedUrl, + ImageUrl = item.ArtWork, + + }); + } + + } + private void LoadEpisodes(string url) + { + var podcastFinder = new iTunesPodcastFinder.PodcastFinder(); + var results = podcastFinder.GetPodcastEpisodesAsync(url); + + Episodes.Clear(); + + foreach (var item in results.Result.Episodes) + { + Episodes.Add( + new Episode + { + Title = item.Title, + Description = item.Summary, + Url = item.FileUrl.ToString(), + Duration = item.Duration.ToString() + }); + } + } + } +} diff --git a/CarouselViewChallenge/CarouselViewChallenge/ViewModels/WelcomePageViewModel.cs b/CarouselViewChallenge/CarouselViewChallenge/ViewModels/WelcomePageViewModel.cs index fdaa195..4d4382b 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/ViewModels/WelcomePageViewModel.cs +++ b/CarouselViewChallenge/CarouselViewChallenge/ViewModels/WelcomePageViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Text; +using System.Windows.Input; using Xamarin.Forms; namespace CarouselViewChallenge.ViewModels diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml index 1a7cc0d..e639170 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml @@ -3,11 +3,47 @@ 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:mediaPlayer="clr-namespace:Xamarians.MediaPlayer;assembly=Xamarians.MediaPlayer" mc:Ignorable="d" x:Class="CarouselViewChallenge.Views.CarouselViewChallengePage"> - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs index 38f2e9f..7a9cc87 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/CarouselViewChallengePage.xaml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - +using CarouselViewChallenge.ViewModels; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -12,9 +7,14 @@ namespace CarouselViewChallenge.Views [XamlCompilation(XamlCompilationOptions.Compile)] public partial class CarouselViewChallengePage : ContentPage { + public PodcastsViewModel model { get; set; } + public CarouselViewChallengePage() { InitializeComponent(); + model = new PodcastsViewModel(); + + BindingContext = model; } } } \ No newline at end of file diff --git a/CarouselViewChallenge/CarouselViewChallenge/Views/WelcomePage.xaml.cs b/CarouselViewChallenge/CarouselViewChallenge/Views/WelcomePage.xaml.cs index 58ad760..a061d0f 100644 --- a/CarouselViewChallenge/CarouselViewChallenge/Views/WelcomePage.xaml.cs +++ b/CarouselViewChallenge/CarouselViewChallenge/Views/WelcomePage.xaml.cs @@ -3,7 +3,6 @@ using System.Collections.ObjectModel; using System.ComponentModel; using Xamarin.Forms; -using Xamarin.Forms.Xaml; namespace CarouselViewChallenge.Views { @@ -21,7 +20,7 @@ public WelcomePage() { new Section { - Header = "Thank you for participating in the CarouselView Challenge!", + Header = "😈 Thank you for participating in the CarouselView Challenge!", Content = new FormattedString { Spans = @@ -36,7 +35,8 @@ public WelcomePage() FontAttributes = FontAttributes.Italic } } - } + }, + Emoji = "😈" }, new Section {