Skip to content

Commit

Permalink
调整评论热门回复样式,提高评论控件紧凑模式触发宽度
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Mar 27, 2024
1 parent bb52467 commit a2954dd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
</Compile>
<Compile Include="Extensions\QrCodeExtensions.cs" />
<Compile Include="Models\Common\Anime\ISeasonItem.cs" />
<Compile Include="Models\Common\Comment\HotReply.cs" />
<Compile Include="Models\Common\Danmaku\BiliDanmakuItem.cs" />
<Compile Include="Models\Common\Dynamic\DynamicUgcSeasonCardModel.cs" />
<Compile Include="Models\Common\Home\DefaultHomeNavItems.cs" />
Expand Down
29 changes: 11 additions & 18 deletions src/BiliLite.UWP/Controls/CommentControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,18 @@
<Run Text="{x:Bind Path=ReplyControl.Location}"></Run>
</TextBlock>

<StackPanel Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2" Visibility="{Binding ElementName=CommentControlContent,Path=DataContext.IsNarrowMode,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel Grid.Column="0"
Grid.ColumnSpan="3"
Grid.Row="2"
Margin="3 0 0 0"
Visibility="{Binding ElementName=CommentControlContent,Path=DataContext.IsNarrowMode,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}">
<ContentPresenter Content="{x:Bind Mode=OneWay}" ContentTemplate="{StaticResource CommentContentTemplate}"></ContentPresenter>
</StackPanel>

<StackPanel Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Visibility="{Binding ElementName=CommentControlContent,Path=DataContext.IsWideMode,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="2"
Visibility="{Binding ElementName=CommentControlContent,Path=DataContext.IsWideMode,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}">
<ContentPresenter Content="{x:Bind Mode=OneWay}" ContentTemplate="{StaticResource CommentContentTemplate}"></ContentPresenter>
</StackPanel>
</Grid>
Expand Down Expand Up @@ -398,7 +405,7 @@
<ListView
Grid.Row="6"
Visibility="{x:Bind ShowHotReplies,Mode=OneWay}"
ItemsSource="{x:Bind HotReplies,Mode=OneWay}"
ItemsSource="{x:Bind HotReplyContents,Mode=OneWay}"
ItemContainerStyle="{StaticResource hotReplyStyle}"
Background="{ThemeResource CardColor}"
SelectionMode="None"
Expand All @@ -408,22 +415,8 @@
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
FontSize="11"
Margin="0 0 8 0"
VerticalAlignment="Top">
<Run
Text="{Binding Path=Member.Uname}" ></Run>
<Run>:</Run>
</TextBlock>
<ContentControl
Grid.Column="1"
FontSize="11" Content="{Binding Path=CommentText,Mode=OneWay}" Visibility="Visible">
FontSize="12" Content="{Binding Path=Content,Mode=OneWay}" Visibility="Visible">
</ContentControl>
</Grid>
</DataTemplate>
Expand Down
7 changes: 6 additions & 1 deletion src/BiliLite.UWP/Extensions/MapperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ public static IServiceCollection AddMapper(this IServiceCollection services)
{
expression.CreateMap<DownloadItem, DownloadItemViewModel>();
expression.CreateMap<DownloadEpisodeItem, DownloadEpisodeItemViewModel>();
expression.CreateMap<CommentItem, HotReply>()
.ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Member.Uname))
.ForMember(dest => dest.Message, opt => opt.MapFrom(src => src.Content.Message))
.ForMember(dest => dest.Emote, opt => opt.MapFrom(src => src.Content.Emote));
expression.CreateMap<CommentItem, CommentViewModel>()
.ForMember(dest => dest.HotReplies, opt => opt.MapFrom(src => src.Replies));
.ForMember(dest => dest.HotReplies, opt => opt.MapFrom(src => src.Replies))
.ForMember(dest => dest.HotReplyContents, opt => opt.MapFrom(src => src.Replies));
expression.CreateMap<DataCommentModel, DataCommentViewModel>();
expression.CreateMap<CommentContentModel, CommentContentViewModel>();
expression.CreateMap<VideoDetailModel, VideoDetailViewModel>();
Expand Down
33 changes: 33 additions & 0 deletions src/BiliLite.UWP/Models/Common/Comment/HotReply.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Linq;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
using BiliLite.Extensions;
using Newtonsoft.Json.Linq;

namespace BiliLite.Models.Common.Comment
{
public class HotReply
{
public string UserName { get; set; }

public string Message { get; set; }

public JObject Emote { get; set; }

public RichTextBlock Content
{
get
{
if (Message.Length <= 50)
{
return $"{UserName}: {Message}"
.ToRichTextBlock(Emote);
}

return $"{UserName}: {Message.SubstringCommentText(50)}..."
.ToRichTextBlock(Emote);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public class CommentControlViewModel : BaseViewModel

public double Width { get; set; } = 320;

[DependsOn(nameof(Width))] public bool IsNarrowMode => Width < 300;
[DependsOn(nameof(Width))] public bool IsNarrowMode => Width < 360;

[DependsOn(nameof(Width))] public bool IsWideMode => Width >= 300;
[DependsOn(nameof(Width))] public bool IsWideMode => Width >= 360;

[DependsOn(nameof(Width))] public bool IsNarrow2Mode => Width < 200;

Expand Down
3 changes: 3 additions & 0 deletions src/BiliLite.UWP/ViewModels/Comment/CommentViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Windows.UI;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -153,6 +154,8 @@ public string Time

public ObservableCollection<CommentViewModel> HotReplies { get; set; }

public List<HotReply> HotReplyContents { get; set; }

[DependsOn(nameof(ShowReplies))]
public bool ShowHotReplies
{
Expand Down

0 comments on commit a2954dd

Please sign in to comment.