Search fix
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
</StackPanel>
|
||||
<TextBlock Name="subscribers" Text="120,452 subscribers" Foreground="Gray"/>
|
||||
<TextBlock Name="videoCount" Foreground="Gray" Text="563,000 videos"/>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" Name="subscriptionPane">
|
||||
<ToggleButton Grid.Column="2" Height="40" Width="200" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
|
||||
<ToggleButton Grid.Column="3" Height="40" Width="40" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace FoxTube
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public void AddInfo(string name, int videos, string avatarUrl, string channelUrl, int subs, Visibility live)
|
||||
public void AddInfo(string name, int videos, string avatarUrl, string channelUrl, int subs, Visibility live, bool logged)
|
||||
{
|
||||
channelName.Text = name;
|
||||
videoCount.Text = string.Format("{0} videos", videos);
|
||||
@@ -38,6 +38,9 @@ namespace FoxTube
|
||||
|
||||
channelId = channelUrl;
|
||||
liveTag.Visibility = live;
|
||||
|
||||
if (!logged)
|
||||
subscriptionPane.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -38,6 +38,15 @@ namespace FoxTube
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
private bool loggedIn = false;
|
||||
public bool Logged
|
||||
{
|
||||
get
|
||||
{
|
||||
return loggedIn;
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
List<Notification> notifications = new List<Notification>();
|
||||
public MainPage()
|
||||
@@ -376,6 +385,8 @@ namespace FoxTube
|
||||
private async void StartSearch(string keyword)
|
||||
{
|
||||
content.Navigate(typeof(Search));
|
||||
topHamburger.SelectedItem = null;
|
||||
bottomHaburger.SelectedItem = null;
|
||||
|
||||
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
@@ -393,14 +404,20 @@ namespace FoxTube
|
||||
s.SetResults(keyword, (int)response.PageInfo.TotalResults);
|
||||
Debug.WriteLine("building items tree...");
|
||||
foreach (SearchResult result in response.Items)
|
||||
s.AddItem(result);
|
||||
s.AddItem(result, Logged);
|
||||
s.ring.IsActive = false;
|
||||
s.content.Visibility = Visibility.Visible;
|
||||
Debug.WriteLine("done");
|
||||
}
|
||||
|
||||
private void searchField_KeyUp(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == Windows.System.VirtualKey.Enter)
|
||||
{
|
||||
searchButton_Click(this, null);
|
||||
content.Focus(FocusState.Pointer);
|
||||
searchSuggestions.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -9,7 +9,9 @@
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<ScrollViewer>
|
||||
<StackPanel Orientation="Vertical" Margin="10">
|
||||
<Grid>
|
||||
<ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="True" Name="progressRing" Foreground="Red" Width="100" Height="100"/>
|
||||
<StackPanel Orientation="Vertical" Margin="10" Visibility="Collapsed" Name="displaying">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Search results for: " FontSize="28"/>
|
||||
<TextBlock Name="searchTerm" Text="[searchTerm]" FontSize="28" Margin="10,0,0,0"/>
|
||||
@@ -37,6 +39,7 @@
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@@ -24,9 +24,13 @@ namespace FoxTube
|
||||
/// </summary>
|
||||
public sealed partial class Search : Page
|
||||
{
|
||||
public ProgressRing ring;
|
||||
public StackPanel content;
|
||||
public Search()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
ring = progressRing;
|
||||
content = displaying;
|
||||
}
|
||||
|
||||
public void SetResults(string keyword, int count)
|
||||
@@ -38,7 +42,7 @@ namespace FoxTube
|
||||
resultsCount.Text = count.ToString();
|
||||
}
|
||||
|
||||
public void AddItem(SearchResult result)
|
||||
public void AddItem(SearchResult result, bool logged)
|
||||
{
|
||||
switch (result.Id.Kind)
|
||||
{
|
||||
@@ -51,7 +55,7 @@ namespace FoxTube
|
||||
|
||||
case "youtube#channel":
|
||||
AddChannel(result.Snippet.Title, 0, 0,
|
||||
result.Snippet.ChannelId, result.Snippet.Thumbnails.Medium.Url, result.Snippet.LiveBroadcastContent);
|
||||
result.Snippet.ChannelId, result.Snippet.Thumbnails.Medium.Url, result.Snippet.LiveBroadcastContent, logged);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -81,7 +85,7 @@ namespace FoxTube
|
||||
}
|
||||
|
||||
void AddChannel(string name, int followers, int uploads,
|
||||
string url, string avatar, string liveBroadcast)
|
||||
string url, string avatar, string liveBroadcast, bool logged)
|
||||
{
|
||||
Visibility live;
|
||||
if (liveBroadcast != "live")
|
||||
@@ -90,7 +94,7 @@ namespace FoxTube
|
||||
|
||||
ChannelCard card = new ChannelCard();
|
||||
card.AddInfo(name, uploads, avatar,
|
||||
"https://www.youtube.com/channel/" + url, followers, live);
|
||||
"https://www.youtube.com/channel/" + url, followers, live, logged);
|
||||
|
||||
resultsList.Children.Add(card);
|
||||
Debug.WriteLine("result item added");
|
||||
|
||||
Reference in New Issue
Block a user