Skip to content

Commit c4d9994

Browse files
committed
添加热门视频
1 parent 1a6cce1 commit c4d9994

33 files changed

Lines changed: 551 additions & 81 deletions

src/App/App.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
<Compile Include="Controls\Shadow\CardAttachedShadow.cs" />
6868
<Compile Include="Controls\Shadow\IAttachedShadow.cs" />
6969
<Compile Include="Controls\Shadow\Shadows.cs" />
70-
<Compile Include="Pages\ChannelPage.xaml.cs">
71-
<DependentUpon>ChannelPage.xaml</DependentUpon>
72-
</Compile>
7370
<Compile Include="Pages\DocumentaryPage.xaml.cs">
7471
<DependentUpon>DocumentaryPage.xaml</DependentUpon>
7572
</Compile>
@@ -85,6 +82,9 @@
8582
<Compile Include="Pages\HelpPage.xaml.cs">
8683
<DependentUpon>HelpPage.xaml</DependentUpon>
8784
</Compile>
85+
<Compile Include="Pages\PopularPage.xaml.cs">
86+
<DependentUpon>PopularPage.xaml</DependentUpon>
87+
</Compile>
8888
<Compile Include="Pages\RecommendPage.xaml.cs">
8989
<DependentUpon>RecommendPage.xaml</DependentUpon>
9090
</Compile>
@@ -268,10 +268,6 @@
268268
<SubType>Designer</SubType>
269269
<Generator>MSBuild:Compile</Generator>
270270
</Page>
271-
<Page Include="Pages\ChannelPage.xaml">
272-
<SubType>Designer</SubType>
273-
<Generator>MSBuild:Compile</Generator>
274-
</Page>
275271
<Page Include="Pages\DocumentaryPage.xaml">
276272
<SubType>Designer</SubType>
277273
<Generator>MSBuild:Compile</Generator>
@@ -292,6 +288,10 @@
292288
<SubType>Designer</SubType>
293289
<Generator>MSBuild:Compile</Generator>
294290
</Page>
291+
<Page Include="Pages\PopularPage.xaml">
292+
<SubType>Designer</SubType>
293+
<Generator>MSBuild:Compile</Generator>
294+
</Page>
295295
<Page Include="Pages\RecommendPage.xaml">
296296
<SubType>Designer</SubType>
297297
<Generator>MSBuild:Compile</Generator>

src/App/Controls/Bili/VideoView.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
xmlns:local="using:Richasy.Bili.App.Controls"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
9-
xmlns:uwp="using:Richasy.Bili.ViewModels.Uwp"
109
d:DesignHeight="300"
1110
d:DesignWidth="400"
1211
mc:Ignorable="d">

src/App/Controls/RootNavigationView.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@
5959
</muxc:NavigationViewItem>
6060
<muxc:NavigationViewItem ext:NavigationExtension.PageId="Rank" Content="{loc:LocaleLocator Name=Rank}">
6161
<muxc:NavigationViewItem.Icon>
62-
<icons:FluentIconElement Symbol="RibbonStar20" />
62+
<icons:FluentIconElement Symbol="Trophy16" />
6363
</muxc:NavigationViewItem.Icon>
6464
</muxc:NavigationViewItem>
6565
<muxc:NavigationViewItem ext:NavigationExtension.PageId="Partition" Content="{loc:LocaleLocator Name=Partition}">
6666
<muxc:NavigationViewItem.Icon>
6767
<icons:FluentIconElement Symbol="Apps16" />
6868
</muxc:NavigationViewItem.Icon>
6969
</muxc:NavigationViewItem>
70-
<muxc:NavigationViewItem ext:NavigationExtension.PageId="Channel" Content="{loc:LocaleLocator Name=Channel}">
70+
<muxc:NavigationViewItem ext:NavigationExtension.PageId="Popular" Content="{loc:LocaleLocator Name=Popular}">
7171
<muxc:NavigationViewItem.Icon>
72-
<icons:FluentIconElement Symbol="ChannelShare16" />
72+
<icons:FluentIconElement Symbol="Rocket16" />
7373
</muxc:NavigationViewItem.Icon>
7474
</muxc:NavigationViewItem>
7575
<muxc:NavigationViewItem ext:NavigationExtension.PageId="Live" Content="{loc:LocaleLocator Name=Live}">

src/App/Controls/RootNavigationView.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ private void CheckMainContentNavigation()
115115
case PageIds.Partition:
116116
pageType = typeof(PartitionPage);
117117
break;
118-
case PageIds.Channel:
119-
pageType = typeof(ChannelPage);
118+
case PageIds.Popular:
119+
pageType = typeof(PopularPage);
120120
break;
121121
case PageIds.SpecialColumn:
122122
pageType = typeof(SpecialColumnPage);

