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