Development 5
This commit is contained in:
+22
-13
@@ -40,17 +40,17 @@
|
|||||||
<TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/>
|
<TextBlock Name="views" Text="[views]" FontSize="24" Foreground="Gray"/>
|
||||||
<ProgressBar Name="rating" Width="250" Background="Green" Foreground="Red"/>
|
<ProgressBar Name="rating" Width="250" Background="Green" Foreground="Red"/>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button Background="Transparent" Foreground="Gray"
|
<FontIcon Foreground="Gray"
|
||||||
Padding="0"
|
HorizontalAlignment="Left"
|
||||||
FontFamily="Segoe MDL2 Assets" FontSize="40"
|
FontSize="40"
|
||||||
Name="dislike" Click="dislike_Click"
|
Name="dislike" Tapped="dislike_Click"
|
||||||
Content=""/>
|
Glyph=""/>
|
||||||
|
|
||||||
<Button Background="Transparent" Foreground="Gray"
|
<FontIcon Foreground="Gray"
|
||||||
Padding="0" HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
FontFamily="Segoe MDL2 Assets" FontSize="40"
|
FontSize="40"
|
||||||
Name="like" Click="like_Click"
|
Name="like" Tapped="like_Click"
|
||||||
Content=""/>
|
Glyph=""/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock Foreground="Gray" Text="[dislikes]" Name="dislikes"/>
|
<TextBlock Foreground="Gray" Text="[dislikes]" Name="dislikes"/>
|
||||||
@@ -85,14 +85,23 @@
|
|||||||
|
|
||||||
|
|
||||||
<CommandBar VerticalAlignment="Bottom" Name="commandbar">
|
<CommandBar VerticalAlignment="Bottom" Name="commandbar">
|
||||||
<AppBarToggleButton Icon="Clock" Label="Watch later" Visibility="Collapsed"/>
|
<AppBarButton Name="download" Icon="Download" Label="Download video">
|
||||||
|
<AppBarButton.Flyout>
|
||||||
|
<MenuFlyout>
|
||||||
|
<MenuFlyoutItem Text="Select quality:" IsEnabled="False"/>
|
||||||
|
<MenuFlyoutSeparator/>
|
||||||
|
<MenuFlyoutItem Text="No items are available" IsEnabled="False"/>
|
||||||
|
</MenuFlyout>
|
||||||
|
</AppBarButton.Flyout>
|
||||||
|
</AppBarButton>
|
||||||
|
<AppBarToggleButton Name="addLater" Icon="Clock" Label="Watch later" Visibility="Collapsed"/>
|
||||||
<AppBarButton Name="refresh" Click="refresh_Click" Icon="Refresh" Label="Refresh page"/>
|
<AppBarButton Name="refresh" Click="refresh_Click" Icon="Refresh" Label="Refresh page"/>
|
||||||
<AppBarButton Name="share" Click="share_Click" Icon="Share" Label="Share"/>
|
<AppBarButton Name="share" Click="share_Click" Icon="Share" Label="Share"/>
|
||||||
<AppBarButton Name="openBrowser" Click="openBrowser_Click" Icon="Globe" Label="Open in browser"/>
|
<AppBarButton Name="openBrowser" Click="openBrowser_Click" Icon="Globe" Label="Open in browser"/>
|
||||||
|
|
||||||
<CommandBar.SecondaryCommands>
|
<CommandBar.SecondaryCommands>
|
||||||
<AppBarButton Icon="Add" Label="Add to playlist" Visibility="Collapsed"/>
|
<AppBarButton Name="addToPlaylist" Icon="Add" Label="Add to playlist" Visibility="Collapsed"/>
|
||||||
<AppBarButton Icon="Flag" Label="Report this video"/>
|
<AppBarButton Icon="Flag" Label="Report this video" Visibility="Collapsed"/>
|
||||||
</CommandBar.SecondaryCommands>
|
</CommandBar.SecondaryCommands>
|
||||||
</CommandBar>
|
</CommandBar>
|
||||||
|
|
||||||
|
|||||||
+71
-39
@@ -34,6 +34,8 @@ using FoxTube.Pages;
|
|||||||
|
|
||||||
namespace FoxTube
|
namespace FoxTube
|
||||||
{
|
{
|
||||||
|
public enum Rating { None, Like, Dislike }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -45,7 +47,10 @@ namespace FoxTube
|
|||||||
bool wide;
|
bool wide;
|
||||||
bool isExtended = false;
|
bool isExtended = false;
|
||||||
|
|
||||||
|
Rating userRating = Rating.None;
|
||||||
|
|
||||||
public VideoPlayer player;
|
public VideoPlayer player;
|
||||||
|
public CommentsPage comments;
|
||||||
LoadingPage LoadingScreen = new LoadingPage();
|
LoadingPage LoadingScreen = new LoadingPage();
|
||||||
LoadingPage loadingRelated = new LoadingPage();
|
LoadingPage loadingRelated = new LoadingPage();
|
||||||
|
|
||||||
@@ -106,7 +111,10 @@ namespace FoxTube
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
views.Text = string.Format("{0:0,0} views", item.Statistics.ViewCount);
|
views.Text = string.Format("{0:0,0} views", item.Statistics.ViewCount);
|
||||||
(commentsPlaceholder.Content as CommentsPage).Initialize(item);
|
comments = new CommentsPage();
|
||||||
|
commentsPlaceholder.Content = null;
|
||||||
|
commentsPlaceholder.Content = comments;
|
||||||
|
comments.Initialize(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.NoAuthService.VideoCategories.List("snippet");
|
VideoCategoriesResource.ListRequest categoryRequest = SecretsVault.NoAuthService.VideoCategories.List("snippet");
|
||||||
@@ -136,11 +144,20 @@ namespace FoxTube
|
|||||||
channelName.Text = item.Snippet.ChannelTitle;
|
channelName.Text = item.Snippet.ChannelTitle;
|
||||||
subscribers.Text = item1.Statistics.SubscriberCount + " subscribers";
|
subscribers.Text = item1.Statistics.SubscriberCount + " subscribers";
|
||||||
|
|
||||||
/*var ratingResponse = await SecretsVault.YoutubeService.Videos.GetRating(id).ExecuteAsync();
|
if(SecretsVault.IsAuthorized)
|
||||||
|
{
|
||||||
|
VideoGetRatingResponse ratingResponse = await SecretsVault.Service.Videos.GetRating(id).ExecuteAsync();
|
||||||
if (ratingResponse.Items[0].Rating == "like")
|
if (ratingResponse.Items[0].Rating == "like")
|
||||||
|
{
|
||||||
|
userRating = Rating.Like;
|
||||||
like.Foreground = new SolidColorBrush(Colors.Green);
|
like.Foreground = new SolidColorBrush(Colors.Green);
|
||||||
|
}
|
||||||
else if (ratingResponse.Items[0].Rating == "dislike")
|
else if (ratingResponse.Items[0].Rating == "dislike")
|
||||||
dislike.Foreground = new SolidColorBrush(Colors.Red);*/
|
{
|
||||||
|
userRating = Rating.Dislike;
|
||||||
|
dislike.Foreground = new SolidColorBrush(Colors.Red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
player = new VideoPlayer(item, item1.Snippet.Thumbnails.Medium.Url);
|
player = new VideoPlayer(item, item1.Snippet.Thumbnails.Medium.Url);
|
||||||
player.SetFullSize += Player_SetFullSize;
|
player.SetFullSize += Player_SetFullSize;
|
||||||
@@ -164,7 +181,7 @@ namespace FoxTube
|
|||||||
loadingRelated.Refresh();
|
loadingRelated.Refresh();
|
||||||
loadingRelated.Visibility = Visibility.Visible;
|
loadingRelated.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
SearchResource.ListRequest request = SecretsVault.NoAuthService.Search.List("snippet");
|
SearchResource.ListRequest request = SecretsVault.IsAuthorized? SecretsVault.Service.Search.List("snippet") : SecretsVault.NoAuthService.Search.List("snippet");
|
||||||
request.RelatedToVideoId = videoId;
|
request.RelatedToVideoId = videoId;
|
||||||
request.MaxResults = 20;
|
request.MaxResults = 20;
|
||||||
request.Type = "video";
|
request.Type = "video";
|
||||||
@@ -416,57 +433,72 @@ namespace FoxTube
|
|||||||
|
|
||||||
private async void dislike_Click(object sender, RoutedEventArgs e)
|
private async void dislike_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if(like.Foreground == new SolidColorBrush(Colors.Green))
|
if (SecretsVault.IsAuthorized)
|
||||||
|
switch (userRating)
|
||||||
{
|
{
|
||||||
|
case Rating.Like:
|
||||||
like.Foreground = new SolidColorBrush(Colors.Gray);
|
like.Foreground = new SolidColorBrush(Colors.Gray);
|
||||||
likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString();
|
likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString();
|
||||||
rating.Value = (int)((item.Statistics.DislikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
|
|
||||||
await SecretsVault.NoAuthService.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dislike.Foreground == new SolidColorBrush(Colors.Red))
|
|
||||||
{
|
|
||||||
dislike.Foreground = new SolidColorBrush(Colors.Gray);
|
|
||||||
rating.Value = (int)((item.Statistics.DislikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
|
|
||||||
await SecretsVault.NoAuthService.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dislike.Foreground = new SolidColorBrush(Colors.Red);
|
dislike.Foreground = new SolidColorBrush(Colors.Red);
|
||||||
dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString();
|
dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString();
|
||||||
rating.Value = (int)((item.Statistics.DislikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
|
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100);
|
||||||
await SecretsVault.NoAuthService.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
|
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
|
||||||
|
|
||||||
|
userRating = Rating.Dislike;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Rating.None:
|
||||||
|
dislike.Foreground = new SolidColorBrush(Colors.Red);
|
||||||
|
dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString();
|
||||||
|
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
|
||||||
|
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
|
||||||
|
|
||||||
|
userRating = Rating.Dislike;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Rating.Dislike:
|
||||||
|
dislike.Foreground = new SolidColorBrush(Colors.Gray);
|
||||||
|
dislikes.Text = (Convert.ToInt32(dislikes.Text) - 1).ToString();
|
||||||
|
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
|
||||||
|
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void like_Click(object sender, RoutedEventArgs e)
|
private async void like_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dislike.Foreground == new SolidColorBrush(Colors.Red))
|
if(SecretsVault.IsAuthorized)
|
||||||
|
switch (userRating)
|
||||||
{
|
{
|
||||||
|
case Rating.Dislike:
|
||||||
dislike.Foreground = new SolidColorBrush(Colors.Gray);
|
dislike.Foreground = new SolidColorBrush(Colors.Gray);
|
||||||
dislikes.Text = (Convert.ToInt32(likes.Text) - 1).ToString();
|
dislikes.Text = (Convert.ToInt32(dislikes.Text) - 1).ToString();
|
||||||
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
|
|
||||||
await SecretsVault.NoAuthService.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (like.Foreground == new SolidColorBrush(Colors.Green))
|
|
||||||
{
|
|
||||||
like.Foreground = new SolidColorBrush(Colors.Gray);
|
|
||||||
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
|
|
||||||
await SecretsVault.NoAuthService.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
like.Foreground = new SolidColorBrush(Colors.Green);
|
like.Foreground = new SolidColorBrush(Colors.Green);
|
||||||
likes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString();
|
likes.Text = (Convert.ToInt32(likes.Text) + 1).ToString();
|
||||||
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
|
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100);
|
||||||
await SecretsVault.NoAuthService.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
|
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void description_LinkClicked(object sender, Microsoft.Toolkit.Uwp.UI.Controls.LinkClickedEventArgs e)
|
userRating = Rating.Like;
|
||||||
{
|
break;
|
||||||
await Launcher.LaunchUriAsync(new Uri(e.Link));
|
|
||||||
|
case Rating.None:
|
||||||
|
like.Foreground = new SolidColorBrush(Colors.Green);
|
||||||
|
likes.Text = (Convert.ToInt32(likes.Text) + 1).ToString();
|
||||||
|
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
|
||||||
|
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync();
|
||||||
|
|
||||||
|
userRating = Rating.Like;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Rating.Like:
|
||||||
|
like.Foreground = new SolidColorBrush(Colors.Gray);
|
||||||
|
likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString();
|
||||||
|
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
|
||||||
|
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user