-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from UnicordDev/feature/notifications-page
Notifications page
- Loading branch information
Showing
16 changed files
with
641 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<Page | ||
x:Class="UniSky.Pages.NotificationsPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UniSky.Pages" | ||
xmlns:extensions="using:UniSky.Extensions" | ||
xmlns:notifications="using:UniSky.ViewModels.Notifications" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:converters="using:UniSky.Converters" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<Page.Resources> | ||
<DataTemplate x:Key="NotificationContentTemplate" | ||
x:DataType="notifications:NotificationViewModel"> | ||
<Grid Margin="12,8" | ||
HorizontalAlignment="Left"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid x:Name="Icons" | ||
Grid.RowSpan="3" | ||
VerticalAlignment="Top" | ||
Margin="0,0,12,0"> | ||
<Viewbox x:Name="RetweetIcon" | ||
x:Load="{x:Bind IsRetweet, Mode=OneWay}" | ||
Width="24" | ||
Height="24"> | ||
<TextBlock Foreground="{ThemeResource RetweetBrush}" | ||
FontFamily="{ThemeResource SymbolThemeFontFamily}"></TextBlock> | ||
</Viewbox> | ||
|
||
<Viewbox x:Name="LikeIcon" | ||
x:Load="{x:Bind IsLike, Mode=OneWay}" | ||
Width="24" | ||
Height="24"> | ||
<TextBlock Foreground="{ThemeResource LikeBrush}" | ||
FontFamily="{ThemeResource SymbolThemeFontFamily}"></TextBlock> | ||
</Viewbox> | ||
|
||
|
||
<Ellipse x:Name="ProfileImage" | ||
x:Load="{x:Bind ShowAvatar, Mode=OneWay}" | ||
Width="24" | ||
Height="24"> | ||
<Ellipse.Fill> | ||
<ImageBrush> | ||
<ImageBrush.ImageSource> | ||
<BitmapImage UriSource="{Binding AvatarUrl}" | ||
DecodePixelWidth="24" | ||
DecodePixelHeight="24" | ||
DecodePixelType="Logical"/> | ||
</ImageBrush.ImageSource> | ||
</ImageBrush> | ||
</Ellipse.Fill> | ||
</Ellipse> | ||
|
||
</Grid> | ||
|
||
<TextBlock x:Name="TitleTextBlock" | ||
Grid.Row="0" | ||
Grid.Column="1" | ||
Style="{ThemeResource BaseTextBlockStyle}" | ||
Text="{x:Bind NotificationTitle, Mode=OneWay}" | ||
TextWrapping="Wrap"/> | ||
|
||
<TextBlock x:Name="CaptionTextBlock" | ||
x:Load="{x:Bind converters:Static.NotNullOrWhiteSpace(NotificationSubtitle), Mode=OneWay}" | ||
Grid.Row="1" | ||
Grid.Column="1" | ||
Style="{ThemeResource CaptionTextBlockStyle}" | ||
Foreground="{ThemeResource ApplicationSecondaryForegroundThemeBrush}" | ||
Text="{x:Bind NotificationSubtitle, Mode=OneWay}" | ||
MaxLines="3"/> | ||
|
||
<controls:ConstrainedBox x:Name="NotificationEmbedContainer" | ||
x:Load="{x:Bind converters:Static.NotNull(NotificationEmbed), Mode=OneWay}" | ||
AspectRatio="3:1" | ||
Margin="0,4" | ||
Grid.Row="2" | ||
Grid.Column="2"> | ||
<ContentControl x:Name="EmbedContent" | ||
ContentTemplateSelector="{StaticResource PostEmbedTemplateSelector}" | ||
Content="{x:Bind NotificationEmbed}"/> | ||
</controls:ConstrainedBox> | ||
|
||
</Grid> | ||
</DataTemplate> | ||
</Page.Resources> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition x:Name="TitleBarPadding" Height="0"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
|
||
<Border Grid.RowSpan="2" | ||
Background="{ThemeResource SystemControlChromeMediumAcrylicElementMediumBrush}" | ||
BorderBrush="{ThemeResource SystemControlRevealSeparatorBrush}" | ||
extensions:Hairline.BorderThickness="0,0,0,1"/> | ||
|
||
<TextBlock Grid.Row="1" | ||
Margin="12,4,12,12" | ||
Text="NOTIFICATIONS" | ||
Style="{ThemeResource BaseTextBlockStyle}"/> | ||
|
||
|
||
<ListView x:Name="RootList" | ||
Grid.Row="2" | ||
Canvas.ZIndex="-1" | ||
ItemsSource="{x:Bind ViewModel.Notifications, Mode=OneWay}" | ||
ItemTemplate="{StaticResource NotificationContentTemplate}" | ||
SelectionMode="None" | ||
IsItemClickEnabled="True" | ||
HorizontalAlignment="Stretch" | ||
HorizontalContentAlignment="Stretch" | ||
ScrollViewer.IsVerticalScrollChainingEnabled="True" | ||
Loaded="RootList_Loaded" | ||
ItemClick="RootList_ItemClick"> | ||
<ListView.Resources> | ||
<SolidColorBrush Color="Transparent" x:Key="ListViewItemRevealBackground"/> | ||
<SolidColorBrush Color="Transparent" x:Key="ListViewItemBackgroundPointerOver"/> | ||
<Thickness x:Key="ListViewItemRevealBorderThemeThickness">0</Thickness> | ||
</ListView.Resources> | ||
<ListView.ItemContainerStyle> | ||
<Style TargetType="ListViewItem"> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> | ||
<Setter Property="Padding" Value="0"/> | ||
</Style> | ||
</ListView.ItemContainerStyle> | ||
</ListView> | ||
|
||
<ProgressBar Grid.Row="3" | ||
VerticalAlignment="Top" | ||
IsIndeterminate="{x:Bind ViewModel.IsLoading, Mode=OneWay}" | ||
Background="Transparent"/> | ||
|
||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Toolkit.Uwp.UI.Extensions; | ||
using UniSky.Services; | ||
using UniSky.ViewModels.Notifications; | ||
using UniSky.ViewModels.Profile; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.Foundation.Metadata; | ||
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; | ||
|
||
namespace UniSky.Pages; | ||
|
||
public sealed partial class NotificationsPage : Page | ||
{ | ||
public NotificationsPageViewModel ViewModel | ||
{ | ||
get { return (NotificationsPageViewModel)GetValue(ViewModelProperty); } | ||
set { SetValue(ViewModelProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty ViewModelProperty = | ||
DependencyProperty.Register("ViewModel", typeof(NotificationsPageViewModel), typeof(NotificationsPage), new PropertyMetadata(null)); | ||
|
||
public NotificationsPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
protected override void OnNavigatedTo(NavigationEventArgs e) | ||
{ | ||
base.OnNavigatedTo(e); | ||
|
||
var safeAreaService = ServiceContainer.Scoped.GetRequiredService<ISafeAreaService>(); | ||
safeAreaService.SafeAreaUpdated += OnSafeAreaUpdated; | ||
|
||
if (this.ViewModel == null) | ||
this.DataContext = this.ViewModel = ActivatorUtilities.CreateInstance<NotificationsPageViewModel>(ServiceContainer.Scoped); | ||
} | ||
|
||
protected override void OnNavigatedFrom(NavigationEventArgs e) | ||
{ | ||
base.OnNavigatedFrom(e); | ||
|
||
var safeAreaService = ServiceContainer.Scoped.GetRequiredService<ISafeAreaService>(); | ||
safeAreaService.SafeAreaUpdated -= OnSafeAreaUpdated; | ||
} | ||
|
||
private void OnSafeAreaUpdated(object sender, SafeAreaUpdatedEventArgs e) | ||
{ | ||
TitleBarPadding.Height = new GridLength(e.SafeArea.Bounds.Top); | ||
} | ||
|
||
private void RootList_ItemClick(object sender, ItemClickEventArgs e) | ||
{ | ||
|
||
} | ||
|
||
private void RootList_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
if (ApiInformation.IsApiContractPresent(typeof(UniversalApiContract).FullName, 7)) | ||
{ | ||
var scrollViewer = RootList.FindDescendant<ScrollViewer>(); | ||
scrollViewer.CanContentRenderOutsideBounds = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.