Archived
1
0

Implemented incognito mode

This commit is contained in:
Michael Gordeev
2020-05-14 00:03:21 +03:00
parent d25bc92188
commit 8159d33a43
3 changed files with 34 additions and 2 deletions
+4 -2
View File
@@ -54,11 +54,13 @@ namespace FoxTube
public static Userinfoplus[] Users { get; private set; } = new Userinfoplus[MaxUsersCount]; 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 bool CanAddAccounts => Users.Any(i => i == null);
public static User CurrentUser { get; set; } public static User CurrentUser { get; set; }
public static bool Authorized => CurrentUser != null; public static bool Authorized => CurrentUser != null;
public static ExtendedYouTubeService Service => CurrentUser?.Service ?? _defaultService; public static ExtendedYouTubeService Service => IncognitoMode ? _defaultService : (CurrentUser?.Service ?? _defaultService);
public static YoutubeClient YoutubeClient => CurrentUser?.Client ?? _defaultYteClient; public static YoutubeClient YoutubeClient => IncognitoMode ? _defaultYteClient : (CurrentUser?.Client ?? _defaultYteClient);
public static event EventHandler<bool> UserStateUpdated; public static event EventHandler<bool> UserStateUpdated;
public static event EventHandler<Subscription> SubscriptionsChanged; public static event EventHandler<Subscription> SubscriptionsChanged;
+3
View File
@@ -80,6 +80,9 @@
<NavigationViewList> <NavigationViewList>
<NavigationViewItemSeparator/> <NavigationViewItemSeparator/>
<NavigationViewItem Tapped="NavigationViewItem_Tapped" x:Name="addAccountButton" Content="Add account" Tag="addUser" Icon="Add"/> <NavigationViewItem Tapped="NavigationViewItem_Tapped" x:Name="addAccountButton" Content="Add account" Tag="addUser" Icon="Add"/>
<NavigationViewItem Tapped="Incognito_Tapped">
<ToggleSwitch x:Name="incognito" OnContent="Incognito mode" OffContent="Incognito mode" Toggled="Icognito_Toggled"/>
</NavigationViewItem>
<NavigationViewItem Tapped="NavigationViewItem_Tapped" Content="Sign out" Foreground="Red" Tag="logout"> <NavigationViewItem Tapped="NavigationViewItem_Tapped" Content="Sign out" Foreground="Red" Tag="logout">
<NavigationViewItem.Icon> <NavigationViewItem.Icon>
<FontIcon Glyph="&#xE1E0;"/> <FontIcon Glyph="&#xE1E0;"/>
+27
View File
@@ -88,5 +88,32 @@ namespace FoxTube.Controls
break; 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;
}
} }
} }