Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

支持显示联合创作 #335

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/App/Controls/App/AppTitleBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@
<Button
x:Name="BackButton"
Style="{StaticResource TitleBarButtonStyle}"
Click="OnBackButtonClick"
IsEnabled="{x:Bind ViewModel.IsBackButtonEnabled, Mode=OneWay}">
Click="OnBackButtonClick">
<Button.KeyboardAccelerators>
<KeyboardAccelerator Key="Back" IsEnabled="True" />
<KeyboardAccelerator Key="XButton2" IsEnabled="True" />
<KeyboardAccelerator Key="Back" IsEnabled="{x:Bind ViewModel.IsBackButtonEnabled, Mode=OneWay}" />
</Button.KeyboardAccelerators>
<animations:Implicit.ShowAnimations>
<animations:OpacityAnimation
Expand Down
143 changes: 97 additions & 46 deletions src/App/Controls/Player/PlayerDescriptor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:local="using:Richasy.Bili.App.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:uwp="using:Richasy.Bili.ViewModels.Uwp"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">
Expand All @@ -20,53 +21,103 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<StackPanel
x:Name="SinglePublisherContainer"
Margin="0,0,0,12"
HorizontalAlignment="Left"
Orientation="Horizontal"
Spacing="12"
Visibility="{x:Bind ViewModel.Publisher, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}">
<local:UserAvatar
Width="36"
Height="36"
Avatar="{x:Bind ViewModel.Publisher.Avatar, Mode=OneWay}"
Tapped="OnUserTappedAsync"
UserName="{x:Bind ViewModel.Publisher.Name, Mode=OneWay}" />
<StackPanel Spacing="4">
<TextBlock
VerticalAlignment="Center"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.Publisher.Name, Mode=OneWay}" />
<Grid HorizontalAlignment="Left" Visibility="{x:Bind ViewModel.Publisher.IsShowFollowButton, Mode=OneWay}">
<Button
x:Name="FollowButton"
Style="{StaticResource AccentButtonStyle}"
Padding="8,2"
Click="OnFollowButtonClickAsync"
Visibility="{x:Bind ViewModel.Publisher.IsFollow, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<local:IconTextBlock
FontSize="10"
IconFontSize="12"
Spacing="2"
Symbol="Add12"
Text="{loc:LocaleLocator Name=Follow}" />
</Button>
<Button
x:Name="UnfollowButton"
Padding="8,2"
Click="OnFollowButtonClickAsync"
Visibility="{x:Bind ViewModel.Publisher.IsFollow, Mode=OneWay}">
<local:IconTextBlock
FontSize="10"
IconFontSize="12"
Spacing="2"
Symbol="EyeShow12"
Text="{loc:LocaleLocator Name=Followed}" />
</Button>
</Grid>
<Grid>
<StackPanel
x:Name="SinglePublisherContainer"
Margin="0,0,0,12"
HorizontalAlignment="Left"
Orientation="Horizontal"
Spacing="12"
Visibility="{x:Bind ViewModel.IsShowStaff, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<local:UserAvatar
Width="36"
Height="36"
Avatar="{x:Bind ViewModel.Publisher.Avatar, Mode=OneWay}"
DataContext="{x:Bind ViewModel.Publisher, Mode=OneWay}"
Tapped="OnUserTappedAsync"
UserName="{x:Bind ViewModel.Publisher.Name, Mode=OneWay}" />
<StackPanel Spacing="4">
<TextBlock
VerticalAlignment="Center"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.Publisher.Name, Mode=OneWay}" />
<Grid HorizontalAlignment="Left" Visibility="{x:Bind ViewModel.Publisher.IsShowFollowButton, Mode=OneWay}">
<Button
x:Name="FollowButton"
Style="{StaticResource AccentButtonStyle}"
Padding="8,2"
Click="OnFollowButtonClickAsync"
Visibility="{x:Bind ViewModel.Publisher.IsFollow, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<local:IconTextBlock
FontSize="10"
IconFontSize="12"
Spacing="2"
Symbol="Add12"
Text="{loc:LocaleLocator Name=Follow}" />
</Button>
<Button
x:Name="UnfollowButton"
Padding="8,2"
Click="OnFollowButtonClickAsync"
Visibility="{x:Bind ViewModel.Publisher.IsFollow, Mode=OneWay}">
<local:IconTextBlock
FontSize="10"
IconFontSize="12"
Spacing="2"
Symbol="EyeShow12"
Text="{loc:LocaleLocator Name=Followed}" />
</Button>
</Grid>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel
x:Name="StaffContainer"
Margin="0,0,0,8"
Orientation="Horizontal"
Visibility="{x:Bind ViewModel.IsShowStaff, Mode=OneWay}">
<muxc:ItemsRepeater ItemsSource="{x:Bind ViewModel.StaffCollection, Mode=OneWay}">
<muxc:ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="uwp:UserViewModel">
<Grid>
<StackPanel Spacing="4">
<local:UserAvatar
Width="36"
Height="36"
Avatar="{x:Bind Avatar, Mode=OneWay}"
DataContext="{x:Bind}"
Tapped="OnUserTappedAsync"
UserName="{x:Bind Name, Mode=OneWay}" />
<TextBlock
MaxWidth="52"
HorizontalAlignment="Center"
FontSize="12"
Text="{x:Bind Name}"
TextAlignment="Center"
TextTrimming="CharacterEllipsis"
ToolTipService.ToolTip="{x:Bind Name}" />
</StackPanel>
<Border
Margin="0,-8,-8,0"
Padding="4"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{StaticResource ControlCornerRadius}">
<TextBlock FontSize="10" Text="{x:Bind AdditionalText, Mode=OneWay}" />
</Border>
</Grid>

