Skip to content

Commit

Permalink
添加追番/追剧跳转 (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Jan 7, 2024
1 parent 556a163 commit 0376f37
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
ItemsStretch="Fill"
MinColumnSpacing="8"
MinItemHeight="220"
MinItemWidth="120"
MinItemWidth="128"
MinRowSpacing="8" />
</ItemsRepeater.Layout>
</ItemsRepeater>
Expand Down
38 changes: 35 additions & 3 deletions src/App/Controls/Modules/AnimeNavListModule.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<Grid RowSpacing="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
Expand Down Expand Up @@ -69,8 +70,39 @@
</StackPanel>
</Grid>

<Button
Grid.Row="1"
Margin="12,0"
Padding="12"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
BorderThickness="0"
Click="OnFavoriteButtonClick">
<Grid ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<base:FluentIcon
VerticalAlignment="Center"
FontSize="14"
Symbol="Dust" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{ext:Locale Name=MyFavoriteAnime}" />
<base:FluentIcon
Grid.Column="2"
VerticalAlignment="Center"
FontSize="12"
Foreground="{ThemeResource TextFillColorTertiaryBrush}"
Symbol="ArrowCircleUpRight" />
</Grid>
</Button>

<!-- 时间表 -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsTimelineShown, Mode=OneWay}">
<Grid Grid.Row="2" Visibility="{x:Bind ViewModel.IsTimelineShown, Mode=OneWay}">
<ScrollViewer
Padding="8,0"
Style="{StaticResource PageScrollViewerStyle}"
Expand Down Expand Up @@ -123,7 +155,7 @@
</Grid>

<!-- 番剧索引 -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsBangumiShown, Mode=OneWay}">
<Grid Grid.Row="2" Visibility="{x:Bind ViewModel.IsBangumiShown, Mode=OneWay}">
<ScrollViewer Padding="12,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind _bangumi.Filters}">
<ItemsRepeater.ItemTemplate>
Expand Down Expand Up @@ -157,7 +189,7 @@
</Grid>

<!-- 国创索引 -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsDomesticShown, Mode=OneWay}">
<Grid Grid.Row="2" Visibility="{x:Bind ViewModel.IsDomesticShown, Mode=OneWay}">
<ScrollViewer Padding="12,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind _domestic.Filters}">
<ItemsRepeater.ItemTemplate>
Expand Down
3 changes: 3 additions & 0 deletions src/App/Controls/Modules/AnimeNavListModule.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ private void OnDomesticConditionChangedAsync(object sender, SelectionChangedEven
}
}
}

private void OnFavoriteButtonClick(object sender, RoutedEventArgs e)
=> AppViewModel.Instance.ShowFavoritesCommand.Execute(FavoriteType.Anime);
}

/// <summary>
Expand Down
38 changes: 35 additions & 3 deletions src/App/Controls/Modules/FilmNavListModule.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<Grid RowSpacing="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
Expand Down Expand Up @@ -70,8 +71,39 @@
</StackPanel>
</Grid>

<Button
Grid.Row="1"
Margin="12,0"
Padding="12"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
BorderThickness="0"
Click="OnFavoriteButtonClick">
<Grid ColumnSpacing="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<base:FluentIcon
VerticalAlignment="Center"
FontSize="14"
Symbol="FilmstripPlay" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{ext:Locale Name=MyFavoriteFilm}" />
<base:FluentIcon
Grid.Column="2"
VerticalAlignment="Center"
FontSize="12"
Foreground="{ThemeResource TextFillColorTertiaryBrush}"
Symbol="ArrowCircleUpRight" />
</Grid>
</Button>

<!-- 电影索引 -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsMovieShown, Mode=OneWay}">
<Grid Grid.Row="2" Visibility="{x:Bind ViewModel.IsMovieShown, Mode=OneWay}">
<ScrollViewer Padding="12,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind _movieRecommendDetailViewModel.Filters}">
<ItemsRepeater.ItemTemplate>
Expand Down Expand Up @@ -105,7 +137,7 @@
</Grid>

