Navigation improvements
This commit is contained in:
@@ -48,6 +48,8 @@ namespace FoxTube
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
|
||||
public enum Sender { Menu, Frame, None }
|
||||
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
public DownloadAgent Agent = new DownloadAgent();
|
||||
@@ -55,6 +57,7 @@ namespace FoxTube
|
||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||
|
||||
NotificationsCenter notificationsCenter = new NotificationsCenter();
|
||||
Sender s = Sender.None;
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
@@ -389,27 +392,33 @@ namespace FoxTube
|
||||
|
||||
private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||
{
|
||||
if (args.IsSettingsSelected)
|
||||
content.Navigate(typeof(Settings));
|
||||
else
|
||||
if (s == Sender.None)
|
||||
{
|
||||
if (args.SelectedItem == toHome)
|
||||
content.Navigate(typeof(Home));
|
||||
else if (args.SelectedItem == toHistory)
|
||||
s = Sender.Menu;
|
||||
if (args.IsSettingsSelected)
|
||||
content.Navigate(typeof(Settings));
|
||||
else if (args.SelectedItem == toLiked)
|
||||
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes);
|
||||
else if (args.SelectedItem == toLater)
|
||||
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater);
|
||||
else if (args.SelectedItem == toSubscriptions)
|
||||
content.Navigate(typeof(Settings));
|
||||
else if (args.SelectedItem == toDownloads)
|
||||
content.Navigate(typeof(Downloads));
|
||||
else if (args.SelectedItem == toChannel)
|
||||
content.Navigate(typeof(Channel), SecretsVault.UserChannel.Id);
|
||||
else
|
||||
content.Navigate(typeof(ChannelPage), SecretsVault.Subscriptions[Convert.ToInt32((args.SelectedItem as NavigationViewItem).Name)].Snippet.ResourceId.ChannelId);
|
||||
{
|
||||
if (args.SelectedItem == toHome)
|
||||
content.Navigate(typeof(Home));
|
||||
else if (args.SelectedItem == toHistory)
|
||||
content.Navigate(typeof(Settings));
|
||||
else if (args.SelectedItem == toLiked)
|
||||
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.Likes);
|
||||
else if (args.SelectedItem == toLater)
|
||||
content.Navigate(typeof(PlaylistPage), SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater);
|
||||
else if (args.SelectedItem == toSubscriptions)
|
||||
content.Navigate(typeof(Settings));
|
||||
else if (args.SelectedItem == toDownloads)
|
||||
content.Navigate(typeof(Downloads));
|
||||
else if (args.SelectedItem == toChannel)
|
||||
content.Navigate(typeof(Channel), SecretsVault.UserChannel.Id);
|
||||
else
|
||||
content.Navigate(typeof(ChannelPage), SecretsVault.Subscriptions[Convert.ToInt32((args.SelectedItem as NavigationViewItem).Name)].Snippet.ResourceId.ChannelId);
|
||||
}
|
||||
}
|
||||
else if (s == Sender.Frame)
|
||||
s = Sender.None;
|
||||
}
|
||||
|
||||
private void content_Navigated(object sender, NavigationEventArgs e)
|
||||
@@ -425,7 +434,35 @@ namespace FoxTube
|
||||
{ typeof(Downloads), () => header.Text = "Downloads" }
|
||||
};
|
||||
|
||||
switchCase[e.SourcePageType]();
|
||||
try { switchCase[e.SourcePageType](); }
|
||||
catch { }
|
||||
|
||||
if (s == Sender.None)
|
||||
{
|
||||
s = Sender.Frame;
|
||||
|
||||
Dictionary<Type, Action> navCase = new Dictionary<Type, Action>()
|
||||
{
|
||||
{ typeof(Settings), () => nav.SelectedItem = nav.SettingsItem },
|
||||
{ typeof(ChannelPage), () =>
|
||||
{
|
||||
//Check channel
|
||||
} },
|
||||
{ typeof(PlaylistPage), () =>
|
||||
{
|
||||
//Check playlist
|
||||
} },
|
||||
{ typeof(Search), () => nav.SelectedItem = null },
|
||||
{ typeof(History), () => nav.SelectedItem = toHistory },
|
||||
{ typeof(Home), () => nav.SelectedItem = toHome },
|
||||
{ typeof(Downloads), () => nav.SelectedItem = toDownloads }
|
||||
};
|
||||
|
||||
try { navCase[e.SourcePageType](); }
|
||||
catch { }
|
||||
}
|
||||
else if (s == Sender.Menu)
|
||||
s = Sender.None;
|
||||
|
||||
if (content.CanGoBack)
|
||||
nav.IsBackEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user