From 05415e44c7938810525b4800c68135a2ff754b42 Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Fri, 10 Aug 2018 23:31:06 +0300 Subject: [PATCH] theme switch fix, channel search filters fix, search in browser added --- FoxTube/Pages/Search.xaml | 2 +- FoxTube/Pages/Search.xaml.cs | 21 +++++++++++---------- FoxTube/Pages/SettingsPages/General.xaml.cs | 19 ++++++++++--------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/FoxTube/Pages/Search.xaml b/FoxTube/Pages/Search.xaml index e363e49..4ad2163 100644 --- a/FoxTube/Pages/Search.xaml +++ b/FoxTube/Pages/Search.xaml @@ -73,7 +73,7 @@ - + diff --git a/FoxTube/Pages/Search.xaml.cs b/FoxTube/Pages/Search.xaml.cs index 4deadbd..18afb3f 100644 --- a/FoxTube/Pages/Search.xaml.cs +++ b/FoxTube/Pages/Search.xaml.cs @@ -18,6 +18,7 @@ using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; +using Windows.System; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 @@ -29,7 +30,7 @@ namespace FoxTube public sealed partial class Search : Page { public string Term; - bool isChannel = false; + string channelId = null; SearchResource.ListRequest request; string nextToken; ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; @@ -66,7 +67,7 @@ namespace FoxTube break; case "youtube#channel": - if(!isChannel) + if(channelId != null) { ChannelCard cCard = new ChannelCard(result.Id.ChannelId/*, result.Snippet.LiveBroadcastContent*/); list.Add(cCard); @@ -99,10 +100,10 @@ namespace FoxTube public void Initialize(SearchParameters arg) { - Initialize(arg.Term, channelId: arg.ChannelId); + Initialize(arg.Term, channel: arg.ChannelId); } - public async void Initialize(string term, bool forceInitialization = false, string channelId = null) + public async void Initialize(string term, bool forceInitialization = false, string channel = null) { if (term == Term && !forceInitialization) return; @@ -112,10 +113,10 @@ namespace FoxTube { Term = term; request = SecretsVault.Service.Search.List("id"); - if (!string.IsNullOrWhiteSpace(channelId)) + if (!string.IsNullOrWhiteSpace(channel)) { - isChannel = true; - request.ChannelId = channelId; + channelId = channel; + request.ChannelId = channel; (grid.Children[1] as CommandBar).Visibility = Visibility.Collapsed; } request.Q = term; @@ -267,7 +268,7 @@ namespace FoxTube private void AppBarButton_Click(object sender, RoutedEventArgs e) { - Initialize(Term, true); + Initialize(Term, true, channelId); } private async void more_Clicked() @@ -304,9 +305,9 @@ namespace FoxTube catch (NullReferenceException) { } } - private void inBrowser_Click(object sender, RoutedEventArgs e) + private async void inBrowser_Click(object sender, RoutedEventArgs e) { - + await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/results?search_query={searchTerm}")); } } } diff --git a/FoxTube/Pages/SettingsPages/General.xaml.cs b/FoxTube/Pages/SettingsPages/General.xaml.cs index 1ce13e7..84cdbc9 100644 --- a/FoxTube/Pages/SettingsPages/General.xaml.cs +++ b/FoxTube/Pages/SettingsPages/General.xaml.cs @@ -8,6 +8,7 @@ using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.Storage; +using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; @@ -94,24 +95,24 @@ namespace FoxTube.Pages.SettingsPages private void RadioButton_Checked(object sender, RoutedEventArgs e) { - if (sender == light) + if (sender == light && (int)settings.Values["themeMode"] != 0) { settings.Values["themeMode"] = 0; - Application.Current.RequestedTheme = ApplicationTheme.Light; + Methods.MainPage.RequestedTheme = ElementTheme.Light; } - if (sender == dark) + if (sender == dark && (int)settings.Values["themeMode"] != 1) { settings.Values["themeMode"] = 1; - Application.Current.RequestedTheme = ApplicationTheme.Dark; + Methods.MainPage.RequestedTheme = ElementTheme.Dark; } - if (sender == system) + if (sender == system && (int)settings.Values["themeMode"] != 2) { settings.Values["themeMode"] = 2; - string uiTheme = (new Windows.UI.ViewManagement.UISettings()).GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString(); - if (uiTheme == "#FF000000") - Application.Current.RequestedTheme = ApplicationTheme.Dark; + Color uiTheme = (new Windows.UI.ViewManagement.UISettings()).GetColorValue(Windows.UI.ViewManagement.UIColorType.Background); + if (uiTheme == Colors.Black) + Methods.MainPage.RequestedTheme = ElementTheme.Dark; else - Application.Current.RequestedTheme = ApplicationTheme.Light; + Methods.MainPage.RequestedTheme = ElementTheme.Light; } } }