</DataTemplate>
</muxc:ItemsRepeater.ItemTemplate>
<muxc:ItemsRepeater.Layout>
<muxc:StackLayout Orientation="Horizontal" Spacing="8" />
</muxc:ItemsRepeater.Layout>
</muxc:ItemsRepeater>
</StackPanel>
</Grid>


<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
Expand Down
7 changes: 5 additions & 2 deletions src/App/Controls/Player/PlayerDescriptor.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Richasy. All rights reserved.

using Richasy.Bili.ViewModels.Uwp;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Richasy.Bili.App.Controls
Expand All @@ -19,10 +21,11 @@ public PlayerDescriptor()

private async void OnUserTappedAsync(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await UserView.Instance.ShowAsync(ViewModel.Publisher);
var dataContext = (sender as FrameworkElement).DataContext as UserViewModel;
await UserView.Instance.ShowAsync(dataContext);
}

private async void OnFollowButtonClickAsync(object sender, Windows.UI.Xaml.RoutedEventArgs e)
private async void OnFollowButtonClickAsync(object sender, RoutedEventArgs e)
{
var btn = sender as Button;
btn.IsEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public partial class UserViewModel
[Reactive]
public bool IsShowVideoEmpty { get; set; }

/// <summary>
/// 附加文本.
/// </summary>
[Reactive]
public string AdditionalText { get; set; }

/// <summary>
/// 用户Id.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Bilibili.App.View.V1;
using Richasy.Bili.Locator.Uwp;
using Richasy.Bili.Models.App.Args;
using Richasy.Bili.Models.BiliBili;
Expand Down Expand Up @@ -36,7 +37,6 @@ public UserViewModel(UserSearchItem item)

Level = item.Level;
FollowerCount = _numberToolkit.GetCountText(item.FollowerCount);
CheckFollowButtonVisibility();
}

/// <summary>
Expand All @@ -52,8 +52,6 @@ public UserViewModel(RelatedUser item)
{
Sign = _resourceToolkit.GetLocaleString(LanguageNames.UserEmptySign);
}

CheckFollowButtonVisibility();
}

/// <summary>
Expand All @@ -65,6 +63,17 @@ public UserViewModel(PublisherInfo info)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="UserViewModel"/> class.
/// </summary>
/// <param name="staff">参演人员.</param>
public UserViewModel(Staff staff)
: this(staff.Name, staff.Face, Convert.ToInt32(staff.Mid))
{
AdditionalText = staff.Title;
IsFollow = staff.Attention == 1;
}

