From 8159d33a436bffc7ceba4426cdceff31eb91746f Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Thu, 14 May 2020 00:03:21 +0300 Subject: [PATCH] Implemented incognito mode --- FoxTube.Core/UserManagement.cs | 6 ++++-- FoxTube/Controls/AccountManager.xaml | 3 +++ FoxTube/Controls/AccountManager.xaml.cs | 27 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/FoxTube.Core/UserManagement.cs b/FoxTube.Core/UserManagement.cs index 551f6f5..0c6c1c3 100644 --- a/FoxTube.Core/UserManagement.cs +++ b/FoxTube.Core/UserManagement.cs @@ -54,11 +54,13 @@ namespace FoxTube public static Userinfoplus[] Users { get; private set; } = new Userinfoplus[MaxUsersCount]; + public static bool IncognitoMode { get; set; } = false; + public static bool CanAddAccounts => Users.Any(i => i == null); public static User CurrentUser { get; set; } public static bool Authorized => CurrentUser != null; - public static ExtendedYouTubeService Service => CurrentUser?.Service ?? _defaultService; - public static YoutubeClient YoutubeClient => CurrentUser?.Client ?? _defaultYteClient; + public static ExtendedYouTubeService Service => IncognitoMode ? _defaultService : (CurrentUser?.Service ?? _defaultService); + public static YoutubeClient YoutubeClient => IncognitoMode ? _defaultYteClient : (CurrentUser?.Client ?? _defaultYteClient); public static event EventHandler UserStateUpdated; public static event EventHandler SubscriptionsChanged; diff --git a/FoxTube/Controls/AccountManager.xaml b/FoxTube/Controls/AccountManager.xaml index 155ce7f..c9e0dc3 100644 --- a/FoxTube/Controls/AccountManager.xaml +++ b/FoxTube/Controls/AccountManager.xaml @@ -80,6 +80,9 @@ + + + diff --git a/FoxTube/Controls/AccountManager.xaml.cs b/FoxTube/Controls/AccountManager.xaml.cs index eea474d..21a26b0 100644 --- a/FoxTube/Controls/AccountManager.xaml.cs +++ b/FoxTube/Controls/AccountManager.xaml.cs @@ -88,5 +88,32 @@ namespace FoxTube.Controls break; } } + + private void Incognito_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) => + incognito.IsOn = !incognito.IsOn; + + private void Icognito_Toggled(object sender, RoutedEventArgs e) + { + if (incognito.IsOn) + MainPage.Current.RequestedTheme = ElementTheme.Dark; + else + { + if (Settings.Theme == 0) + MainPage.Current.RequestedTheme = ElementTheme.Light; + else if (Settings.Theme == 1) + MainPage.Current.RequestedTheme = ElementTheme.Dark; + else + MainPage.Current.RequestedTheme = ElementTheme.Default; + + if (RequestedTheme == ElementTheme.Default) + App.UpdateTitleBar(Application.Current.RequestedTheme == ApplicationTheme.Dark); + else + App.UpdateTitleBar(MainPage.Current.RequestedTheme == ElementTheme.Dark); + } + + UpdateLayout(); + + UserManagement.IncognitoMode = incognito.IsOn; + } } } \ No newline at end of file