src/App/Pages/ChannelPage.xaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/App/Pages/ChannelPage.xaml.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/App/Pages/PopularPage.xaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<Page
2+
x:Class="Richasy.Bili.App.Pages.PopularPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:controls="using:Richasy.Bili.App.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:loc="using:Richasy.Bili.Locator.Uwp"
8+
xmlns:local="using:Richasy.Bili.App.Pages"
9+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
10+
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
11+
xmlns:uwp="using:Richasy.Bili.ViewModels.Uwp"
12+
mc:Ignorable="d">
13+
14+
<Grid>
15+
<VisualStateManager.VisualStateGroups>
16+
<VisualStateGroup x:Name="Common">
17+
<VisualState x:Name="WideState">
18+
<VisualState.StateTriggers>
19+
<AdaptiveTrigger MinWindowWidth="{StaticResource CompactModeThresholdWidth}" />
20+
</VisualState.StateTriggers>
21+
</VisualState>
22+
<VisualState x:Name="NarrowState">
23+
<VisualState.StateTriggers>
24+
<AdaptiveTrigger MinWindowWidth="0" />
25+
</VisualState.StateTriggers>
26+
<VisualState.Setters>
27+
<Setter Target="ContentScrollViewer.Padding" Value="{StaticResource NarrowContainerPadding}" />
28+
<Setter Target="VideoView.ItemOrientation" Value="Horizontal" />
29+
</VisualState.Setters>
30+
</VisualState>
31+
</VisualStateGroup>
32+
</VisualStateManager.VisualStateGroups>
33+
<muxc:RefreshContainer RefreshRequested="OnRefreshRequestedAsync">
34+
<ScrollViewer
35+
x:Name="ContentScrollViewer"
36+
Padding="{StaticResource DefaultContainerPadding}"
37+
HorizontalScrollMode="Disabled"
38+
VerticalScrollBarVisibility="Auto">
39+
<controls:VideoView
40+
x:Name="VideoView"
41+
Margin="0,0,0,12"
42+
HeaderVisibility="Collapsed"
43+
ItemsSource="{x:Bind ViewModel.VideoCollection}"
44+
RequestLoadMore="OnVideoViewRequestLoadMoreAsync">
45+
<controls:VideoView.ItemTemplate>
46+
<DataTemplate x:DataType="uwp:VideoViewModel">
47+
<controls:VideoItem
48+
AdditionalOverlayContentVisibility="{x:Bind AdditionalText, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}"
49+
IsShowAvatar="False"
50+
IsShowDanmakuCount="{x:Bind DanmakuCount, Mode=OneWay, Converter={StaticResource ObjectToBoolConverter}}"
51+
IsShowLikeCount="{x:Bind LikeCount, Mode=OneWay, Converter={StaticResource ObjectToBoolConverter}}"
52+
IsShowPlayCount="True"
53+
ViewModel="{x:Bind Mode=OneWay}">
54+
<controls:VideoItem.AdditionalOverlayContent>
55+
<Grid
56+
Padding="8,4"
57+
HorizontalAlignment="Left"
58+
Background="{ThemeResource AccentMaskAcrylicBrush}"
59+
CornerRadius="{StaticResource ControlCornerRadius}">
60+
<TextBlock
61+
Style="{StaticResource CaptionTextBlockStyle}"
62+
Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}"
63+
Text="{x:Bind AdditionalText, Mode=OneWay}" />
64+
</Grid>
65+
</controls:VideoItem.AdditionalOverlayContent>
66+
</controls:VideoItem>
67+
</DataTemplate>
68+
</controls:VideoView.ItemTemplate>
69+
</controls:VideoView>
70+
</ScrollViewer>
71+
</muxc:RefreshContainer>
72+
73+
<muxc:ProgressRing Style="{StaticResource PageProgressRingStyle}" IsActive="{x:Bind ViewModel.IsInitializeLoading, Mode=OneWay}" />
74+
<muxc:ProgressBar
75+
HorizontalAlignment="Stretch"
76+
VerticalAlignment="Bottom"
77+
IsIndeterminate="True"
78+
Visibility="{x:Bind ViewModel.IsDeltaLoading, Mode=OneWay}" />
79+
80+
<controls:ErrorPanel
81+
x:Name="ErrorPanel"
82+
HorizontalAlignment="Center"
83+
VerticalAlignment="Center"
84+
ActionButtonClick="OnRefreshButtonClickAsync"
85+
ActionContent="{loc:LocaleLocator Name=Refresh}"
86+
Text="{x:Bind ViewModel.ErrorText, Mode=OneWay}"
87+
Visibility="{x:Bind ViewModel.IsError, Mode=OneWay}" />
88+
</Grid>
89+
</Page>

