Archived
1
0

Search fix

This commit is contained in:
Michael Gordeev
2018-05-07 22:09:46 +03:00
parent 5ee95a95a6
commit 96b81c02c6
5 changed files with 60 additions and 33 deletions
+1 -1
View File
@@ -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>
+4 -1
View File
@@ -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)
+18 -1
View File
@@ -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;
}
} }
} }
} }
+28 -25
View File
@@ -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"/>
<TextBlock Name="resultsCount" Text="[resultsCount]" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
<TextBlock Text="items" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
</StackPanel>
<HyperlinkButton Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" FontSize="18" Visibility="Collapsed"/>
<Grid Background="WhiteSmoke" Padding="5" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Type" FontSize="20"/>
<Line StrokeThickness="1" Stroke="Gray" X1="0" X2="150"/>
<RadioButton Content="All" IsChecked="True"/>
<RadioButton Content="Videos"/>
<RadioButton Content="Channels"/>
<RadioButton Content="Playlists"/>
</StackPanel> </StackPanel>
</Grid> <StackPanel Orientation="Horizontal">
<StackPanel Name="resultsList" Orientation="Vertical"> <TextBlock Text="Found:" FontSize="14" Foreground="Gray" Margin="0,-5,0,10"/>
<TextBlock Name="resultsCount" Text="[resultsCount]" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
<TextBlock Text="items" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
</StackPanel>
<HyperlinkButton Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" FontSize="18" Visibility="Collapsed"/>
<Grid Background="WhiteSmoke" Padding="5" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Type" FontSize="20"/>
<Line StrokeThickness="1" Stroke="Gray" X1="0" X2="150"/>
<RadioButton Content="All" IsChecked="True"/>
<RadioButton Content="Videos"/>
<RadioButton Content="Channels"/>
<RadioButton Content="Playlists"/>
</StackPanel>
</Grid>
<StackPanel Name="resultsList" Orientation="Vertical">
</StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </Grid>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
</Page> </Page>
+8 -4
View File
@@ -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");