Skip to content

Commit 4510ae1

Browse files
authored
支持动漫表单详情显示 (Richasy#36)
* 添加播放列表接口及类型 * 添加播放列表的显示 * 更新播放器错误 * 完善错误显示
1 parent 609650c commit 4510ae1

32 files changed

Lines changed: 682 additions & 15 deletions

File tree

src/App/App.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<Compile Include="Controls\Dialogs\ConfirmDialog.xaml.cs">
2525
<DependentUpon>ConfirmDialog.xaml</DependentUpon>
2626
</Compile>
27+
<Compile Include="Controls\Pgc\PgcPlayListView.xaml.cs">
28+
<DependentUpon>PgcPlayListView.xaml</DependentUpon>
29+
</Compile>
2730
<Compile Include="Controls\User\AccountPanel.xaml.cs">
2831
<DependentUpon>AccountPanel.xaml</DependentUpon>
2932
</Compile>
@@ -69,7 +72,7 @@
6972
<Compile Include="Controls\Live\FollowLiveView.xaml.cs">
7073
<DependentUpon>FollowLiveView.xaml</DependentUpon>
7174
</Compile>
72-
<Compile Include="Controls\Common\PgcItem.xaml.cs">
75+
<Compile Include="Controls\Pgc\PgcItem.xaml.cs">
7376
<DependentUpon>PgcItem.xaml</DependentUpon>
7477
</Compile>
7578
<Compile Include="Controls\Player\PlayerDashboard.xaml.cs">
@@ -306,6 +309,7 @@
306309
<Content Include="Assets\Bili_rgba_25.png" />
307310
<Content Include="Assets\Bili_rgba_500.png" />
308311
<Content Include="Assets\DashVideoTemplate.xml" />
312+
<Content Include="Assets\ERROR_rgba.png" />
309313
<Content Include="Assets\Level\level_0.png" />
310314
<Content Include="Assets\Level\level_1.png" />
311315
<Content Include="Assets\Level\level_2.png" />
@@ -408,6 +412,10 @@
408412
<SubType>Designer</SubType>
409413
<Generator>MSBuild:Compile</Generator>
410414
</Page>
415+
<Page Include="Controls\Pgc\PgcPlayListView.xaml">
416+
<SubType>Designer</SubType>
417+
<Generator>MSBuild:Compile</Generator>
418+
</Page>
411419
<Page Include="Controls\User\AccountPanel.xaml">
412420
<SubType>Designer</SubType>
413421
<Generator>MSBuild:Compile</Generator>
@@ -468,7 +476,7 @@
468476
<SubType>Designer</SubType>
469477
<Generator>MSBuild:Compile</Generator>
470478
</Page>
471-
<Page Include="Controls\Common\PgcItem.xaml">
479+
<Page Include="Controls\Pgc\PgcItem.xaml">
472480
<SubType>Designer</SubType>
473481
<Generator>MSBuild:Compile</Generator>
474482
</Page>

src/App/Assets/ERROR_rgba.png

41.1 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Richasy. All rights reserved.
22

3+
using System;
34
using Richasy.Bili.ViewModels.Uwp;
45
using Windows.UI.Xaml;
56
using Windows.UI.Xaml.Controls;
@@ -55,6 +56,11 @@ public PgcItem()
5556
this.InitializeComponent();
5657
}
5758

59+
/// <summary>
60+
/// 条目被点击时触发.
61+
/// </summary>
62+
public event EventHandler<SeasonViewModel> ItemClick;
63+
5864
/// <summary>
5965
/// 视图模型.
6066
/// </summary>
@@ -111,6 +117,7 @@ public Style CardStyle
111117