src/App/Pages/PopularPage.xaml.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) Richasy. All rights reserved.
2+
3+
using System.Linq;
4+
using Richasy.Bili.ViewModels.Uwp;
5+
using Windows.UI.Xaml;
6+
using Windows.UI.Xaml.Controls;
7+
8+
namespace Richasy.Bili.App.Pages
9+
{
10+
/// <summary>
11+
/// 热门视频页面.
12+
/// </summary>
13+
public sealed partial class PopularPage : Page
14+
{
15+
/// <summary>
16+
/// <see cref="ViewModel"/>的依赖属性.
17+
/// </summary>
18+
public static readonly DependencyProperty ViewModelProperty =
19+
DependencyProperty.Register(nameof(ViewModel), typeof(PopularViewModel), typeof(RecommendPage), new PropertyMetadata(PopularViewModel.Instance));
20+
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="PopularPage"/> class.
23+
/// </summary>
24+
public PopularPage()
25+
{
26+
this.InitializeComponent();
27+
this.Loaded += OnLoadedAsync;
28+
}
29+
30+
/// <summary>
31+
/// 热门视频视图模型.
32+
/// </summary>
33+
public PopularViewModel ViewModel
34+
{
35+
get { return (PopularViewModel)GetValue(ViewModelProperty); }
36+
set { SetValue(ViewModelProperty, value); }
37+
}
38+
39+
private async void OnLoadedAsync(object sender, RoutedEventArgs e)
40+
{
41+
if (!this.ViewModel.VideoCollection.Any())
42+
{
43+
await this.ViewModel.RequestDataAsync();
44+
}
45+
}
46+
47+
private async void OnVideoViewRequestLoadMoreAsync(object sender, System.EventArgs e)
48+
{
49+
await this.ViewModel.RequestDataAsync();
50+
}
51+
52+
private async void OnRefreshRequestedAsync(Microsoft.UI.Xaml.Controls.RefreshContainer sender, Microsoft.UI.Xaml.Controls.RefreshRequestedEventArgs args)
53+
{
54+
var def = args.GetDeferral();
55+
if (!ViewModel.IsInitializeLoading && !ViewModel.IsDeltaLoading)
56+
{
57+
ViewModel.Reset();
58+
await this.ViewModel.RequestDataAsync();
59+
}
60+
61+
def.Complete();
62+
def.Dispose();
63+
}
64+
65+
private async void OnRefreshButtonClickAsync(object sender, RoutedEventArgs e)
66+
{
67+
await ViewModel.RequestDataAsync();
68+
}
69+
}
70+
}

src/App/Resources/Strings/zh-CN/Resources.resw

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@
138138
<data name="CaptchaIsEmpty" xml:space="preserve">
139139
<value>验证码不能为空</value>
140140
</data>
141-
<data name="Channel" xml:space="preserve">
142-
<value>频道</value>
143-
</data>
144141
<data name="ComprehensiveDynamics" xml:space="preserve">
145142
<value>综合动态</value>
146143
</data>
@@ -231,6 +228,9 @@
231228
<data name="PleaseSignIn" xml:space="preserve">
232229
<value>请登录</value>
233230
</data>
231+
<data name="Popular" xml:space="preserve">
232+
<value>热门</value>
233+
</data>
234234
<data name="QRCodeExpired" xml:space="preserve">
235235
<value>二维码已过期,请刷新</value>
236236
</data>
@@ -249,6 +249,9 @@
249249
<data name="Refresh" xml:space="preserve">
250250
<value>刷新</value>
251251
</data>
252+
<data name="RequestPopularFailed" xml:space="preserve">
253+
<value>热门视频请求失败</value>
254+
</data>
252255
<data name="RequestRecommendFailed" xml:space="preserve">
253256
<value>推荐视频请求失败</value>
254257
</data>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Richasy. All rights reserved.
2+
3+
using System.Threading.Tasks;
4+
5+
namespace Richasy.Bili.Controller.Uwp
6+
{
7+
/// <summary>
8+
/// 热门.
9+
/// </summary>
10+
public partial class BiliController
11+
{
12+
/// <summary>
13+
/// 获取热门信息.
14+
/// </summary>
15+
/// <param name="offsetIndex">偏移值.</param>
16+
/// <returns><see cref="Task"/>.</returns>
17+
public async Task RequestPopularCardsAsync(int offsetIndex)
18+
{
19+
try
20+
{
21+
var cards = await _popularProvider.GetPopularDetailAsync(offsetIndex);
22+
PopularVideoIteration?.Invoke(this, new Models.App.Args.PopularVideoIterationEventArgs(cards));
23+
}
24+
catch
25+
{
26+
if (offsetIndex == 0)
27+
{
28+
throw;
29+
}
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)