/// <summary>
/// Initializes a new instance of the <see cref="UserViewModel"/> class.
/// </summary>
Expand All @@ -79,6 +88,8 @@ public UserViewModel(string userName, string avatar = "", int userId = 0)
{
Avatar = avatar + "@60w_60h_1c_100q.jpg";
}

CheckFollowButtonVisibility();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private void Reset()
LiveDanmakuCollection.Clear();
FavoriteMetaCollection.Clear();
SubtitleIndexCollection.Clear();
StaffCollection.Clear();

ReplyModuleViewModel.Instance.SetInformation(0, Models.Enums.Bili.ReplyType.None);
var preferPlayerMode = _settingsToolkit.ReadLocalSetting(SettingNames.DefaultPlayerDisplayMode, PlayerDisplayMode.Default);
Expand Down Expand Up @@ -200,8 +201,6 @@ private void InitializeVideoDetail()
Title = _videoDetail.Arc.Title;
Subtitle = DateTimeOffset.FromUnixTimeSeconds(_videoDetail.Arc.Pubdate).ToString("yy/MM/dd HH:mm");
Description = _videoDetail.Arc.Desc;
var author = _videoDetail.Arc.Author;
Publisher = new UserViewModel(author.Name, author.Face, Convert.ToInt32(author.Mid));
AvId = _videoDetail.Arc.Aid.ToString();
BvId = _videoDetail.Bvid;
SeasonId = string.Empty;
Expand All @@ -218,6 +217,24 @@ private void InitializeVideoDetail()
CoverUrl = _videoDetail.Arc.Pic;
ReplyModuleViewModel.Instance.SetInformation(Convert.ToInt32(_videoDetail.Arc.Aid), Models.Enums.Bili.ReplyType.Video);

if (_videoDetail.Staff.Count > 0)
{
// 联合创作.
IsShowStaff = true;
foreach (var user in _videoDetail.Staff)
{
var vm = new UserViewModel(user);
StaffCollection.Add(vm);
}
}
else
{
// 独立创作.
IsShowStaff = false;
var author = _videoDetail.Arc.Author;
Publisher = new UserViewModel(author.Name, author.Face, Convert.ToInt32(author.Mid));
}

IsLikeChecked = _videoDetail.ReqUser.Like == 1;
IsCoinChecked = _videoDetail.ReqUser.Coin == 1;
IsFavoriteChecked = _videoDetail.ReqUser.Favorite == 1;
Expand Down Expand Up @@ -674,6 +691,7 @@ private MediaPlayer InitializeMediaPlayer()
private async Task InitializeUserRelationAsync()
{
if (AccountViewModel.Instance.Status != AccountViewModelStatus.Login ||
IsShowStaff ||
AccountViewModel.Instance.Mid.Value == Publisher.Id)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,24 @@ public partial class PlayerViewModel
[Reactive]
public UserViewModel Publisher { get; set; }

/// <summary>
/// 是否显示为参演人员列表.
/// </summary>
[Reactive]
public bool IsShowStaff { get; set; }

/// <summary>
/// 音量.
/// </summary>
[Reactive]
public double Volume { get; set; }

/// <summary>
/// 参演人员集合.
/// </summary>
[Reactive]
public ObservableCollection<UserViewModel> StaffCollection { get; set; }

/// <summary>
/// 关联视频集合.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public PlayerViewModel()
LiveDanmakuCollection = new ObservableCollection<LiveDanmakuMessage>();
FavoriteMetaCollection = new ObservableCollection<FavoriteMetaViewModel>();
SubtitleIndexCollection = new ObservableCollection<SubtitleIndexItemViewModel>();
StaffCollection = new ObservableCollection<UserViewModel>();
_audioList = new List<DashItem>();
_videoList = new List<DashItem>();
_flvList = new List<FlvItem>();
Expand Down