Archived
1
0

Notification center has been cut off

This commit is contained in:
Michael Gordeev
2018-10-22 21:24:26 +03:00
parent fb3b88a046
commit 4cb9bdd8cb
5 changed files with 39 additions and 205 deletions
-23
View File
@@ -1,23 +0,0 @@
<UserControl
x:Class="FoxTube.NotificationsCenter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="400"
d:DesignWidth="300">
<StackPanel Background="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}" Width="300" Margin="-10" MinHeight="400">
<Grid Height="50">
<TextBlock Text="Notifications" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
<Button Visibility="Collapsed" Background="Transparent" Foreground="Gray" FontFamily="Segoe MDL2 Assets" Content="&#xE74D;" Height="50" Width="50" HorizontalAlignment="Right" ToolTipService.ToolTip="Clear all" Name="clear" Click="clear_Click"/>
</Grid>
<TextBlock Text="You have no any notification" Name="noNotifications" Foreground="Gray" FontStyle="Italic" Padding="10" Visibility="Visible"/>
<ScrollViewer>
<StackPanel Name="array"/>
</ScrollViewer>
</StackPanel>
</UserControl>
@@ -1,93 +0,0 @@
using FoxTube.Background;
using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Xml;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace FoxTube
{
public sealed partial class NotificationsCenter : UserControl
{
List<Notification> notifications = new List<Notification>();
private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
XmlDocument doc = new XmlDocument();
public NotificationsCenter()
{
this.InitializeComponent();
}
public void Initialize()
{
try
{
doc.LoadXml(settings.Values["notificationsHistory"] as string);
foreach (XmlElement n in doc["history"].ChildNodes)
AddNotification(new Notification(n.ToString()));
}
catch { }
BackgroundProcessor.NotificationRecieved += NewNotification;
}
private void NewNotification(object sender, Notification item)
{
AddNotification(item);
}
private void clear_Click(object sender, RoutedEventArgs e)
{
array.Children.Clear();
notifications.Clear();
doc["history"].InnerXml = "";
settings.Values["notificationsHistory"] = doc.InnerXml;
clear.Visibility = Visibility.Collapsed;
noNotifications.Visibility = Visibility.Visible;
}
public void AddNotification(Notification notification)
{
notifications.Add(notification);
Methods.MainPage.GotNotification();
noNotifications.Visibility = Visibility.Collapsed;
clear.Visibility = Visibility.Visible;
Button item = notification.GetNotification();
item.Click += Notification_Click;
array.Children.Add(item);
}
private void Notification_Click(object sender, RoutedEventArgs e)
{
Notification n = notifications[array.Children.IndexOf(sender as Button)];
switch(n.Type)
{
case NotificationType.Changelog:
case NotificationType.Internal:
Methods.MainPage.GoToDeveloper(n.Id);
break;
case NotificationType.Video:
Methods.MainPage.GoToVideo(n.Id);
break;
}
}
}
}
-7
View File
@@ -153,9 +153,6 @@
<Compile Include="Pages\MainPage.xaml.cs"> <Compile Include="Pages\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon> <DependentUpon>MainPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\NotificationsCenter.xaml.cs">
<DependentUpon>NotificationsCenter.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\PlaylistCardWide.xaml.cs"> <Compile Include="Controls\PlaylistCardWide.xaml.cs">
<DependentUpon>PlaylistCardWide.xaml</DependentUpon> <DependentUpon>PlaylistCardWide.xaml</DependentUpon>
</Compile> </Compile>
@@ -348,10 +345,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Controls\NotificationsCenter.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\PlaylistCardWide.xaml"> <Page Include="Controls\PlaylistCardWide.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
+28 -59
View File
@@ -14,24 +14,7 @@
PreviewKeyUp="Page_PreviewKeyUp"> PreviewKeyUp="Page_PreviewKeyUp">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups> <NavigationView Header="Home" SelectedItem="toHome" Windows10version1803:BackRequested="nav_BackRequested" Windows10version1803:PaneTitle="FoxTube" OpenPaneLength="300" Name="nav" SelectionChanged="nav_SelectionChanged">
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="641"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="header.FontSize" Value="28"/>
<Setter Target="headerGrid.Margin" Value="10,25,0,0"/>
<Setter Target="account.Height" Value="50"/>
<Setter Target="notificationMenu.Height" Value="50"/>
<Setter Target="avatar.Height" Value="50"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<NavigationView SelectedItem="toHome" Windows10version1803:BackRequested="nav_BackRequested" Windows10version1803:PaneTitle="FoxTube" OpenPaneLength="300" Name="nav" SelectionChanged="nav_SelectionChanged">
<NavigationView.MenuItems> <NavigationView.MenuItems>
<NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/> <NavigationViewItem x:Uid="/Main/home" Icon="Home" Content="Home" Name="toHome"/>
@@ -63,6 +46,33 @@
<TextBlock x:Uid="/Main/adsFree" Text="Remove ads"/> <TextBlock x:Uid="/Main/adsFree" Text="Remove ads"/>
</StackPanel> </StackPanel>
</Button> </Button>
<Button Visibility="Visible" Name="account" Height="40" HorizontalAlignment="Stretch" Background="Transparent" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<FontIcon Glyph="&#xE8FA;" FontSize="16" Margin="6,0,16,0"/>
<TextBlock x:Uid="/Main/signIn" Text="Add account"/>
</StackPanel>
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/signEx" Text="Sign in with existing account" Name="signIn" Click="signIn_Click"/>
<MenuFlyoutItem x:Uid="/Main/signNew" Text="Create new Google account" Name="createAccount" Click="createAccount_Click"/>
</MenuFlyout>
</Button.Flyout>
</Button>
<Button Visibility="Collapsed" Name="avatar" Height="40" HorizontalAlignment="Stretch" Background="Transparent" HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<PersonPicture Height="23" Margin="3,0,12,0"/>
<TextBlock Name="myName" Text="My account"/>
</StackPanel>
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/myChannelContext" Text="My channel" Name="myChannel" Click="myChannel_Click"/>
<MenuFlyoutSeparator/>
<MenuFlyoutItem x:Uid="/Main/signOut" Text="Log out" Name="logout" Click="logout_Click"/>
</MenuFlyout>
</Button.Flyout>
</Button>
</StackPanel> </StackPanel>
</NavigationView.PaneFooter> </NavigationView.PaneFooter>
@@ -70,47 +80,6 @@
<AutoSuggestBox x:Name="search" QueryIcon="Find" QuerySubmitted="search_QuerySubmitted" TextChanged="search_TextChanged" x:Uid="/Main/searchPlaceholder" PlaceholderText="Search"/> <AutoSuggestBox x:Name="search" QueryIcon="Find" QuerySubmitted="search_QuerySubmitted" TextChanged="search_TextChanged" x:Uid="/Main/searchPlaceholder" PlaceholderText="Search"/>
</NavigationView.AutoSuggestBox> </NavigationView.AutoSuggestBox>
<NavigationView.Header>
<Grid Name="headerGrid" Margin="0,-10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock FontSize="24" VerticalAlignment="Center" Text="Home" Name="header"/>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Name="notificationMenu" Click="notificationMenu_Click"
FontFamily="Segoe MDL2 Assets" Content="&#xED0D;"
Width="50" Height="42" Background="Transparent" x:Uid="notifications" ToolTipService.ToolTip="Notifications">
<Button.Flyout>
<Flyout Content="{x:Bind notificationsCenter}"/>
</Button.Flyout>
</Button>
<Button Name="account"
FontFamily="Segoe MDL2 Assets" Content="&#xE8FA;"
Width="50" Height="42" Background="Transparent" x:Uid="signIn" ToolTipService.ToolTip="Sign in">
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/signEx" Text="Sign in with existing account" Name="signIn" Click="signIn_Click"/>
<MenuFlyoutItem x:Uid="/Main/signNew" Text="Create new Google account" Name="createAccount" Click="createAccount_Click"/>
</MenuFlyout>
</Button.Flyout>
</Button>
<Button Width="50" Background="Transparent" Height="42" Visibility="Collapsed" Name="avatar">
<PersonPicture Width="30" ToolTipService.ToolTip="My account" x:Uid="myAccount"/>
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem x:Uid="/Main/myChannelContext" Text="My channel" Name="myChannel" Click="myChannel_Click"/>
<MenuFlyoutSeparator/>
<MenuFlyoutItem x:Uid="/Main/signOut" Text="Log out" Name="logout" Click="logout_Click"/>
</MenuFlyout>
</Button.Flyout>
</Button>
</StackPanel>
</Grid>
</NavigationView.Header>
<Grid> <Grid>
<Frame Name="content" Navigated="content_Navigated"/> <Frame Name="content" Navigated="content_Navigated"/>
<Frame Name="videoPlaceholder"/> <Frame Name="videoPlaceholder"/>
+10 -22
View File
@@ -41,7 +41,6 @@ namespace FoxTube
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
NotificationsCenter notificationsCenter = new NotificationsCenter();
Sender s = Sender.None; Sender s = Sender.None;
public MainPage() public MainPage()
{ {
@@ -111,7 +110,6 @@ namespace FoxTube
} }
catch { } catch { }
} }
notificationsCenter.Initialize();
SecretsVault.AuthorizationStateChanged += Vault_AuthorizationStateChanged; SecretsVault.AuthorizationStateChanged += Vault_AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged; SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
@@ -191,8 +189,8 @@ namespace FoxTube
{ {
Userinfoplus info = await new Oauth2Service(SecretsVault.Initializer).Userinfo.Get().ExecuteAsync(); Userinfoplus info = await new Oauth2Service(SecretsVault.Initializer).Userinfo.Get().ExecuteAsync();
ToolTipService.SetToolTip(avatar, new ToolTip() { Content = info.Name }); myName.Text = info.Name;
(avatar.Content as PersonPicture).ProfilePicture = new BitmapImage(new Uri(info.Picture)); ((avatar.Content as StackPanel).Children[0] as PersonPicture).ProfilePicture = new BitmapImage(new Uri(info.Picture));
} }
catch { } catch { }
avatar.Visibility = Visibility.Visible; avatar.Visibility = Visibility.Visible;
@@ -256,16 +254,6 @@ namespace FoxTube
GoToVideo((videoPlaceholder.Content as VideoPage).videoId); GoToVideo((videoPlaceholder.Content as VideoPage).videoId);
} }
public void GotNotification()
{
notificationMenu.Content = "\xED0C";
}
public void notificationMenu_Click(object sender, RoutedEventArgs e)
{
notificationMenu.Content = "\xED0D";
}
private async void feedback_Click(object sender, RoutedEventArgs e) private async void feedback_Click(object sender, RoutedEventArgs e)
{ {
await Launcher.LaunchUriAsync(new Uri("feedback-hub:")); await Launcher.LaunchUriAsync(new Uri("feedback-hub:"));
@@ -502,14 +490,14 @@ namespace FoxTube
{ {
Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>() Dictionary<Type, Action> switchCase = new Dictionary<Type, Action>()
{ {
{ typeof(Settings), () => header.Text = "Settings" }, { typeof(Settings), () => nav.Header = "Settings" },
{ typeof(ChannelPage), () => header.Text = "Channel" }, { typeof(ChannelPage), () => nav.Header = "Channel" },
{ typeof(PlaylistPage), () => header.Text = "Playlist" }, { typeof(PlaylistPage), () => nav.Header = "Playlist" },
{ typeof(Search), () => header.Text = "Search" }, { typeof(Search), () => nav.Header = "Search" },
{ typeof(Subscriptions), () => header.Text = "Subscriptions" }, { typeof(Subscriptions), () => nav.Header = "Subscriptions" },
{ typeof(History), () => header.Text = "History" }, { typeof(History), () => nav.Header = "History" },
{ typeof(Home), () => header.Text = "Home" }, { typeof(Home), () => nav.Header = "Home" },
{ typeof(Downloads), () => header.Text = "Downloads" } { typeof(Downloads), () => nav.Header = "Downloads" }
}; };
try { switchCase[e.SourcePageType](); } try { switchCase[e.SourcePageType](); }