Complete comments
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
<Grid Background="WhiteSmoke" Margin="2" Name="grid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="0"/> <!--32-->
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="0"/>
|
||||
<RowDefinition Height="0"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -63,15 +63,16 @@
|
||||
</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"
|
||||
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"
|
||||
Width="32" Height="32" Padding="0"
|
||||
Background="Red" Foreground="White"
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
Content="" />
|
||||
<ProgressBar Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" IsIndeterminate="True" Foreground="Red" Name="sending" Visibility="Collapsed"/>
|
||||
|
||||
<StackPanel Grid.Row="2">
|
||||
<StackPanel Margin="60,0,0,0" Name="replies"/>
|
||||
|
||||
@@ -17,6 +17,7 @@ using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.System;
|
||||
using Windows.UI.Popups;
|
||||
|
||||
// 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;
|
||||
|
||||
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)
|
||||
showReplies.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
@@ -130,11 +131,6 @@ namespace FoxTube.Controls
|
||||
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)
|
||||
{
|
||||
more.Visibility = Visibility.Collapsed;
|
||||
@@ -155,5 +151,40 @@ namespace FoxTube.Controls
|
||||
}
|
||||
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,46 +9,45 @@
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Grid Background="White" Name="grid">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Background="Red">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Background="Red">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Margin="5,5,42,5" PlaceholderText="Add a public comment" VerticalAlignment="Center" MinHeight="32" MaxHeight="100" Height="auto" AcceptsReturn="True"/>
|
||||
<Button HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
<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" Name="send" Click="send_Click" VerticalAlignment="Top"
|
||||
Height="32" Width="32"
|
||||
Margin="0,5,5,0" Padding="0"
|
||||
Background="Transparent" Foreground="White"
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
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"/>
|
||||
<StackPanel Padding="0" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
|
||||
<TextBlock Text="Sort by: " Foreground="White" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
||||
<Button Name="orderBtn" Background="Transparent" Content="Relevance" Foreground="DeepSkyBlue" Padding="0" VerticalAlignment="Center">
|
||||
<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">
|
||||
<TextBlock Text="Sort by: " Foreground="White" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
||||
<Button Name="orderBtn" Background="Transparent" Content="Relevance" Foreground="DeepSkyBlue" Padding="0" VerticalAlignment="Center">
|
||||
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Click="toRelevance_Click" Name="toRelevance" Text="Relevance"/>
|
||||
<MenuFlyoutItem Click="toDate_Click" Name="toDate" Text="Date"/>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<StackPanel>
|
||||
<StackPanel Name="placeholder"/>
|
||||
<HyperlinkButton Name="more" Click="more_Click" HorizontalAlignment="Center" Foreground="Red" Content="Show more"/>
|
||||
<ProgressBar Name="moreLoading" Visibility="Collapsed" IsIndeterminate="True" Foreground="Red"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Click="toRelevance_Click" Name="toRelevance" Text="Relevance"/>
|
||||
<MenuFlyoutItem Click="toDate_Click" Name="toDate" Text="Date"/>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer Grid.Row="1" Name="scroll">
|
||||
<StackPanel>
|
||||
<StackPanel Name="placeholder"/>
|
||||
<HyperlinkButton Name="more" Click="more_Click" HorizontalAlignment="Center" Foreground="Red" Content="Show more"/>
|
||||
<ProgressBar Name="moreLoading" Visibility="Collapsed" IsIndeterminate="True" Foreground="Red"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -16,6 +16,7 @@ using Windows.UI.Xaml.Navigation;
|
||||
using Google.Apis.YouTube.v3;
|
||||
using Google.Apis.YouTube.v3.Data;
|
||||
using FoxTube.Controls;
|
||||
using Windows.UI.Popups;
|
||||
|
||||
// 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;
|
||||
|
||||
if (!SecretsVault.IsAuthorized)
|
||||
grid.RowDefinitions[0].Height = new GridLength(0);
|
||||
|
||||
counter.Text = string.Format("{0:0,0} Comments", video.Statistics.CommentCount);
|
||||
|
||||
var request = SecretsVault.NoAuthService.CommentThreads.List("snippet,replies");
|
||||
@@ -133,5 +137,41 @@ namespace FoxTube.Pages
|
||||
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