112118
private void OnRootCardClick(object sender, RoutedEventArgs e)
113119
{
120+
ItemClick?.Invoke(this, ViewModel);
114121
AppViewModel.Instance.OpenPlayer(ViewModel);
115122
}
116123
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<UserControl
2+
x:Class="Richasy.Bili.App.Controls.PgcPlayListView"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:loc="using:Richasy.Bili.Locator.Uwp"
7+
xmlns:local="using:Richasy.Bili.App.Controls"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
10+
xmlns:uwp="using:Richasy.Bili.ViewModels.Uwp"
11+
d:DesignHeight="300"
12+
d:DesignWidth="400"
13+
mc:Ignorable="d">
14+
15+
<Grid>
16+
<VisualStateManager.VisualStateGroups>
17+
<VisualStateGroup x:Name="LayoutGroup">
18+
<VisualState x:Name="CenterState">
19+
<VisualState.StateTriggers>
20+
<AdaptiveTrigger MinWindowWidth="{StaticResource MediumWindowThresholdWidth}" />
21+
</VisualState.StateTriggers>
22+
</VisualState>
23+
<VisualState x:Name="BottomState">
24+
<VisualState.StateTriggers>
25+
<AdaptiveTrigger MinWindowWidth="0" />
26+
</VisualState.StateTriggers>
27+
<VisualState.Setters>
28+
<Setter Target="Container.PreferredPlacement" Value="Bottom" />
29+
</VisualState.Setters>
30+
</VisualState>
31+
</VisualStateGroup>
32+
</VisualStateManager.VisualStateGroups>
33+
<muxc:TeachingTip
34+
x:Name="Container"
35+
VerticalAlignment="Stretch"
36+
Closed="OnContainerClosed"
37+
IsLightDismissEnabled="True"
38+
PreferredPlacement="Center"
39+
ShouldConstrainToRootBounds="False">
40+
<muxc:TeachingTip.HeroContent>
41+
<Grid
42+
Padding="20,16,20,12"
43+
RowSpacing="4"
44+
Visibility="{x:Bind ViewModel.IsInitializeLoading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
45+
<Grid.RowDefinitions>
46+
<RowDefinition Height="Auto" />
47+
<RowDefinition Height="Auto" />
48+
</Grid.RowDefinitions>
49+
<TextBlock
50+
Style="{StaticResource SubtitleTextBlockStyle}"
51+
HorizontalAlignment="Left"
52+
Text="{x:Bind ViewModel.Title, Mode=OneWay}" />
53+
<TextBlock
54+
Style="{StaticResource CaptionTextBlockStyle}"
55+
Grid.Row="1"
56+
HorizontalAlignment="Left"
57+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
58+
Text="{x:Bind ViewModel.TotalCount, Mode=OneWay}"
59+
TextWrapping="Wrap" />
60+
</Grid>
61+
</muxc:TeachingTip.HeroContent>
62+
<Grid Width="400" Margin="0,-12,0,0">
63+
<Grid>
64+
<local:VerticalRepeaterView
65+
x:Name="SeasonView"
66+
Grid.Row="2"
67+
Margin="0,0,0,12"
68+
Background="Transparent"
69+
HeaderVisibility="Collapsed"
70+
ItemOrientation="Horizontal"
71+
ItemsSource="{x:Bind ViewModel.SeasonCollection, Mode=OneWay}"
72+
Visibility="{x:Bind ViewModel.IsInitializeLoading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
73+
<local:VerticalRepeaterView.ItemTemplate>
74+
<DataTemplate x:DataType="uwp:SeasonViewModel">
75+
<local:PgcItem
76+
CoverHeight="140"
77+
CoverWidth="100"
78+
ItemClick="OnItemClick"
79+
TitleRowHeight="28"
80+
ViewModel="{x:Bind}">
81+
<local:PgcItem.CardStyle>
82+
<Style TargetType="local:CardPanel">
83+
<Setter Property="IsEnableHoverAnimation" Value="False" />
84+
<Setter Property="IsEnableShadow" Value="False" />
85+
</Style>
86+
</local:PgcItem.CardStyle>
87+
</local:PgcItem>
88+
</DataTemplate>
89+
</local:VerticalRepeaterView.ItemTemplate>
90+
</local:VerticalRepeaterView>
91+
<local:OverlayLoadingPanel
92+
MinHeight="80"
93+
IsBarActive="{x:Bind ViewModel.IsDeltaLoading, Mode=OneWay}"
94+
IsRingActive="{x:Bind ViewModel.IsInitializeLoading, Mode=OneWay}" />
95+
<local:ErrorPanel
96+
x:Name="ErrorPanel"
97+
ActionButtonClick="OnRefreshButtonClickAsync"
98+
ActionContent="{loc:LocaleLocator Name=Refresh}"
99+
Text="{x:Bind ViewModel.ErrorText, Mode=OneWay}"
100+
Visibility="{x:Bind ViewModel.IsError, Mode=OneWay}" />
101+
</Grid>
102+
</Grid>
103+
</muxc:TeachingTip>
104+
</Grid>
105+
</UserControl>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) Richasy. All rights reserved.
2+
3+
using System.Threading.Tasks;
4+
using Richasy.Bili.App.Pages;
5+
using Richasy.Bili.ViewModels.Uwp;
6+
using Windows.UI.Xaml;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace Richasy.Bili.App.Controls
10+
{
11+
/// <summary>
12+
/// PGC播放列表视图.
13+
/// </summary>
14+
public sealed partial class PgcPlayListView : UserControl
15+
{
16+
/// <summary>
17+
/// <see cref="ViewModel"/>的依赖属性.
18+
/// </summary>
19+
public static readonly DependencyProperty ViewModelProperty =
20+
DependencyProperty.Register(nameof(ViewModel), typeof(PgcPlayListViewModel), typeof(PgcPlayListView), new PropertyMetadata(PgcPlayListViewModel.Instance));
21+
22+
/// <summary>
23+
/// Initializes a new instance of the <see cref="PgcPlayListView"/> class.
24+
/// </summary>
25+
public PgcPlayListView()
26+
{
27+
this.InitializeComponent();
28+
}
29+
30+
/// <summary>
31+
/// 视图模型.
32+
/// </summary>
33+
public PgcPlayListViewModel ViewModel
34+
{
35+
get { return (PgcPlayListViewModel)GetValue(ViewModelProperty); }
36+
set { SetValue(ViewModelProperty, value); }
37+
}
38+
39+
/// <summary>
40+
/// 显示.
41+
/// </summary>
42+
/// <param name="listId">用户Id.</param>
43+
/// <returns><see cref="Task"/>.</returns>
44+
public async Task ShowAsync(int listId)
45+
{
46+
Container.IsOpen = true;
47+
((Window.Current.Content as Frame).Content as RootPage).ShowOnHolder(this);
48+
await ViewModel.InitializeAsync(listId);
49+
}
50+
51+
private void OnContainerClosed(Microsoft.UI.Xaml.Controls.TeachingTip sender, Microsoft.UI.Xaml.Controls.TeachingTipClosedEventArgs args)
52+
{
53+
((Window.Current.Content as Frame).Content as RootPage).ClearHolder();
54+
}
55+
56+
private void OnItemClick(object sender, SeasonViewModel e)
57+
{
58+
this.Container.IsOpen = false;
59+
}
60+
61+
private async void OnRefreshButtonClickAsync(object sender, RoutedEventArgs e)
62+
{
63+
await ViewModel.InitializeAsync(ViewModel.Id, isRefresh: true);
64+
}
65+
}
66+
}

