Skip to content

Commit

Permalink
Revert "[WIP]完善PlayListPage"
Browse files Browse the repository at this point in the history
  • Loading branch information
Raspberry-Monster authored Jun 28, 2024
1 parent e5b3333 commit 0f5a965
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ await RequestAsync(
await RequestAsync(NeteaseApis.PlaylistSubscribeApi,
new PlaylistSubscribeRequest()
{
IsSubscribe = false,
IsSubscribe = true,
PlaylistId = inProviderId.Substring(2)
}, ctk).ConfigureAwait(false);
}
Expand Down
3 changes: 0 additions & 3 deletions src/HyPlayer.App/Resources/Converters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@
<converters:BooleanToNavButtonVisibleConverter x:Key="BooleanToNavButtonVisibleConverter" />
<converters:StringToImageSourceConverter x:Key="StringToImageSourceConverter" />
<converters:BrushToColorConverter x:Key="BrushToColorConverter" />
<converters:TimeStampToDateConverter x:Key="TimeStampToDateConverter"/>
<converters:ArtistListToStringConverter x:Key="ArtistListToStringConverter"/>
<converters:BoolToStringConverter x:Key="BoolToStringConverter"/>
</ResourceDictionary>

This file was deleted.

23 changes: 0 additions & 23 deletions src/HyPlayer.App/ViewModels/Converters/BoolToStringConverter.cs

This file was deleted.

44 changes: 0 additions & 44 deletions src/HyPlayer.App/ViewModels/Converters/TimeStampToDateConverter.cs

This file was deleted.

59 changes: 4 additions & 55 deletions src/HyPlayer.App/ViewModels/NeteasePlaylistViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using HyPlayer.NeteaseProvider.Models;
using HyPlayer.PlayCore.Abstraction.Models.SingleItems;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;

Expand All @@ -25,10 +24,8 @@ public partial class NeteasePlaylistViewModel : ObservableObject, IScrollableVie
public long? PlayCount => PlayList?.PlayCount;
public long? ShareCount => PlayList?.ShareCount;
[ObservableProperty]
public ObservableCollection<NeteaseSong>? _songsList;
public int SortOrder = 0; // 0: 不排序, 1: 升序, 2: 降序
public string SortTypes = "SongName";
private ObservableCollection<NeteaseSong> tempSong;
public List<NeteaseSong>? _songsList;


public NeteasePlaylistViewModel(NeteaseProvider.NeteaseProvider provider)
{
Expand All @@ -40,56 +37,8 @@ public async Task GetSongsAsync()
{
if(PlayList is not null)
{
SongsList = new ObservableCollection<NeteaseSong>((await PlayList.GetAllItemsAsync())?.Select(t => (NeteaseSong)t));
tempSong = SongsList;
}
}

[RelayCommand]
public async Task SubscribePlaylistAsync()
{
if (PlayList.Subscribed==false)
{
await _provider.LikeProvidableItemAsync($"pl{PlayList.ActualId}", null);
}
else
{
await _provider.UnlikeProvidableItemAsync($"pl{PlayList.ActualId}", null);
}
OnPropertyChanged(nameof(PlayList));
}
[RelayCommand]
public void ToggleSortOrder()
{
SortOrder = (SortOrder + 1) % 3;
SortSongListOrder(true);
}

[RelayCommand]
public void SortSongListOrder(bool reload = false)
{
if (SortOrder == 0)
{
if(!reload) return;
SongsList = tempSong;
OnPropertyChanged(nameof(SongsList));
return;
}
switch (SortTypes)
{
case "SongName":
SongsList = new ObservableCollection<NeteaseSong>(SortOrder == 1 ? SongsList.OrderBy(song => song.Name) : SongsList.OrderByDescending(song => song.Name));
break;
case "Artist":
SongsList = new ObservableCollection<NeteaseSong>(SortOrder == 1 ? SongsList.OrderBy(song => song.Artists.FirstOrDefault()?.Name) : SongsList.OrderByDescending(song => song.Artists.FirstOrDefault()?.Name));
break;
case "Album":
SongsList = new ObservableCollection<NeteaseSong>(SortOrder == 1 ? SongsList.OrderBy(song => song.Album?.Name) : SongsList.OrderByDescending(song => song.Album?.Name));
break;
default:
SongsList = tempSong;
OnPropertyChanged(nameof(SongsList));
break;
SongsList = (await PlayList.GetAllItemsAsync())?.Select(t => (NeteaseSong)t).ToList();
}

}
}
6 changes: 2 additions & 4 deletions src/HyPlayer.App/Views/Controls/Dialogs/SignInDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
<TextBox
x:Name="TextBoxAccount"
BorderThickness="0"
PlaceholderText="手机 / 邮箱"
TabIndex="1"/>
PlaceholderText="手机 / 邮箱" />
<PasswordBox
x:Name="TextBoxPassword"
BorderThickness="0"
PlaceholderText="密码"
TabIndex="2"/>
PlaceholderText="密码" />
<TextBlock
VerticalAlignment="Center"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
mc:Ignorable="d">

