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.
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
|
public enum Sender { Menu, Frame, None }
|
||||||
|
|
||||||
public sealed partial class MainPage : Page
|
public sealed partial class MainPage : Page
|
||||||
{
|
{
|
||||||
public DownloadAgent Agent = new DownloadAgent();
|
public DownloadAgent Agent = new DownloadAgent();
|
||||||
@@ -55,6 +57,7 @@ namespace FoxTube
|
|||||||
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
|
||||||
|
|
||||||
NotificationsCenter notificationsCenter = new NotificationsCenter();
|
NotificationsCenter notificationsCenter = new NotificationsCenter();
|
||||||
|
Sender s = Sender.None;
|
||||||
public MainPage()
|
public MainPage()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
@@ -389,6 +392,9 @@ namespace FoxTube
|
|||||||
|
|
||||||
private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
||||||
{
|
{
|
||||||
|
if (s == Sender.None)
|
||||||
|
{
|
||||||
|
s = Sender.Menu;
|
||||||
if (args.IsSettingsSelected)
|
if (args.IsSettingsSelected)
|
||||||
content.Navigate(typeof(Settings));
|
content.Navigate(typeof(Settings));
|
||||||
else
|
else
|
||||||
@@ -411,6 +417,9 @@ namespace FoxTube
|
|||||||
content.Navigate(typeof(ChannelPage), SecretsVault.Subscriptions[Convert.ToInt32((args.SelectedItem as NavigationViewItem).Name)].Snippet.ResourceId.ChannelId);
|
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)
|
private void content_Navigated(object sender, NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -425,7 +434,35 @@ namespace FoxTube
|
|||||||
{ typeof(Downloads), () => header.Text = "Downloads" }
|
{ 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)
|
if (content.CanGoBack)
|
||||||
nav.IsBackEnabled = true;
|
nav.IsBackEnabled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user