Skip to content

Commit

Permalink
Merge pull request #18 from UnicordDev/feature/notifications-page
Browse files Browse the repository at this point in the history
Notifications page
  • Loading branch information
WamWooWam authored Dec 7, 2024
2 parents 95627e6 + ab8ff8d commit 950381f
Show file tree
Hide file tree
Showing 16 changed files with 641 additions and 11 deletions.
2 changes: 1 addition & 1 deletion UniSky/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="24101WamWooWamRD.25225E497690B"
Publisher="CN=0F22111D-EDF0-42F0-B58D-26C4C5C5054B"
Version="1.0.153.0" />
Version="1.0.154.0" />

<mp:PhoneIdentity PhoneProductId="d3ae258d-7752-4bdb-bb0c-b6cca57f9cd1" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
147 changes: 147 additions & 0 deletions UniSky/Pages/NotificationsPage.xaml
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}">&#xE8EB;</TextBlock>
</Viewbox>

<Viewbox x:Name="LikeIcon"
x:Load="{x:Bind IsLike, Mode=OneWay}"
Width="24"
Height="24">
<TextBlock Foreground="{ThemeResource LikeBrush}"
FontFamily="{ThemeResource SymbolThemeFontFamily}">&#xEB52;</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>
77 changes: 77 additions & 0 deletions UniSky/Pages/NotificationsPage.xaml.cs
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;
}
}
}
2 changes: 1 addition & 1 deletion UniSky/Pages/SearchPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<AutoSuggestBox x:Name="SearchBox"
Grid.Row="2"
Margin="12,4,12,12"
Margin="12,8,12,12"
PlaceholderText="Find something cool..."
QueryIcon="Find"
Text="{x:Bind ViewModel.SearchQuery, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Expand Down
27 changes: 27 additions & 0 deletions UniSky/Resources/en-GB/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,31 @@
<data name="ProfileFollowing" xml:space="preserve">
<value>Following</value>
</data>
<data name="NotificationLikedTweetSingle" xml:space="preserve">
<value>{0} liked your post</value>
</data>
<data name="NotificationLikedTweetMultiple" xml:space="preserve">
<value>{0} and {1} liked your post</value>
</data>
<data name="NotificationFollow" xml:space="preserve">
<value>{0} followed you</value>
</data>
<data name="NotificationMention" xml:space="preserve">
<value>{0} mentioned you</value>
</data>
<data name="NotificationOther" xml:space="preserve">
<value>other</value>
</data>
<data name="NotificationQuote" xml:space="preserve">
<value>{0} quoted your post</value>
</data>
<data name="NotificationReply" xml:space="preserve">
<value>{0} replied to you</value>
</data>
<data name="NotificationRetweetMultiple" xml:space="preserve">
<value>{0} and {1} reposted</value>
</data>
<data name="NotificationRetweetSingle" xml:space="preserve">
<value>{0} reposted</value>
</data>
</root>
15 changes: 15 additions & 0 deletions UniSky/Resources/en-GB/custom-twitter/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,19 @@
<data name="ComposeSheetTitle.Text" xml:space="preserve">
<value>NEW TWEET</value>
</data>
<data name="NotificationLikedTweetMultiple" xml:space="preserve">
<value>{0} and {1} liked your tweet</value>
</data>
<data name="NotificationLikedTweetSingle" xml:space="preserve">
<value>{0} liked your tweet</value>
</data>
<data name="NotificationRetweetMultiple" xml:space="preserve">
<value>{0} and {1} retweeted</value>
</data>
<data name="NotificationRetweetSingle" xml:space="preserve">
<value>{0} retweeted</value>
</data>
<data name="NotificationQuote" xml:space="preserve">
<value>{0} quoted your tweet</value>
</data>
</root>
20 changes: 15 additions & 5 deletions UniSky/UniSky.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@
<Compile Include="Helpers\StringExtensions.cs" />
<Compile Include="Helpers\UIElementExtensions.cs" />
<Compile Include="Helpers\UrlHelpers.cs" />
<Compile Include="Pages\NotificationsPage.xaml.cs">
<DependentUpon>NotificationsPage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\ProfilePage.xaml.cs">
<DependentUpon>ProfilePage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -250,14 +253,17 @@
<Compile Include="ViewModels\Compose\ComposeViewAttachmentViewModel.cs" />
<Compile Include="ViewModels\Compose\ComposeViewModel.cs" />
<Compile Include="ViewModels\Error\ExceptionViewModel.cs" />
<Compile Include="ViewModels\Post\PostEmbedVideoViewModel.cs" />
<Compile Include="ViewModels\Notifications\NotificationsCollection.cs" />
<Compile Include="ViewModels\Notifications\NotificationsPageViewModel.cs" />
<Compile Include="ViewModels\Notifications\NotificationViewModel.cs" />
<Compile Include="ViewModels\Posts\PostEmbedVideoViewModel.cs" />
<Compile Include="ViewModels\Profile\ProfileFeedViewModel.cs" />
<Compile Include="ViewModels\Profile\ProfilePageViewModel.cs" />
<Compile Include="ViewModels\Profile\ProfileViewModel.cs" />
<Compile Include="ViewModels\Post\PostEmbedImagesViewModel.cs" />
<Compile Include="ViewModels\Post\PostEmbedImageViewModel.cs" />
<Compile Include="ViewModels\Post\PostEmbedViewModel.cs" />
<Compile Include="ViewModels\Post\PostViewModel.cs" />
<Compile Include="ViewModels\Posts\PostEmbedImagesViewModel.cs" />
<Compile Include="ViewModels\Posts\PostEmbedImageViewModel.cs" />
<Compile Include="ViewModels\Posts\PostEmbedViewModel.cs" />
<Compile Include="ViewModels\Posts\PostViewModel.cs" />
<Compile Include="ViewModels\Search\SearchFeedViewModel.cs" />
<Compile Include="ViewModels\Search\SearchPageViewModel.cs" />
<Compile Include="ViewModels\Search\SearchPostsCollection.cs" />
Expand Down Expand Up @@ -441,6 +447,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\NotificationsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\ProfilePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
2 changes: 2 additions & 0 deletions UniSky/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ private void NavigateToPage()
this.homeNavigationService.Navigate<SearchPage>();
break;
case HomePages.Notifications:
this.homeNavigationService.Navigate<NotificationsPage>();
break;
case HomePages.Chat:
this.homeNavigationService.Navigate<Page>();
break;
Expand Down
Loading

0 comments on commit 950381f

Please sign in to comment.