corp-app/CORP-MAUI/Pages/PostsPage.xaml

273 lines
13 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:CORP_MAUI.ViewModels"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="CORP_MAUI.Pages.PostsPage"
Title="Лента новостей"
BackgroundColor="White">
<Grid RowDefinitions="Auto,Auto,*">
<!-- Шапка с аватаром и заголовком -->
<Grid
Grid.Row="0"
ColumnDefinitions="50,*,50"
Padding="15,10"
BackgroundColor="#E5E5E5">
<!-- Аватар пользователя -->
<Border
Grid.Column="0"
WidthRequest="40"
HeightRequest="40"
StrokeShape="RoundRectangle 20"
BackgroundColor="{StaticResource Gray300}"
Stroke="Transparent"
HorizontalOptions="Start">
<Image
x:Name="UserAvatarImage"
Aspect="AspectFill"/>
</Border>
<!-- Заголовок -->
<Label
Grid.Column="1"
Text="Лента новостей"
FontSize="18"
FontAttributes="Bold"
TextColor="{StaticResource Gray900}"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<!-- Иконка уведомлений -->
<Border
Grid.Column="2"
WidthRequest="40"
HeightRequest="40"
StrokeShape="RoundRectangle 20"
BackgroundColor="Transparent"
Stroke="Transparent"
HorizontalOptions="End">
<Image
Source="notifications.png"
WidthRequest="28"
HeightRequest="28"
HorizontalOptions="Center"
VerticalOptions="Center">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</Image.Behaviors>
</Image>
</Border>
</Grid>
<!-- Поиск с серым фоном -->
<Grid
Grid.Row="1"
ColumnDefinitions="Auto,*"
Padding="15,5,15,15"
BackgroundColor="White">
<!-- Круглая кнопка поиска -->
<Border
Grid.Column="0"
WidthRequest="45"
HeightRequest="45"
StrokeShape="RoundRectangle 22.5"
BackgroundColor="{StaticResource Primary}"
Stroke="Transparent"
Margin="0,0,10,0">
<Image
Source="search.png"
WidthRequest="24"
HeightRequest="24"
HorizontalOptions="Center"
VerticalOptions="Center">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="White"/>
</Image.Behaviors>
</Image>
</Border>
<!-- Поле поиска с серым фоном -->
<Border
Grid.Column="1"
StrokeShape="RoundRectangle 22.5"
BackgroundColor="{StaticResource Gray300}"
Stroke="Transparent"
HeightRequest="45"
Padding="15,0">
<Entry
x:Name="SearchEntry"
Placeholder="Поиск по названию, авто...."
PlaceholderColor="{StaticResource Gray500}"
TextColor="{StaticResource Gray900}"
BackgroundColor="Transparent"
VerticalOptions="Center"
TextChanged="OnSearchTextChanged"/>
</Border>
</Grid>
<!-- Список постов -->
<RefreshView
Grid.Row="2"
x:Name="PostsRefreshView"
IsRefreshing="False"
Refreshing="OnRefreshing">
<CollectionView
x:Name="PostsCollectionView"
SelectionMode="Single"
SelectionChanged="OnPostSelected"
BackgroundColor="Transparent">
<CollectionView.EmptyView>
<VerticalStackLayout Style="{StaticResource EmptyStateContainer}">
<Label Text="📰" Style="{StaticResource EmptyStateIcon}"/>
<Label
Text="Нет новостей"
Style="{StaticResource EmptyStateTitle}"
Margin="0,10,0,0"/>
<Label
Text="Здесь будут отображаться новости компании"
Style="{StaticResource EmptyStateText}"/>
</VerticalStackLayout>
</CollectionView.EmptyView>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="models:PostViewModel">
<Border
Style="{StaticResource CardBorder}"
Margin="10,8"
Padding="0"
StrokeShape="RoundRectangle 15">
<VerticalStackLayout Spacing="0">
<!-- Заголовок с аватаром автора -->
<Grid
ColumnDefinitions="50,*"
Padding="15"
BackgroundColor="White">
<!-- Аватар автора -->
<Border
Grid.Column="0"
Style="{StaticResource AvatarSmall}"
WidthRequest="45"
HeightRequest="45"
StrokeShape="RoundRectangle 22.5">
<Image
Source="{Binding Post.Author.DisplayAvatarSource}"
Aspect="AspectFill"/>
</Border>
<!-- Имя автора и дата -->
<VerticalStackLayout
Grid.Column="1"
VerticalOptions="Center"
Spacing="2"
Margin="10,0,0,0">
<Label
Text="{Binding Post.Author.FullName}"
Style="{StaticResource CardSubtitle}"
FontSize="15"/>
<Label
Text="{Binding Post.DisplayDate, StringFormat='{0:dd.MM.yyyy HH:mm}'}"
Style="{StaticResource CardMeta}"/>
</VerticalStackLayout>
</Grid>
<!-- Изображение поста -->
<Image
Aspect="AspectFill"
MinimumHeightRequest="300"
BackgroundColor="{StaticResource Gray200}"
Source="{Binding DisplayImageSource}"
IsVisible="{Binding IsImageVisible}"/>
<!-- Контент поста -->
<VerticalStackLayout
Padding="15"
Spacing="8"
BackgroundColor="White">
<!-- Заголовок -->
<Label
Text="{Binding Post.Title}"
Style="{StaticResource CardTitle}"
FontSize="16"
LineBreakMode="TailTruncation"
MaxLines="2"/>
<!-- Превью текста -->
<Label
Text="{Binding PreviewContent}"
Style="{StaticResource CardText}"
LineBreakMode="TailTruncation"
MaxLines="3"/>
<!-- Футер с лайками и комментариями -->
<HorizontalStackLayout
Spacing="20"
Margin="0,8,0,0">
<!-- Лайки -->
<HorizontalStackLayout Spacing="5">
<Image
Source="like.png"
WidthRequest="18"
HeightRequest="18"
VerticalOptions="Center">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</Image.Behaviors>
</Image>
<Label
Text="{Binding Post.LikesCount}"
Style="{StaticResource CardMeta}"
VerticalOptions="Center"/>
</HorizontalStackLayout>
<!-- Комментарии -->
<HorizontalStackLayout Spacing="5">
<Image
Source="messages.png"
WidthRequest="18"
HeightRequest="18"
VerticalOptions="Center">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</Image.Behaviors>
</Image>
<Label
Text="{Binding Post.CommentsCount}"
Style="{StaticResource CardMeta}"
VerticalOptions="Center"/>
</HorizontalStackLayout>
</HorizontalStackLayout>
</VerticalStackLayout>
</VerticalStackLayout>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
<!-- Индикатор загрузки -->
<ActivityIndicator
Grid.Row="2"
x:Name="LoadingIndicator"
IsRunning="False"
IsVisible="False"
Color="{StaticResource Primary}"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</Grid>
</ContentPage>