Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naweed committed Aug 28, 2022
1 parent 033b152 commit 1b05b41
Show file tree
Hide file tree
Showing 9 changed files with 451 additions and 28 deletions.
3 changes: 3 additions & 0 deletions src/MauiTubePlayer/MauiTubePlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
<MauiXaml Update="Views\VideoDetailsPage.xaml">
<SubType></SubType>
</MauiXaml>
<MauiXaml Update="ViewControls\SmallVideoCell.xaml">
<SubType></SubType>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Maui.Apps.Framework\Maui.Apps.Framework.csproj" />
Expand Down
63 changes: 63 additions & 0 deletions src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:MauiTubePlayer.Models"
x:DataType="models:YoutubeVideo"
xmlns:viewmodels="clr-namespace:MauiTubePlayer.ViewModels"

x:Class="MauiTubePlayer.ViewControls.SmallVideoCell">

<Border
BackgroundColor="{StaticResource DarkColor}"
StrokeShape="RoundRectangle 8"
Padding="6"
WidthRequest="130">

<Border.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:VideoDetailsPageViewModel}}, Path=NavigateToVideoDetailsPageCommand, Mode=OneWay}"
CommandParameter="{Binding Id.VideoId}" />
</Border.GestureRecognizers>

<Grid
RowSpacing="6"
RowDefinitions="*,32">

<!-- Thumbnail -->
<Frame
Grid.Row="0"
HasShadow="True"
CornerRadius="6"
HorizontalOptions="Fill"
VerticalOptions="Fill"
IsClippedToBounds="True"
Padding="0"
Margin="0,0,2,2">
<Image
HorizontalOptions="Fill"
VerticalOptions="Fill"
Aspect="AspectFill">
<Image.Source>
<UriImageSource
Uri="{Binding Snippet.Thumbnails.Medium.Url, Mode=OneWay}"
CacheValidity="1:00:00.0" />
</Image.Source>
</Image>
</Frame>

<!-- Video Details -->
<Label
Style="{StaticResource RegularLightText12}"
Grid.Row="1"
LineBreakMode="WordWrap"
VerticalOptions="Fill"
MaxLines="2"
Text="{Binding Snippet.Title, Mode=OneWay}" />

</Grid>

</Border>

</ContentView>

9 changes: 9 additions & 0 deletions src/MauiTubePlayer/ViewControls/SmallVideoCell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiTubePlayer.ViewControls;

public partial class SmallVideoCell : ContentView
{
public SmallVideoCell()
{
InitializeComponent();
}
}
3 changes: 2 additions & 1 deletion src/MauiTubePlayer/ViewControls/VideoCell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -14,7 +15,7 @@

<Border.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Path=ParentContext.NavigateToVideoDetailsPageCommand, Source={x:Reference VideoCellRoot}, Mode=OneWay}"
Command="{Binding Path=NavigateToVideoDetailsPageCommand, Source={RelativeSource AncestorType={x:Type viewmodels:StartPageViewModel}}, Mode=OneWay}"
CommandParameter="{Binding Id.VideoId}" />
</Border.GestureRecognizers>

Expand Down
20 changes: 0 additions & 20 deletions src/MauiTubePlayer/ViewControls/VideoCell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
47 changes: 43 additions & 4 deletions src/MauiTubePlayer/ViewModels/VideoDetailsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ public partial class VideoDetailsPageViewModel : AppViewModelBase
[ObservableProperty]
private Channel theChannel;

[ObservableProperty]
private bool similarVideosAvailable;

[ObservableProperty]
private List<Comment> comments;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
}


}

1 change: 0 additions & 1 deletion src/MauiTubePlayer/Views/StartPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
x:DataType="models:YoutubeVideo">

<controls:VideoCell
ParentContext="{Binding BindingContext, Source={x:Reference RootPage}}"
HorizontalOptions="Fill"
HeightRequest="{Binding ItemsHeight, Source={x:Reference RootPage}}"/>

Expand Down
Loading

0 comments on commit 1b05b41

Please sign in to comment.