Complete comments
This commit is contained in:
@@ -12,8 +12,8 @@
|
|||||||
<Grid Background="WhiteSmoke" Margin="2" Name="grid">
|
<Grid Background="WhiteSmoke" Margin="2" Name="grid">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition Height="0"/> <!--32-->
|
<RowDefinition Height="0"/>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="0"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -63,15 +63,16 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<TextBox Grid.Row="1" BorderThickness="0" Background="LightGray"
|
<TextBox Grid.Row="1" Name="reply" TextChanged="reply_TextChanged" BorderThickness="0" Background="LightGray" AcceptsReturn="True" MaxLength="500"
|
||||||
Padding="5" Margin="0,0,32,0"
|
Padding="5" Margin="0,0,32,0"
|
||||||
PlaceholderText="Enter your reply..."/>
|
PlaceholderText="Enter your reply..."/>
|
||||||
<Button Grid.Row="1" HorizontalAlignment="Right"
|
<Button Grid.Row="1" Name="send" Click="send_Click" IsEnabled="False" HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||||
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||||
Width="32" Height="32" Padding="0"
|
Width="32" Height="32" Padding="0"
|
||||||
Background="Red" Foreground="White"
|
Background="Red" Foreground="White"
|
||||||
FontFamily="Segoe MDL2 Assets"
|
FontFamily="Segoe MDL2 Assets"
|
||||||
Content="" />
|
Content="" />
|
||||||
|
<ProgressBar Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsIndeterminate="True" Foreground="Red" Name="sending" Visibility="Collapsed"/>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2">
|
<StackPanel Grid.Row="2">
|
||||||
<StackPanel Margin="60,0,0,0" Name="replies"/>
|
<StackPanel Margin="60,0,0,0" Name="replies"/>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ 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 Windows.System;
|
using Windows.System;
|
||||||
|
using Windows.UI.Popups;
|
||||||
|
|
||||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ namespace FoxTube.Controls
|
|||||||
{
|
{
|
||||||
item = comment.Snippet.TopLevelComment;
|
item = comment.Snippet.TopLevelComment;
|
||||||
|
|
||||||
replyBtn.Visibility = comment.Snippet.CanReply == true ? Visibility.Visible : Visibility.Collapsed;
|
replyBtn.Visibility = !comment.Snippet.CanReply.Value || !SecretsVault.IsAuthorized ? Visibility.Collapsed : Visibility.Visible;
|
||||||
if (!comment.Snippet.TotalReplyCount.HasValue || comment.Snippet.TotalReplyCount.Value == 0)
|
if (!comment.Snippet.TotalReplyCount.HasValue || comment.Snippet.TotalReplyCount.Value == 0)
|
||||||
showReplies.Visibility = Visibility.Collapsed;
|
showReplies.Visibility = Visibility.Collapsed;
|
||||||
else
|
else
|
||||||
@@ -130,11 +131,6 @@ namespace FoxTube.Controls
|
|||||||
Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]);
|
Methods.MainPage.GoToChannel(item.Snippet.AuthorChannelId.ToString().Split('"')[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void text_LinkClicked(object sender, Microsoft.Toolkit.Uwp.UI.Controls.LinkClickedEventArgs e)
|
|
||||||
{
|
|
||||||
await Launcher.LaunchUriAsync(new Uri(e.Link));
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void more_Click(object sender, RoutedEventArgs e)
|
private async void more_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
more.Visibility = Visibility.Collapsed;
|
more.Visibility = Visibility.Collapsed;
|
||||||
@@ -155,5 +151,40 @@ namespace FoxTube.Controls
|
|||||||
}
|
}
|
||||||
moreLoading.Visibility = Visibility.Collapsed;
|
moreLoading.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reply_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (reply.Text.Length == 0)
|
||||||
|
send.IsEnabled = false;
|
||||||
|
else
|
||||||
|
send.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void send_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
send.IsEnabled = false;
|
||||||
|
reply.IsEnabled = false;
|
||||||
|
sending.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
|
Comment comment = new Comment();
|
||||||
|
comment.Snippet = new CommentSnippet();
|
||||||
|
comment.Snippet.TextOriginal = reply.Text;
|
||||||
|
comment.Snippet.ParentId = item.Id;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Comment response = await SecretsVault.Service.Comments.Insert(comment, "snippet").ExecuteAsync();
|
||||||
|
reply.Text = "";
|
||||||
|
grid.RowDefinitions[1].Height = new GridLength(0);
|
||||||
|
replies.Children.Add(new CommentCard(response));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await new MessageDialog("Failed to send your reply. Please, try again later.", "Failed to send your reply").ShowAsync();
|
||||||
|
}
|
||||||
|
send.IsEnabled = true;
|
||||||
|
reply.IsEnabled = true;
|
||||||
|
sending.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
|
|
||||||
<Grid Background="White" Name="grid">
|
<Grid Background="White" Name="grid">
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
@@ -19,13 +18,14 @@
|
|||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
<RowDefinition Height="30"/>
|
<RowDefinition Height="30"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBox Margin="5,5,42,5" PlaceholderText="Add a public comment" VerticalAlignment="Center" MinHeight="32" MaxHeight="100" Height="auto" AcceptsReturn="True"/>
|
<TextBox Margin="5,5,42,5" PlaceholderText="Add a public comment" Name="newComment" VerticalAlignment="Center" MinHeight="32" MaxHeight="100" Height="auto" AcceptsReturn="True"/>
|
||||||
<Button HorizontalAlignment="Right" VerticalAlignment="Top"
|
<Button HorizontalAlignment="Right" Name="send" Click="send_Click" VerticalAlignment="Top"
|
||||||
Height="32" Width="32"
|
Height="32" Width="32"
|
||||||
Margin="0,5,5,0" Padding="0"
|
Margin="0,5,5,0" Padding="0"
|
||||||
Background="Transparent" Foreground="White"
|
Background="Transparent" Foreground="White"
|
||||||
FontFamily="Segoe MDL2 Assets"
|
FontFamily="Segoe MDL2 Assets"
|
||||||
Content="" FontSize="30" ToolTipService.ToolTip="Post comment"/>
|
Content="" FontSize="30" ToolTipService.ToolTip="Post comment"/>
|
||||||
|
<ProgressBar Name="sending" IsIndeterminate="True" Foreground="Red" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/>
|
||||||
|
|
||||||
<TextBlock Name="counter" Grid.Row="1" Text="[Comments count] Comments" Margin="5,0,0,0" VerticalAlignment="Center" Foreground="White" FontWeight="SemiBold"/>
|
<TextBlock Name="counter" Grid.Row="1" Text="[Comments count] Comments" Margin="5,0,0,0" VerticalAlignment="Center" Foreground="White" FontWeight="SemiBold"/>
|
||||||
<StackPanel Padding="0" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
|
<StackPanel Padding="0" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<ScrollViewer Grid.Row="1">
|
<ScrollViewer Grid.Row="1" Name="scroll">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Name="placeholder"/>
|
<StackPanel Name="placeholder"/>
|
||||||
<HyperlinkButton Name="more" Click="more_Click" HorizontalAlignment="Center" Foreground="Red" Content="Show more"/>
|
<HyperlinkButton Name="more" Click="more_Click" HorizontalAlignment="Center" Foreground="Red" Content="Show more"/>
|
||||||
@@ -50,5 +50,4 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using Windows.UI.Xaml.Navigation;
|
|||||||
using Google.Apis.YouTube.v3;
|
using Google.Apis.YouTube.v3;
|
||||||
using Google.Apis.YouTube.v3.Data;
|
using Google.Apis.YouTube.v3.Data;
|
||||||
using FoxTube.Controls;
|
using FoxTube.Controls;
|
||||||
|
using Windows.UI.Popups;
|
||||||
|
|
||||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
@@ -40,6 +41,9 @@ namespace FoxTube.Pages
|
|||||||
{
|
{
|
||||||
threadId = video.Id;
|
threadId = video.Id;
|
||||||
|
|
||||||
|
if (!SecretsVault.IsAuthorized)
|
||||||
|
grid.RowDefinitions[0].Height = new GridLength(0);
|
||||||
|
|
||||||
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
|
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
|
||||||
|
|
||||||
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
|
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
|
||||||
@@ -133,5 +137,41 @@ namespace FoxTube.Pages
|
|||||||
moreLoading.Visibility = Visibility.Collapsed;
|
moreLoading.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void send_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if(newComment.Text.Length > 0)
|
||||||
|
{
|
||||||
|
newComment.IsEnabled = false;
|
||||||
|
send.IsEnabled = false;
|
||||||
|
sending.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
|
CommentThread thread = new CommentThread();
|
||||||
|
thread.Snippet = new CommentThreadSnippet();
|
||||||
|
|
||||||
|
Comment comment = new Comment();
|
||||||
|
comment.Snippet = new CommentSnippet();
|
||||||
|
comment.Snippet.TextOriginal = newComment.Text;
|
||||||
|
|
||||||
|
thread.Snippet.VideoId = threadId;
|
||||||
|
thread.Snippet.TopLevelComment = comment;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CommentThread response = await SecretsVault.Service.CommentThreads.Insert(thread, "snippet").ExecuteAsync();
|
||||||
|
newComment.Text = "";
|
||||||
|
placeholder.Children.Insert(0, new CommentCard(response));
|
||||||
|
scroll.ChangeView(null, 0, null);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await new MessageDialog("Failed to publish your comment. Please, try again later.", "Failed to publish your comment").ShowAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
newComment.IsEnabled = true;
|
||||||
|
send.IsEnabled = true;
|
||||||
|
sending.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user