Archived
1
0

Items cards' context menu. Fixed duplicating authors' name on comments replies. Another version of logo

Related Work Items: #226
This commit is contained in:
Michael Gordeev
2018-12-31 01:42:11 +03:00
parent 7f4eaa0c7a
commit f136aa8d0c
9 changed files with 121 additions and 24 deletions
+8
View File
@@ -52,4 +52,12 @@
</Grid> </Grid>
</Grid> </Grid>
</Button> </Button>
<UserControl.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Icon="Contact" Text="View channel" Click="Button_Click"/>
<MenuFlyoutSeparator/>
<MenuFlyoutItem Icon="Link" Text="Copy link" Name="getLink" Click="GetLink_Click"/>
<MenuFlyoutItem Icon="Share" Text="Share" Name="share" Click="Share_Click"/>
</MenuFlyout>
</UserControl.ContextFlyout>
</UserControl> </UserControl>
+27 -12
View File
@@ -1,26 +1,19 @@
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using System; using System;
using System.Collections.Generic; using Windows.ApplicationModel.DataTransfer;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation; using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI; using Windows.UI;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace FoxTube.Controls namespace FoxTube.Controls
{ {
/// <summary>
/// Channel item card
/// </summary>
public sealed partial class ChannelCard : UserControl public sealed partial class ChannelCard : UserControl
{ {
string channelId; string channelId;
@@ -28,8 +21,9 @@ namespace FoxTube.Controls
public ChannelCard(string id, string live = "null") public ChannelCard(string id, string live = "null")
{ {
this.InitializeComponent(); InitializeComponent();
Initialize(id, live); Initialize(id, live);
DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Share);
} }
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
@@ -104,5 +98,26 @@ namespace FoxTube.Controls
subscribe.Content = "Subscribe"; subscribe.Content = "Subscribe";
} }
} }
private void GetLink_Click(object sender, RoutedEventArgs e)
{
DataPackage data = new DataPackage();
data.SetText(string.IsNullOrWhiteSpace(item.Snippet.CustomUrl) ? $"https://www.youtube.com/channel/{item.Id}" : $"https://www.youtube.com/user/{item.Snippet.CustomUrl}");
Clipboard.SetContent(data);
}
private void Share_Click(object sender, RoutedEventArgs e)
{
DataTransferManager.ShowShareUI();
}
private void Share(DataTransferManager sender, DataRequestedEventArgs args)
{
Methods.Share(args,
item.Snippet.Thumbnails.Medium.Url,
item.Snippet.Title,
string.IsNullOrWhiteSpace(item.Snippet.CustomUrl) ? $"https://www.youtube.com/channel/{item.Id}" : $"https://www.youtube.com/user/{item.Snippet.CustomUrl}",
"channel");
}
} }
} }
+1 -1
View File
@@ -118,7 +118,7 @@ namespace FoxTube.Controls
else else
author.Text = comment.Snippet.AuthorDisplayName; author.Text = comment.Snippet.AuthorDisplayName;
meta.Text = string.Format("{0} {1}", comment.Snippet.AuthorDisplayName, Methods.GetAgo(comment.Snippet.PublishedAt.Value), comment.Snippet.UpdatedAt.Value != comment.Snippet.PublishedAt.Value ? "(edited)" : ""); meta.Text = string.Format("{0} {1}", Methods.GetAgo(comment.Snippet.PublishedAt.Value), comment.Snippet.UpdatedAt != comment.Snippet.PublishedAt ? "(edited)" : "");
Methods.FormatText(ref text, comment.Snippet.TextDisplay); Methods.FormatText(ref text, comment.Snippet.TextDisplay);
try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.AuthorProfileImageUrl)); } try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.AuthorProfileImageUrl)); }
+9
View File
@@ -48,4 +48,13 @@
</Grid> </Grid>
</Grid> </Grid>
</Button> </Button>
<UserControl.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Icon="List" Text="View playlist" Click="Button_Click"/>
<MenuFlyoutItem Icon="Contact" Text="View channel" Name="openChannel" Click="OpenChannel_Click"/>
<MenuFlyoutSeparator/>
<MenuFlyoutItem Icon="Link" Text="Copy link" Name="getLink" Click="GetLink_Click"/>
<MenuFlyoutItem Icon="Share" Text="Share" Name="share" Click="Share_Click"/>
</MenuFlyout>
</UserControl.ContextFlyout>
</Page> </Page>
+29
View File
@@ -1,6 +1,8 @@
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using System; using System;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
@@ -19,6 +21,7 @@ namespace FoxTube.Controls
{ {
InitializeComponent(); InitializeComponent();
Initialize(id); Initialize(id);
DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Share);
} }
public async void Initialize(string id) public async void Initialize(string id)
@@ -54,5 +57,31 @@ namespace FoxTube.Controls
{ {
Methods.MainPage.GoToPlaylist(item.Id); Methods.MainPage.GoToPlaylist(item.Id);
} }
private void OpenChannel_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(item.Snippet.ChannelId);
}
private void GetLink_Click(object sender, RoutedEventArgs e)
{
DataPackage data = new DataPackage();
data.SetText($"https://www.youtube.com/playlist?list={playlistId}");
Clipboard.SetContent(data);
}
private void Share_Click(object sender, RoutedEventArgs e)
{
DataTransferManager.ShowShareUI();
}
private void Share(DataTransferManager sender, DataRequestedEventArgs args)
{
Methods.Share(args,
item.Snippet.Thumbnails.Medium.Url,
item.Snippet.Title,
$"https://www.youtube.com/playlist?list={item.Id}",
"playlist");
}
} }
} }
+11 -6
View File
@@ -53,13 +53,18 @@
</Button> </Button>
<UserControl.ContextFlyout> <UserControl.ContextFlyout>
<MenuFlyout> <MenuFlyout>
<MenuFlyoutItem Icon="Play" Text="Play"/> <MenuFlyoutItem Icon="Play" Text="Play" Name="play" Click="Button_Click"/>
<MenuFlyoutItem Icon="Contact" Text="View channel"/> <MenuFlyoutItem Text="Play incognito" Visibility="Collapsed">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE727;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem Icon="Contact" Text="View channel" Name="viewChannel" Click="ViewChannel_Click"/>
<MenuFlyoutSeparator/> <MenuFlyoutSeparator/>
<MenuFlyoutItem Icon="Link" Text="Copy link"/> <MenuFlyoutItem Icon="Link" Text="Copy link" Name="getLink" Click="GetLink_Click"/>
<MenuFlyoutItem Icon="Share" Text="Share"/> <MenuFlyoutItem Icon="Share" Text="Share" Name="share" Click="Share_Click"/>
<MenuFlyoutSeparator/> <MenuFlyoutSeparator Visibility="Collapsed"/>
<MenuFlyoutItem Icon="Download" Text="Download"/> <MenuFlyoutItem Icon="Download" Text="Download" Visibility="Collapsed"/>
</MenuFlyout> </MenuFlyout>
</UserControl.ContextFlyout> </UserControl.ContextFlyout>
</UserControl> </UserControl>
+33 -2
View File
@@ -4,12 +4,16 @@ using Windows.UI.Xaml.Controls;
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data; using Google.Apis.YouTube.v3.Data;
using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Imaging;
using System.Xml;
using Windows.System; using Windows.System;
using Windows.UI.Popups; using Windows.UI.Popups;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
namespace FoxTube.Controls namespace FoxTube.Controls
{ {
/// <summary>
/// Video item card
/// </summary>
public sealed partial class VideoCard : UserControl public sealed partial class VideoCard : UserControl
{ {
public string playlistId; public string playlistId;
@@ -19,8 +23,9 @@ namespace FoxTube.Controls
bool embed = false; bool embed = false;
public VideoCard(string id, string playlist = null) public VideoCard(string id, string playlist = null)
{ {
this.InitializeComponent(); InitializeComponent();
Initialize(id, playlist); Initialize(id, playlist);
DataTransferManager.GetForCurrentView().DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(Share);
} }
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e) private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
@@ -105,5 +110,31 @@ namespace FoxTube.Controls
else else
Methods.MainPage.GoToVideo(videoId, playlistId); Methods.MainPage.GoToVideo(videoId, playlistId);
} }
private void ViewChannel_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(item.Snippet.ChannelId);
}
private void GetLink_Click(object sender, RoutedEventArgs e)
{
DataPackage data = new DataPackage();
data.SetText($"https://www.youtube.com/watch?v={videoId}");
Clipboard.SetContent(data);
}
private void Share_Click(object sender, RoutedEventArgs e)
{
DataTransferManager.ShowShareUI();
}
private void Share(DataTransferManager sender, DataRequestedEventArgs args)
{
Methods.Share(args,
item.Snippet.Thumbnails.Medium.Url,
item.Snippet.Title,
$"https://www.youtube.com/watch?v={videoId}",
"video");
}
} }
} }
+3 -3
View File
@@ -48,9 +48,9 @@ namespace FoxTube
{ {
miniview = value; miniview = value;
if (value) if (value)
captions.Hide(); captions?.Hide();
else else
captions.Show(); captions?.Show();
} }
} }
private bool fullScreen = false; private bool fullScreen = false;
@@ -178,7 +178,7 @@ namespace FoxTube
systemControls.IsEnabled = true; systemControls.IsEnabled = true;
#endregion #endregion
videoSource.PosterSource = new BitmapImage(item.Snippet.Thumbnails.Maxres.Url.ToUri()); videoSource.PosterSource = new BitmapImage((item.Snippet.Thumbnails.Maxres ?? item.Snippet.Thumbnails.Medium).Url.ToUri());
title.Text = item.Snippet.Title; title.Text = item.Snippet.Title;
channelName.Text = item.Snippet.ChannelTitle; channelName.Text = item.Snippet.ChannelTitle;
Binary file not shown.