<Grid>
<ListView x:Name="SongContainer"
ItemsSource="{x:Bind ViewModel.SongsList ,Mode=OneWay}"
IsItemClickEnabled="True"
ItemClick="SongItemOnClick">
<ListView x:Name="SongContainer">
<ListView.Header>
<ContentControl
x:Name="HeaderPanel"
Expand All @@ -25,77 +22,7 @@
<ListView.Footer>
<ContentControl Content="{x:Bind Footer}" />
</ListView.Footer>
<ListView.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem
x:Name="FlyoutItemPlay"
Text="立即播放">
<MenuFlyoutItem.Icon>
<SymbolIcon Symbol="Play" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem
x:Name="FlyoutItemAddToPlaylist"
Text="添加到播放列表">
<MenuFlyoutItem.Icon>
<SymbolIcon Symbol="MusicInfo" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutSeparator />
<MenuFlyoutItem
x:Name="FlyoutItemSinger"
Text="歌手">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE716;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem
x:Name="FlyoutItemAlbum"
Text="专辑">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE93C;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutSeparator />
<MenuFlyoutItem
x:Name="FlyoutItemComments"
Text="评论">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE8F2;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem
x:Name="FlyoutItemDownload"
Text="下载">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE118;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem
x:Name="BtnMV"
Text="视频">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE173;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem
x:Name="FlyoutCollection"
Text="收藏">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE1DA;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem
x:Name="Btn_Del"
Foreground="Red"
Text="删除"
Visibility="{Binding ElementName=SongListRoot, Path=IsMySongList}">
<MenuFlyoutItem.Icon>
<FontIcon Foreground="Red" Glyph="&#xE107;" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyout>
</ListView.ContextFlyout>

<ListView.ItemTemplate>
<DataTemplate x:DataType="netease:NeteaseSong">
<Grid Margin="12,8">
Expand All @@ -110,12 +37,12 @@
Grid.Column="1"
VerticalAlignment="Center"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Text="{x:Bind Artists, Converter={StaticResource ArtistListToStringConverter}}" />
Text="{x:Bind Artists, Converter={StaticResource StringListToStringConverter}}" />
<TextBlock
Grid.Column="2"
VerticalAlignment="Center"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Text="{x:Bind Album.Name}" />
Text="{x:Bind Album}" />
<Button
Grid.Column="3"
Height="32"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using System.Runtime.InteropServices;
using CommunityToolkit.WinUI.UI;
using HyPlayer.NeteaseProvider.Models;
using HyPlayer.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
Expand All @@ -38,7 +31,7 @@ public sealed partial class SongListView : UserControl

public static readonly DependencyProperty FooterProperty = DependencyProperty.Register(
"Footer", typeof(UIElement), typeof(SongListView), new PropertyMetadata(default(UIElement)));
public NeteasePlaylistViewModel ViewModel;

public string ListSource
{
get => (string)GetValue(ListSourceProperty);
Expand All @@ -65,24 +58,5 @@ public SongListView()
{
this.InitializeComponent();
}


public void Update()
{
this.Bindings.Update();
}

private void SongItemOnClick(object sender, ItemClickEventArgs e)
{
var song = (NeteaseSong)e.ClickedItem;
Debug.WriteLine($"Clicking on {song.Name}");
//TODO: Play the song
}

public async void ScrollToIndex(int index)
{
SongContainer.SelectedItem = ViewModel.SongsList[index];
await SongContainer.SmoothScrollIntoViewWithIndexAsync(index, ScrollItemPlacement.Top, false, true);
}
}
}
5 changes: 2 additions & 3 deletions src/HyPlayer.App/Views/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@
LeaderBoardName="{x:Bind Name}"
PlayCount="{x:Bind PlayCount, Converter={StaticResource CountHumanizerConverter}}"
Style="{ThemeResource DefaultTopChartButtonStyle}"
CommandParameter="{x:Bind}"
Click="HomePageTopChart_OnClick"/>
UseSystemFocusVisuals="True" />
</DataTemplate>

<DataTemplate x:Key="HomePagePeronalFMTemplate" x:DataType="models:NeteaseSong">
Expand Down Expand Up @@ -703,7 +702,7 @@
Height="140"
Margin="12,4"
DesiredWidth="240"
IsItemClickEnabled="False"
IsItemClickEnabled="True"
ItemClick="OnPlaylistItemClicked"
ItemHeight="128"
ItemTemplate="{StaticResource HomePageTopChartTemplate}"
Expand Down
Loading

0 comments on commit 0f5a965

Please sign in to comment.