From 1b05b415532bbc9652a710642d6e343add8bf24c Mon Sep 17 00:00:00 2001 From: Naweed Akram Date: Sun, 28 Aug 2022 08:19:13 +0300 Subject: [PATCH] Commit --- src/MauiTubePlayer/MauiTubePlayer.csproj | 3 + .../ViewControls/SmallVideoCell.xaml | 63 +++++ .../ViewControls/SmallVideoCell.xaml.cs | 9 + .../ViewControls/VideoCell.xaml | 3 +- .../ViewControls/VideoCell.xaml.cs | 20 -- .../ViewModels/VideoDetailsPageViewModel.cs | 47 +++- src/MauiTubePlayer/Views/StartPage.xaml | 1 - .../Views/VideoDetailsPage.xaml | 263 +++++++++++++++++- .../Views/VideoDetailsPage.xaml.cs | 70 ++++- 9 files changed, 451 insertions(+), 28 deletions(-) create mode 100644 src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml create mode 100644 src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml.cs diff --git a/src/MauiTubePlayer/MauiTubePlayer.csproj b/src/MauiTubePlayer/MauiTubePlayer.csproj index c76382c..291a0d5 100644 --- a/src/MauiTubePlayer/MauiTubePlayer.csproj +++ b/src/MauiTubePlayer/MauiTubePlayer.csproj @@ -94,6 +94,9 @@ + + + diff --git a/src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml b/src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml new file mode 100644 index 0000000..de3bebd --- /dev/null +++ b/src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml.cs b/src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml.cs new file mode 100644 index 0000000..72bcfa5 --- /dev/null +++ b/src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml.cs @@ -0,0 +1,9 @@ +namespace MauiTubePlayer.ViewControls; + +public partial class SmallVideoCell : ContentView +{ + public SmallVideoCell() + { + InitializeComponent(); + } +} diff --git a/src/MauiTubePlayer/ViewControls/VideoCell.xaml b/src/MauiTubePlayer/ViewControls/VideoCell.xaml index 8b3a83a..ef9762b 100644 --- a/src/MauiTubePlayer/ViewControls/VideoCell.xaml +++ b/src/MauiTubePlayer/ViewControls/VideoCell.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:models="clr-namespace:MauiTubePlayer.Models" + xmlns:viewmodels="clr-namespace:MauiTubePlayer.ViewModels" x:DataType="models:YoutubeVideo" x:Name="VideoCellRoot" x:Class="MauiTubePlayer.ViewControls.VideoCell"> @@ -14,7 +15,7 @@ diff --git a/src/MauiTubePlayer/ViewControls/VideoCell.xaml.cs b/src/MauiTubePlayer/ViewControls/VideoCell.xaml.cs index 0d09c3b..8a83f52 100644 --- a/src/MauiTubePlayer/ViewControls/VideoCell.xaml.cs +++ b/src/MauiTubePlayer/ViewControls/VideoCell.xaml.cs @@ -2,26 +2,6 @@ public partial class VideoCell : ContentView { - public static readonly BindableProperty ParentContextProperty = BindableProperty.Create( - "ParentContext", - typeof(object), - typeof(VideoCell), - null, - propertyChanged: - (bindableObject, oldValue, newValue) => - { - if (newValue is not null && bindableObject is VideoCell cell && newValue != oldValue) - { - cell.ParentContext = newValue; - } - }); - - public object ParentContext - { - get { return GetValue(ParentContextProperty); } - set { SetValue(ParentContextProperty, value); } - } - public VideoCell() { InitializeComponent(); diff --git a/src/MauiTubePlayer/ViewModels/VideoDetailsPageViewModel.cs b/src/MauiTubePlayer/ViewModels/VideoDetailsPageViewModel.cs index 4a6ba5a..7f45cca 100644 --- a/src/MauiTubePlayer/ViewModels/VideoDetailsPageViewModel.cs +++ b/src/MauiTubePlayer/ViewModels/VideoDetailsPageViewModel.cs @@ -11,9 +11,6 @@ public partial class VideoDetailsPageViewModel : AppViewModelBase [ObservableProperty] private Channel theChannel; - [ObservableProperty] - private bool similarVideosAvailable; - [ObservableProperty] private List comments; @@ -51,7 +48,6 @@ public override async void OnNavigatedTo(object parameters) var similarVideosSearchResult = await _appApiService.SearchVideos(TheVideo.Snippet.Tags.First(), ""); SimilarVideos = similarVideosSearchResult.Items; - SimilarVideosAvailable = (SimilarVideos?.Count > 0); } //Get Comments @@ -83,5 +79,48 @@ public override async void OnNavigatedTo(object parameters) } } + [RelayCommand] + private async Task UnlikeVideo() + { + await PageService.DisplayAlert("Coming Soon", + "The unlike option is coming soon, once we implement the OAuth login functionality.", + "OK"); + } + + [RelayCommand] + private async Task ShareVideo() + { + var textToShare = + $"Hey, I found this amazing video. check it out: https://www.youtube.com/watch?v={TheVideo.Id}"; + + //Share + await Share.RequestAsync(new ShareTextRequest + { + Text = textToShare, + Title = TheVideo.Snippet.Title + }); + } + + [RelayCommand] + private async Task DownloadVideo() + { + } + + [RelayCommand] + private async Task SubscribeChannel() + { + await PageService.DisplayAlert( + "Coming Soon", + "The subscribe to channel option is coming soon, once we implement the OAuth login functionality.", + "OK"); + } + + [RelayCommand] + private async Task NavigateToVideoDetailsPage(string videoID) + { + await NavigationService.PushAsync(new VideoDetailsPage(videoID)); + } + + } diff --git a/src/MauiTubePlayer/Views/StartPage.xaml b/src/MauiTubePlayer/Views/StartPage.xaml index 3dc824a..ee9a43e 100644 --- a/src/MauiTubePlayer/Views/StartPage.xaml +++ b/src/MauiTubePlayer/Views/StartPage.xaml @@ -97,7 +97,6 @@ x:DataType="models:YoutubeVideo"> diff --git a/src/MauiTubePlayer/Views/VideoDetailsPage.xaml b/src/MauiTubePlayer/Views/VideoDetailsPage.xaml index 71b425f..8b0321b 100644 --- a/src/MauiTubePlayer/Views/VideoDetailsPage.xaml +++ b/src/MauiTubePlayer/Views/VideoDetailsPage.xaml @@ -6,6 +6,7 @@ xmlns:viewmodels="clr-namespace:MauiTubePlayer.ViewModels" xmlns:models="clr-namespace:MauiTubePlayer.Models" xmlns:controls="clr-namespace:MauiTubePlayer.ViewControls" + xmlns:converters="clr-namespace:Maui.Apps.Framework.Converters;assembly=Maui.Apps.Framework" x:Class="MauiTubePlayer.Views.VideoDetailsPage" x:TypeArguments="viewmodels:VideoDetailsPageViewModel" x:DataType="viewmodels:VideoDetailsPageViewModel" @@ -14,6 +15,10 @@ ContentDisplayMode="NavigationBar" x:Name="RootPage"> + + + + - +