Skip to content

Commit

Permalink
展示评论热门回复
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Mar 26, 2024
1 parent e59abf5 commit bb52467
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 3 deletions.
46 changes: 44 additions & 2 deletions src/BiliLite.UWP/Controls/CommentControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
<Setter Property="BorderBrush" Value="#33808080"></Setter>
<Setter Property="Padding" Value="0"></Setter>
</Style>

<Style TargetType="ListViewItem" x:Key="hotReplyStyle">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="BorderThickness" Value="0 1 0 1"></Setter>
<Setter Property="BorderBrush" Value="#33808080"></Setter>
<Setter Property="Padding" Value="0"></Setter>
</Style>
<convert:ColorSelecteConvert x:Key="colorSelct" ></convert:ColorSelecteConvert>
<convert:ColorConvert x:Key="colorConvert" ></convert:ColorConvert>
<Flyout x:Key="FaceFlyout" x:Name="FaceFlyout">
Expand Down Expand Up @@ -204,6 +211,7 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>

<ContentControl Grid.Row="0" Margin="4 0" Content="{Binding Path=CommentText,Mode=OneWay}" Visibility="Visible">
Expand Down Expand Up @@ -268,8 +276,6 @@
<TextBlock FontSize="10" Margin="8 8" Foreground="Gray">UP主觉得很赞</TextBlock>
</Border>
</StackPanel>


</Grid>

<StackPanel Grid.Row="4" Margin="0 4" Background="#19AAAAAA" Padding="8" Visibility="{x:Bind Path=ShowReplies,Mode=OneWay}">
Expand Down Expand Up @@ -388,6 +394,42 @@
</StackPanel>

</StackPanel>

<ListView
Grid.Row="6"
Visibility="{x:Bind ShowHotReplies,Mode=OneWay}"
ItemsSource="{x:Bind HotReplies,Mode=OneWay}"
ItemContainerStyle="{StaticResource hotReplyStyle}"
Background="{ThemeResource CardColor}"
SelectionMode="None"
IsItemClickEnabled="False"
ScrollViewer.VerticalScrollMode="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
<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">
</ContentControl>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

</Grid>
</DataTemplate>
</UserControl.Resources>
Expand Down
1 change: 1 addition & 0 deletions src/BiliLite.UWP/Controls/CommentControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private async Task GetComment()
result = await m_commentApi.CommentV2(m_loadCommentInfo.Oid, m_loadCommentInfo.CommentSort, m_page,
m_loadCommentInfo.CommentMode, offsetStr: m_nextCursor?.PaginationReply?.NextOffset).Request();
}

if (!result.status)
{
throw new CustomizedErrorException("加载评论失败");
Expand Down
3 changes: 2 additions & 1 deletion src/BiliLite.UWP/Extensions/MapperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public static IServiceCollection AddMapper(this IServiceCollection services)
{
expression.CreateMap<DownloadItem, DownloadItemViewModel>();
expression.CreateMap<DownloadEpisodeItem, DownloadEpisodeItemViewModel>();
expression.CreateMap<CommentItem, CommentViewModel>();
expression.CreateMap<CommentItem, CommentViewModel>()
.ForMember(dest => dest.HotReplies, opt => opt.MapFrom(src => src.Replies));
expression.CreateMap<DataCommentModel, DataCommentViewModel>();
expression.CreateMap<CommentContentModel, CommentContentViewModel>();
expression.CreateMap<VideoDetailModel, VideoDetailViewModel>();
Expand Down
10 changes: 10 additions & 0 deletions src/BiliLite.UWP/Models/Common/SettingConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public class UI
/// 默认折叠评论长度
/// </summary>
public const int COMMENT_SHRINK_DEFAULT_LENGTH = 75;

/// <summary>
/// 显示评论热门回复
/// </summary>
public const string SHOW_HOT_REPLIES = "ShowHotReplies";

/// <summary>
/// 显示评论热门回复默认选项
/// </summary>
public const bool DEFAULT_SHOW_HOT_REPLIES = true;
}

public class Account
Expand Down
5 changes: 5 additions & 0 deletions src/BiliLite.UWP/Pages/SettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@
<controls:NumberBox x:Name="numCommentShrinkLength" Minimum="0" Width="200" HorizontalAlignment="Left" Value="0" SpinButtonPlacementMode="Compact" SmallChange="1" ></controls:NumberBox>
</StackPanel>

<StackPanel Margin="0 0 0 8">
<TextBlock Margin="0 8" FontSize="16">展示评论热门回复</TextBlock>
<ToggleSwitch x:Name="swShowHotReplies" ></ToggleSwitch>
</StackPanel>

<StackPanel Margin="0 0 0 8">
<TextBlock Margin="0 8" FontSize="16">新窗口打开图片预览</TextBlock>
<ToggleSwitch x:Name="swPreviewImageNavigateToPage" ></ToggleSwitch>
Expand Down
10 changes: 10 additions & 0 deletions src/BiliLite.UWP/Pages/SettingPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ private void LoadUI()
};
};

// 展示评论热门回复
swShowHotReplies.IsOn = SettingService.GetValue(SettingConstants.UI.SHOW_HOT_REPLIES, SettingConstants.UI.DEFAULT_SHOW_HOT_REPLIES);
swShowHotReplies.Loaded += (sender, e) =>
{
swShowHotReplies.Toggled += (obj, args) =>
{
SettingService.SetValue(SettingConstants.UI.SHOW_HOT_REPLIES, swShowHotReplies.IsOn);
};
};

//动态显示
cbDynamicDisplayMode.SelectedIndex = SettingService.GetValue<int>(SettingConstants.UI.DYNAMIC_DISPLAY_MODE, 0);
cbDynamicDisplayMode.Loaded += new RoutedEventHandler((sender, e) =>
Expand Down
12 changes: 12 additions & 0 deletions src/BiliLite.UWP/ViewModels/Comment/CommentViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ public string Time

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

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

[DependsOn(nameof(ShowReplies))]
public bool ShowHotReplies
{
get
{
if (!SettingService.GetValue(SettingConstants.UI.SHOW_HOT_REPLIES, SettingConstants.UI.DEFAULT_SHOW_HOT_REPLIES)) return false;
return !ShowReplies;
}
}

//public ObservableCollection<CommentModel> replies { get; set; }

public bool ShowReplies { get; set; } = false;
Expand Down

0 comments on commit bb52467

Please sign in to comment.