Archived
1
0

Navigation improvements

This commit is contained in:
Michael Gordeev
2018-08-12 13:52:57 +03:00
parent 05415e44c7
commit 8e454c3375
+55 -18
View File
@@ -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,27 +392,33 @@ namespace FoxTube
private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) private void nav_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{ {
if (args.IsSettingsSelected) if (s == Sender.None)
content.Navigate(typeof(Settings));
else
{ {
if (args.SelectedItem == toHome) s = Sender.Menu;
content.Navigate(typeof(Home)); if (args.IsSettingsSelected)
else if (args.SelectedItem == toHistory)
content.Navigate(typeof(Settings)); 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 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) 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;