<!-- 电视剧索引 -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsTvShown, Mode=OneWay}">
<Grid Grid.Row="2" Visibility="{x:Bind ViewModel.IsTvShown, Mode=OneWay}">
<ScrollViewer Padding="12,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind _tvRecommendDetailViewModel.Filters}">
<ItemsRepeater.ItemTemplate>
Expand Down Expand Up @@ -139,7 +171,7 @@
</Grid>

<!-- 纪录片索引 -->
<Grid Grid.Row="1" Visibility="{x:Bind ViewModel.IsDocumentaryShown, Mode=OneWay}">
<Grid Grid.Row="2" Visibility="{x:Bind ViewModel.IsDocumentaryShown, Mode=OneWay}">
<ScrollViewer Padding="12,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind _documentaryRecommendDetailViewModel.Filters}">
<ItemsRepeater.ItemTemplate>
Expand Down
3 changes: 3 additions & 0 deletions src/App/Controls/Modules/FilmNavListModule.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ private void OnMovieConditionChangedAsync(object sender, SelectionChangedEventAr
}
}
}

private void OnFavoriteButtonClick(object sender, RoutedEventArgs e)
=> AppViewModel.Instance.ShowFavoritesCommand.Execute(FavoriteType.Film);
}

/// <summary>
Expand Down
9 changes: 7 additions & 2 deletions src/App/Forms/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Bili.Copilot.Models.Data.User;
using Bili.Copilot.Models.Data.Video;
using Bili.Copilot.ViewModels;
using Bili.Copilot.ViewModels.Views;
using Microsoft.UI.Windowing;
using Windows.Graphics;

Expand Down Expand Up @@ -233,14 +234,18 @@ private void OnRequestShowFans(object sender, UserProfile e)
}
}

private void OnRequestShowFavorites(object sender, EventArgs e)
private void OnRequestShowFavorites(object sender, FavoriteType e)
{
Activate();
MainSplitView.IsPaneOpen = false;

if (OverlayFrame.Content is not FavoritesPage)
{
_ = OverlayFrame.Navigate(typeof(FavoritesPage));
_ = OverlayFrame.Navigate(typeof(FavoritesPage), e);
}
else
{
FavoritesPageViewModel.Instance.Type = e;
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/App/Pages/FavoritesPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Bili Copilot. All rights reserved.

using Bili.Copilot.App.Controls.Base;
using Bili.Copilot.Models.Constants.App;
using Bili.Copilot.ViewModels.Views;

namespace Bili.Copilot.App.Pages;
Expand All @@ -20,10 +21,17 @@ public FavoritesPage()
}

/// <inheritdoc/>
protected override void OnPageLoaded()
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.Video.InitializeCommand.Execute(default);
if (e.Parameter is FavoriteType type)
{
ViewModel.Type = type;
}
}

/// <inheritdoc/>
protected override void OnPageLoaded()
=> ViewModel.Video.InitializeCommand.Execute(default);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public sealed partial class AppViewModel
/// <summary>
/// 请求显示收藏夹.
/// </summary>
public event EventHandler RequestShowFavorites;
public event EventHandler<FavoriteType> RequestShowFavorites;

/// <summary>
/// 在有新的用户空间请求时触发.
Expand Down
4 changes: 2 additions & 2 deletions src/ViewModels/Components/AppViewModel/AppViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ private void ShowHistory()
=> RequestShowHistory?.Invoke(this, EventArgs.Empty);

[RelayCommand]
private void ShowFavorites()
private void ShowFavorites(FavoriteType type = FavoriteType.Video)
{
IsOverlayShown = true;
RequestShowFavorites?.Invoke(this, EventArgs.Empty);
RequestShowFavorites?.Invoke(this, type);
}

[RelayCommand]
Expand Down

0 comments on commit 0376f37

Please sign in to comment.