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 3ad3f2d commit 57ca01f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/BiliLite.UWP/Controls/CommentControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<StackPanel Grid.Column="0"
Grid.ColumnSpan="3"
Grid.Row="2"
Margin="3 0 0 0"
Margin="8 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>
Expand Down Expand Up @@ -408,6 +408,7 @@
ItemsSource="{x:Bind HotReplyContents,Mode=OneWay}"
ItemContainerStyle="{StaticResource hotReplyStyle}"
Background="{ThemeResource CardColor}"
Margin="0 0 8 0"
SelectionMode="None"
IsItemClickEnabled="False"
ScrollViewer.VerticalScrollMode="Disabled"
Expand Down
12 changes: 9 additions & 3 deletions src/BiliLite.UWP/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static string TraditionalToSimplified(this string input)
/// <param name="txt"></param>
/// <param name="emote"></param>
/// <returns></returns>
public static RichTextBlock ToRichTextBlock(this string txt, JObject emote, bool isLive = false, string fontColor = null, string fontWeight = "Normal")
public static RichTextBlock ToRichTextBlock(this string txt, JObject emote, bool isLive = false, string fontColor = null, string fontWeight = "Normal",string lowProfilePrefix="")
{
var input = txt;
try
Expand All @@ -105,15 +105,21 @@ public static RichTextBlock ToRichTextBlock(this string txt, JObject emote, bool
//处理av号/bv号
if (!isLive) { input = HandelVideoID(input); }

if (!string.IsNullOrEmpty(lowProfilePrefix))
{
lowProfilePrefix = $"<Run Foreground=\"{{ThemeResource LowProfileTextColor}}\" Text=\"{lowProfilePrefix}\"></Run>";
}

//生成xaml
var xaml = string.Format(@"<RichTextBlock HorizontalAlignment=""Stretch"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:d=""http://schemas.microsoft.com/expression/blend/2008""
xmlns:mc = ""http://schemas.openxmlformats.org/markup-compatibility/2006"" LineHeight=""{1}"" {2} {3}>
<Paragraph>{0}</Paragraph>
<Paragraph>{4}{0}</Paragraph>
</RichTextBlock>", input,
isLive ? 22 : 20,
fontColor == null ? "" : $"Foreground=\"{fontColor}\"",
$"FontWeight=\"{fontWeight}\"");
$"FontWeight=\"{fontWeight}\"",
lowProfilePrefix);
var p = (RichTextBlock)XamlReader.Load(xaml);
return p;
}
Expand Down
13 changes: 5 additions & 8 deletions src/BiliLite.UWP/Models/Common/Comment/HotReply.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Linq;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Controls;
using BiliLite.Extensions;
using Newtonsoft.Json.Linq;

Expand All @@ -21,12 +18,12 @@ public RichTextBlock Content
{
if (Message.Length <= 50)
{
return $"{UserName}: {Message}"
.ToRichTextBlock(Emote);
return $"{Message}"
.ToRichTextBlock(Emote, lowProfilePrefix: $"{UserName}: ");
}

return $"{UserName}: {Message.SubstringCommentText(50)}..."
.ToRichTextBlock(Emote);
return $"{Message.SubstringCommentText(50)}..."
.ToRichTextBlock(Emote, lowProfilePrefix: $"{UserName}: ");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/BiliLite.UWP/Themes/Dark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Color x:Key="DefaultTextColor">#CC000000</Color>
<Color x:Key="SystemColorHighLightColor">#ec407a</Color>
<Color x:Key="LinkTextColor">#008ac5</Color>
<Color x:Key="LowProfileTextColor">Gray</Color>

<SolidColorBrush x:Key="NavigationViewTopPaneBackground" Color="{ThemeResource TopPaneBackground}" />
<Color x:Key="NoTapGridBackground">#FF282828</Color>
Expand Down
1 change: 1 addition & 0 deletions src/BiliLite.UWP/Themes/Light.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Color x:Key="DefaultTextColor">#CC000000</Color>
<Color x:Key="SystemColorHighLightColor">#ec407a</Color>
<Color x:Key="LinkTextColor">#008ac5</Color>
<Color x:Key="LowProfileTextColor">Gray</Color>

<SolidColorBrush x:Key="NavigationViewTopPaneBackground" Color="{ThemeResource TopPaneBackground}" />
<Color x:Key="NoTapGridBackground">#FFF9F9F9</Color>
Expand Down

0 comments on commit 57ca01f

Please sign in to comment.