src/App/Controls/Player/Related/SeasonView.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@
4444
</Border>
4545
</Grid>
4646
<TextBlock
47+
x:Name="TitleBlock"
4748
Style="{StaticResource BodyTextBlockStyle}"
4849
Grid.Row="1"
4950
HorizontalAlignment="Center"
5051
FontWeight="Bold"
5152
MaxLines="1"
5253
Text="{x:Bind Data.Title}"
5354
TextAlignment="Center"
54-
TextTrimming="CharacterEllipsis" />
55+
TextTrimming="CharacterEllipsis">
56+
<ToolTipService.ToolTip>
57+
<ToolTip Content="{x:Bind Data.Title}" IsEnabled="{Binding ElementName=TitleBlock, Path=IsTextTrimmed}" />
58+
</ToolTipService.ToolTip>
59+
</TextBlock>
5560
</Grid>
5661
</controls:CardPanel>
5762
</DataTemplate>

src/App/Controls/User/UserView.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ public async Task ShowAsync(UserViewModel vm)
8585
}
8686
}
8787

88-
private void OnRefreshButtonClickAsync(object sender, RoutedEventArgs e)
88+
private async void OnRefreshButtonClickAsync(object sender, RoutedEventArgs e)
8989
{
90+
await ViewModel.InitializeUserDetailAsync();
9091
}
9192

9293
private async void OnVideoViewRequestLoadMoreAsync(object sender, System.EventArgs e)

src/App/Pages/Overlay/PlayerPage.xaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,32 @@
8282
x:Name="PlayerContainer"
8383
Margin="0,0,0,24"
8484
Visibility="{x:Bind ViewModel.IsDetailLoading, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
85-
<controls:BiliPlayer x:Name="BiliPlayer" />
85+
<controls:BiliPlayer x:Name="BiliPlayer" Visibility="{x:Bind ViewModel.IsPlayInformationError, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
86+
<Grid
87+
x:Name="PlayErrorContainer"
88+
MinHeight="200"
89+
VerticalAlignment="Stretch"
90+
x:Load="{x:Bind ViewModel.IsPlayInformationError, Mode=OneWay}"
91+
Background="{ThemeResource LayerFillColorDefaultBrush}"
92+
CornerRadius="{StaticResource OverlayCornerRadius}">
93+
<StackPanel
94+
Padding="20,12"
95+
HorizontalAlignment="Center"
96+
VerticalAlignment="Center"
97+
Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}"
98+
CornerRadius="{StaticResource OverlayCornerRadius}"
99+
Spacing="8">
100+
<Image
101+
Width="120"
102+
HorizontalAlignment="Center"
103+
Source="ms-appx:///Assets/ERROR_rgba.png"
104+
Stretch="Uniform" />
105+
<TextBlock
106+
HorizontalAlignment="Center"
107+
Text="{x:Bind ViewModel.PlayInformationErrorText, Mode=OneWay}"
108+
TextAlignment="Center" />
109+
</StackPanel>
110+
</Grid>
86111
</Grid>
87112

88113
<Grid

src/App/Pages/Reuse/AnimePage.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Richasy. All rights reserved.
22

33
using System.Threading.Tasks;
4+
using Richasy.Bili.App.Controls;
45
using Richasy.Bili.Models.Enums;
56
using Richasy.Bili.ViewModels.Uwp;
67
using Windows.UI.Xaml;
@@ -102,8 +103,13 @@ private void OnRootNavViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView
102103
CheckCurrentTabAsync();
103104
}
104105

105-
private void OnShowMoreButtonClickAsync(object sender, RoutedEventArgs e)
106+
private async void OnShowMoreButtonClickAsync(object sender, RoutedEventArgs e)
106107
{
108+
var vm = (sender as Button).Tag as PgcModuleViewModel;
109+
if (vm.Id > 0)
110+
{
111+
await new PgcPlayListView().ShowAsync(vm.Id);
112+
}
107113
}
108114

109115
private void OnIndexButtonClick(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)