Archived
1
0

Added navigation logic

This commit is contained in:
Michael Gordeev
2019-12-03 18:44:29 +03:00
parent c11d1e3dcf
commit 6293037ae5
11 changed files with 165 additions and 34 deletions
+1
View File
@@ -142,6 +142,7 @@
<Compile Include="Models\Inbox\InboxItem.cs" />
<Compile Include="Models\IRefreshable.cs" />
<Compile Include="Models\Notifications.cs" />
<Compile Include="Models\PageView.cs" />
<Compile Include="Models\SearchSuggestion.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\FoxTube.Core.rd.xml" />
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FoxTube.Core.Models
namespace FoxTube.Core.Models
{
public interface IRefreshable
{
+17
View File
@@ -0,0 +1,17 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace FoxTube.Core.Models
{
public class PageView : Page
{
public string Header { get; set; }
public object Parameter { get; private set; }
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Parameter = e.Parameter;
}
}
}
+49 -8
View File
@@ -30,7 +30,9 @@
IsTitleBarAutoPaddingEnabled="False"
DisplayModeChanged="NavigationView_DisplayModeChanged"
PaneClosing="NavigationView_PaneClosing"
PaneOpening="NavigationView_PaneOpening">
PaneOpening="NavigationView_PaneOpening"
BackRequested="NavigationViewControl_BackRequested"
ItemInvoked="NavigationViewControl_ItemInvoked">
<ui:NavigationView.AutoSuggestBox>
<AutoSuggestBox QueryIcon="Find" PlaceholderText="Search YouTube..." TextChanged="AutoSuggestBox_TextChanged" QuerySubmitted="AutoSuggestBox_QuerySubmitted" TextMemberPath="Text">
@@ -58,8 +60,8 @@
</ui:NavigationView.PaneFooter>
<ui:NavigationView.MenuItems>
<ui:NavigationViewItem Icon="Home" Content="Home"/>
<ui:NavigationViewItem Content="Subscriptions">
<ui:NavigationViewItem Icon="Home" Content="Home" Name="home"/>
<ui:NavigationViewItem Content="Subscriptions" Name="subscriptions">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE125;"/>
</ui:NavigationViewItem.Icon>
@@ -67,20 +69,59 @@
<ui:NavigationViewItemHeader Content="Library"/>
<ui:NavigationViewItem Content="History">
<ui:NavigationViewItem Content="History" Name="history">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE81C;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="Liked videos">
<ui:NavigationViewItem Content="Liked videos" Name="liked">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE19F;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Icon="Clock" Content="Watch later"/>
<ui:NavigationViewItem Icon="Download" Content="Downloads"/>
<ui:NavigationViewItem Icon="Clock" Content="Watch later" Name="wl"/>
<ui:NavigationViewItem Icon="Download" Content="Downloads" Name="download"/>
<ui:NavigationViewItemHeader Content="Subscriptions"/>
<ui:NavigationViewItemHeader Content="Best of YouTube"/>
<ui:NavigationViewItem Content="Music" Name="music">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE189;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="Sports" Name="sports">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE95E;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="Movies" Name="movies">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE8B2;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="News" Name="news">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE12A;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="Live" Name="live">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xE93E;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="Spotlight" Name="spotlight">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xECAD;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="360&#xB0; video" Name="vr">
<ui:NavigationViewItem.Icon>
<FontIcon Glyph="&#xF131;"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
</ui:NavigationView.MenuItems>
<Grid>
@@ -89,7 +130,7 @@
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Margin="0,40,0,0" Padding="13,0" x:Name="headerGrid">
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Home" VerticalAlignment="Center"/>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Home" VerticalAlignment="Center" Name="title"/>
<CommandBar HorizontalAlignment="Right" Background="Transparent" DefaultLabelPosition="Right">
<AppBarButton x:Name="LeaveFeedback" Click="LeaveFeedback_Click">
<AppBarButton.Icon>
+77 -7
View File
@@ -1,8 +1,8 @@
using FoxTube.Core.Helpers;
using FoxTube.Core.Models;
using FoxTube.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.ApplicationModel.Core;
using Windows.Foundation.Metadata;
using Windows.UI;
@@ -27,8 +27,7 @@ namespace FoxTube
else if (Settings.Theme == 1)
RequestedTheme = ElementTheme.Dark;
// TODO: Remove this
content.Navigate(typeof(Views.Settings));
Navigate(typeof(Views.Home));
Window.Current.SetTitleBar(AppTitleBar);
@@ -108,7 +107,7 @@ namespace FoxTube
bool success = await StoreInterop.PurchaseApp();
if (success)
{
MessageDialog dialog = new MessageDialog("Thanks for purchasing full version of the app (^∇^) In order to complete changes we need to reopen it. But you can do it later (some elements may be broken)", "Thank you for your purchase!");
MessageDialog dialog = new MessageDialog("Thanks for purchasing full version of the app (^∇^) In order to complete changes we need to reopen it. Or you can do it later (but some elements may be broken)", "Thank you for your purchase!");
dialog.Commands.Add(new UICommand("Restart", (command) => Utils.RestartApp()));
dialog.Commands.Add(new UICommand("Later"));
dialog.CancelCommandIndex = 1;
@@ -117,13 +116,35 @@ namespace FoxTube
}
}
public static void Navigate(Type pageType)
{
public static void Navigate(Type pageType) =>
Navigate(pageType, null);
public static void Navigate(Type pageType, object param)
{
if (pageType == Current.content.CurrentSourcePageType && param == (Current.content.Content as PageView).Parameter)
return;
// TODO: Add navigation logic for videos
Current.content.Navigate(pageType, param);
}
void Content_Navigated(object sender, NavigationEventArgs e) =>
void Content_Navigated(object sender, NavigationEventArgs e)
{
refresh.Visibility = (e.Content is IRefreshable) ? Visibility.Visible : Visibility.Collapsed;
NavigationViewControl.IsBackEnabled = content.CanGoBack;
title.Text = (e.Content as PageView).Header ?? "FoxTube";
switch(e.SourcePageType.Name)
{
case "Home":
NavigationViewControl.SelectedItem = home;
break;
case "Settings":
NavigationViewControl.SelectedItem = NavigationViewControl.SettingsItem;
break;
default:
NavigationViewControl.SelectedItem = null;
break;
}
}
void Refresh_Click(object sender, RoutedEventArgs e)
{
@@ -138,6 +159,9 @@ namespace FoxTube
if (sender.Text.Length < 3 || args.Reason != AutoSuggestionBoxTextChangeReason.UserInput)
return;
// TODO: Load suggestions
// TODO: Remove
sender.ItemsSource = new List<SearchSuggestion>
{
new SearchSuggestion("Suggestion 0"),
@@ -153,7 +177,53 @@ namespace FoxTube
void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
// TODO: Go to search
}
void NavigationViewControl_BackRequested(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewBackRequestedEventArgs args)
{
// TODO: Add backward navigation logic for videos
if (content.CanGoBack)
content.GoBack();
}
void NavigationViewControl_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
if (args.IsSettingsInvoked)
Navigate(typeof(Views.Settings));
else
switch((args.InvokedItemContainer as Microsoft.UI.Xaml.Controls.NavigationViewItem).Name)
{
case "home":
Navigate(typeof(Views.Home));
break;
case "subscriptions":
break;
case "history":
break;
case "liked":
break;
case "wl":
break;
case "download":
break;
case "music":
break;
case "sports":
break;
case "movies":
break;
case "news":
break;
case "live":
break;
case "spotlight":
break;
case "vr":
break;
default:
break;
}
}
}
}
+5 -3
View File
@@ -1,4 +1,5 @@
<Page
<models:PageView
xmlns:models="using:FoxTube.Core.Models"
NavigationCacheMode="Enabled"
x:Class="FoxTube.Views.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@@ -7,7 +8,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:controls="using:FoxTube.Controls"
mc:Ignorable="d">
mc:Ignorable="d"
Header="Home">
<Pivot>
<PivotItem Header="Recommended">
@@ -56,4 +58,4 @@
</Grid>
</PivotItem>
</Pivot>
</Page>
</models:PageView>
+1 -2
View File
@@ -1,6 +1,5 @@
using FoxTube.Controls.Cards;
using FoxTube.Core.Models;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -10,7 +9,7 @@ namespace FoxTube.Views
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Home : Page, IRefreshable
public sealed partial class Home : PageView, IRefreshable
{
public Home() =>
InitializeComponent();
+5 -3
View File
@@ -1,11 +1,13 @@
<Page
<models:PageView
xmlns:models="using:FoxTube.Core.Models"
x:Class="FoxTube.Views.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:settingssections="using:FoxTube.Views.SettingsSections"
mc:Ignorable="d">
mc:Ignorable="d"
Header="Settings">
<Page.Resources>
<Style TargetType="ScrollViewer">
@@ -35,4 +37,4 @@
</ScrollViewer>
</PivotItem>
</Pivot>
</Page>
</models:PageView>
+2 -2
View File
@@ -1,4 +1,4 @@
using Windows.UI.Xaml.Controls;
using FoxTube.Core.Models;
using Windows.UI.Xaml.Navigation;
namespace FoxTube.Views
@@ -6,7 +6,7 @@ namespace FoxTube.Views
/// <summary>
/// Settings page
/// </summary>
public sealed partial class Settings : Page
public sealed partial class Settings : PageView
{
public Settings() =>
InitializeComponent();
+2 -2
View File
@@ -16,7 +16,7 @@
</Style>
</Page.Resources>
<controls:MasterDetailsView Background="Transparent" MasterPaneWidth="400" CompactModeThresholdWidth="850" x:Name="masterDetailsView" BackButtonBehavior="Manual">
<controls:MasterDetailsView Background="Transparent" MasterPaneWidth="400" CompactModeThresholdWidth="850" x:Name="masterDetailsView" BackButtonBehavior="Inline">
<controls:MasterDetailsView.MasterHeader>
<StackPanel>
<ProgressBar IsIndeterminate="True" x:Name="progressBar"/>
@@ -79,7 +79,7 @@
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" FontStyle="Italic" Text="{Binding Type}"/>
</StackPanel>
<controls:MarkdownTextBlock RelativePanel.Below="avatar" Text="{Binding Content}"/>
<controls:MarkdownTextBlock Background="Transparent" RelativePanel.Below="avatar" Text="{Binding Content}"/>
</RelativePanel>
</ScrollViewer>
</DataTemplate>
@@ -1,5 +1,6 @@
using FoxTube.Core.Models;
using FoxTube.Core.Models.Inbox;
using System;
using System.Collections.Generic;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -21,6 +22,10 @@ namespace FoxTube.Views.SettingsSections
{
items = await Core.Helpers.Inbox.GetInbox();
// TODO: Remove
items.Add(new Changelog("1.0", "Changelog content", "Changelog description", DateTime.Now));
items.Add(new DeveloperMessage("id", "Message title", "Message content", DateTime.Now, ""));
filter.SelectedIndex = 0;
progressBar.Visibility = Visibility.Collapsed;