From 6b91c622170110e4e36247e5224438a09a5a3680 Mon Sep 17 00:00:00 2001 From: MaKrotos Date: Fri, 19 Apr 2024 16:32:47 +0300 Subject: [PATCH] Main Page Completed --- MusicX.Core/Models/Block.cs | 12 ++ VK UI3 (Package)/Package.appxmanifest | 2 +- .../Blocks/ArtistBannerBlockControl.xaml.cs | 3 +- VK UI3/Controls/Blocks/Buttons.xaml | 9 +- VK UI3/Controls/Blocks/Buttons.xaml.cs | 37 ++++ VK UI3/Controls/Blocks/ListPlaylists.xaml | 11 +- VK UI3/Controls/Blocks/ListPlaylists.xaml.cs | 46 ++--- VK UI3/Controls/Blocks/MixControl.xaml | 1 + VK UI3/Controls/Blocks/MixControl.xaml.cs | 2 - VK UI3/Controls/Blocks/PlayListTemplate.xaml | 25 --- .../Controls/Blocks/PlayListTemplate.xaml.cs | 16 -- VK UI3/Controls/TitleBlockControl.xaml | 2 +- VK UI3/Controls/TitleBlockControl.xaml.cs | 2 - VK UI3/Controls/VibeControl.xaml | 158 +++++++++++------- VK UI3/Controls/VibeControl.xaml.cs | 18 +- VK UI3/MainWindow.xaml | 9 +- VK UI3/VK UI3.csproj | 4 - VK UI3/Views/Controls/BlockButtonView.xaml.cs | 84 ++++++---- VK UI3/Views/PlayList.xaml | 16 +- VK UI3/Views/PlayListPage.xaml.cs | 23 ++- 20 files changed, 259 insertions(+), 221 deletions(-) delete mode 100644 VK UI3/Controls/Blocks/PlayListTemplate.xaml delete mode 100644 VK UI3/Controls/Blocks/PlayListTemplate.xaml.cs diff --git a/MusicX.Core/Models/Block.cs b/MusicX.Core/Models/Block.cs index de74e7a..e977f5e 100644 --- a/MusicX.Core/Models/Block.cs +++ b/MusicX.Core/Models/Block.cs @@ -101,6 +101,12 @@ public class Block [JsonProperty("Banners")] public List Banners { get; set; } = new List(); + + [JsonProperty("meta")] + public MetaBLock? Meta { get; set; } + + + public List Links { get; set; } = new List(); public List Suggestions { get; set; } = new List(); public List Artists { get; set; } = new List(); @@ -120,4 +126,10 @@ public class Block public List Stations { get; set; } = new List(); } + + public class MetaBLock + { + [JsonProperty("anchor")] + public string? anchor { get; set; } + } } diff --git a/VK UI3 (Package)/Package.appxmanifest b/VK UI3 (Package)/Package.appxmanifest index 36e2d88..be57c5c 100644 --- a/VK UI3 (Package)/Package.appxmanifest +++ b/VK UI3 (Package)/Package.appxmanifest @@ -13,7 +13,7 @@ + Version="0.1.6.0" /> diff --git a/VK UI3/Controls/Blocks/ArtistBannerBlockControl.xaml.cs b/VK UI3/Controls/Blocks/ArtistBannerBlockControl.xaml.cs index f635af7..e34e4c2 100644 --- a/VK UI3/Controls/Blocks/ArtistBannerBlockControl.xaml.cs +++ b/VK UI3/Controls/Blocks/ArtistBannerBlockControl.xaml.cs @@ -3,7 +3,6 @@ using Microsoft.UI.Xaml.Media; using MusicX.Core.Models; using VK_UI3.Helpers.Animations; -using VK_UI3.Views; using VK_UI3.Views.Controls; using static VK_UI3.Views.Controls.BlockButtonView; @@ -45,7 +44,7 @@ private void ArtistBannerBlockControl_Loading(FrameworkElement sender, object ar ArtistText.Text = block.Artists[0].Name; - var sectionView = FindParent(this); + // var sectionView = FindParent(this); for (var i = 0; i < block.Actions.Count; i++) { diff --git a/VK UI3/Controls/Blocks/Buttons.xaml b/VK UI3/Controls/Blocks/Buttons.xaml index acd56a3..162ee07 100644 --- a/VK UI3/Controls/Blocks/Buttons.xaml +++ b/VK UI3/Controls/Blocks/Buttons.xaml @@ -1,14 +1,13 @@ - + - - - + diff --git a/VK UI3/Controls/Blocks/Buttons.xaml.cs b/VK UI3/Controls/Blocks/Buttons.xaml.cs index 8b08e95..b394032 100644 --- a/VK UI3/Controls/Blocks/Buttons.xaml.cs +++ b/VK UI3/Controls/Blocks/Buttons.xaml.cs @@ -1,5 +1,8 @@ +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using MusicX.Core.Models; +using VK_UI3.Views.Controls; +using static VK_UI3.Views.Controls.BlockButtonView; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -18,9 +21,43 @@ public Buttons() this.DataContextChanged += Buttons_DataContextChanged; } + + private void Buttons_DataContextChanged(Microsoft.UI.Xaml.FrameworkElement sender, Microsoft.UI.Xaml.DataContextChangedEventArgs args) { + if (DataContext is not Block bloc) return; + + gridV.Items.Clear(); + + + foreach (var item in bloc.Actions) + { + var action = item; + + var text = new TextBlock(); + + + var button = new BlockButtonView() + { + Margin = new Thickness(0, 10, 15, 10), + DataContext = new BlockBTN(action, parentBlock: block), + Height = 45, + blockBTN = new BlockBTN(action, parentBlock: block) + }; + + + if (button.DataContext is BlockBTN viewModel) + { + button.Command = button.InvokeCommand; + } + + + button.MinWidth = 170; + + button.Refresh(); + gridV.Items.Add(button); + } } } diff --git a/VK UI3/Controls/Blocks/ListPlaylists.xaml b/VK UI3/Controls/Blocks/ListPlaylists.xaml index 714f131..f1e6c13 100644 --- a/VK UI3/Controls/Blocks/ListPlaylists.xaml +++ b/VK UI3/Controls/Blocks/ListPlaylists.xaml @@ -5,12 +5,18 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:custom="using:VK_UI3.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="using:VK_UI3.Controls.Blocks" + xmlns:local="using:VK_UI3.Controls" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Margin="10,0,10,0" mc:Ignorable="d"> - + + + + + + @@ -23,7 +29,6 @@ CornerRadius="8"> diff --git a/VK UI3/Controls/Blocks/MixControl.xaml.cs b/VK UI3/Controls/Blocks/MixControl.xaml.cs index 5ec0a3e..3117e1a 100644 --- a/VK UI3/Controls/Blocks/MixControl.xaml.cs +++ b/VK UI3/Controls/Blocks/MixControl.xaml.cs @@ -52,8 +52,6 @@ private void MixControl_Loaded(object sender, RoutedEventArgs e) private void MixControl_Unloaded(object sender, RoutedEventArgs e) { - - this.Loading -= MixControl_Loading; this.Unloaded -= MixControl_Unloaded; this.DataContextChanged -= MixControl_DataContextChanged; diff --git a/VK UI3/Controls/Blocks/PlayListTemplate.xaml b/VK UI3/Controls/Blocks/PlayListTemplate.xaml deleted file mode 100644 index 6696679..0000000 --- a/VK UI3/Controls/Blocks/PlayListTemplate.xaml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/VK UI3/Controls/Blocks/PlayListTemplate.xaml.cs b/VK UI3/Controls/Blocks/PlayListTemplate.xaml.cs deleted file mode 100644 index 2a18900..0000000 --- a/VK UI3/Controls/Blocks/PlayListTemplate.xaml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.UI.Xaml.Controls; - -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - -namespace VK_UI3.Controls.Blocks -{ - public sealed partial class PlayListTemplate : UserControl - { - public PlayListTemplate() - { - this.InitializeComponent(); - } - } -} - diff --git a/VK UI3/Controls/TitleBlockControl.xaml b/VK UI3/Controls/TitleBlockControl.xaml index 1a757d0..dc52ee2 100644 --- a/VK UI3/Controls/TitleBlockControl.xaml +++ b/VK UI3/Controls/TitleBlockControl.xaml @@ -5,7 +5,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - Margin="15,-10,15,5" + Margin="15,0,15,5" d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> diff --git a/VK UI3/Controls/TitleBlockControl.xaml.cs b/VK UI3/Controls/TitleBlockControl.xaml.cs index a19b6e7..5b634c8 100644 --- a/VK UI3/Controls/TitleBlockControl.xaml.cs +++ b/VK UI3/Controls/TitleBlockControl.xaml.cs @@ -92,7 +92,6 @@ private void TitleBlockControl_Loading(FrameworkElement sender, object args) if (block.Actions.Count > 0) { - if (block.Actions[0].Options.Count > 0) //android { ButtonsGrid.Visibility = Visibility.Visible; @@ -150,7 +149,6 @@ private async void MoreButton_Click(object sender, RoutedEventArgs e) var button = block.Buttons[0]; - MainView.OpenSection(button.SectionId); } catch (Exception ex) diff --git a/VK UI3/Controls/VibeControl.xaml b/VK UI3/Controls/VibeControl.xaml index 4ad6648..34d3262 100644 --- a/VK UI3/Controls/VibeControl.xaml +++ b/VK UI3/Controls/VibeControl.xaml @@ -1,59 +1,69 @@ - - + - - - + + + - + - + - + - + - + - + - + @@ -61,38 +71,66 @@ To="0" Duration="0:0:0.25"/> - - - - - - - - - - - - + + + + - - + + - - - @@ -102,7 +140,7 @@ To="0" Duration="0:0:0.25"/> - + diff --git a/VK UI3/Controls/VibeControl.xaml.cs b/VK UI3/Controls/VibeControl.xaml.cs index bb6a4b9..2f6e70d 100644 --- a/VK UI3/Controls/VibeControl.xaml.cs +++ b/VK UI3/Controls/VibeControl.xaml.cs @@ -2,7 +2,6 @@ using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; using System; -using System.Collections.Generic; using VK_UI3.Controllers; using VK_UI3.Helpers; using VK_UI3.Helpers.Animations; @@ -22,6 +21,7 @@ public VibeControl() this.InitializeComponent(); AnimationsChangeFontIcon = new AnimationsChangeFontIcon(PlayPause, this.DispatcherQueue); + animationsChangeImage = new AnimationsChangeImage(GridThumbs, this.DispatcherQueue); titleAnim = new AnimationsChangeText(Title, this.DispatcherQueue); this.Unloaded += PlaylistControl_Unloaded; @@ -170,24 +170,12 @@ public void update() if (_PlayList.Cover != null) { - GridThumbs.AddImagesToGrid(_PlayList.Cover); - } - else if (_PlayList.Thumbs != null) - { - int count = _PlayList.Thumbs.Count; - int index = 0; - List list = new List(); - foreach (var item in _PlayList.Thumbs) - { - string photo = item.Photo600 ?? item.Photo1200 ?? item.Photo300 ?? item.Photo34 ?? item.Photo270 ?? item.Photo135 ?? item.Photo68; - list.Add(photo); - index++; - } - GridThumbs.AddImagesToGrid(list); + animationsChangeImage.ChangeImageWithAnimation(_PlayList.Cover); } + updatePlayState(); FadeInAnimationGrid.Begin(); diff --git a/VK UI3/MainWindow.xaml b/VK UI3/MainWindow.xaml index ecfdfd6..b3da73c 100644 --- a/VK UI3/MainWindow.xaml +++ b/VK UI3/MainWindow.xaml @@ -104,7 +104,7 @@ Grid.Column="1" Width="0" Height="0" - Margin="0,0,0,0" + Margin="0,0,0,5" Padding="0" Background="Transparent" BorderThickness="0" @@ -156,11 +156,12 @@ Grid.Column="2" Width="20" Height="20" - Margin="5" + Margin="5,0,5,5" Source="ms-appx:///Assets/StoreLogo.scale-400.png" /> @@ -170,7 +171,7 @@ Grid.Column="4" Width="0" Height="0" - Margin="0,0,0,0" + Margin="0,0,0,5" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Center" @@ -198,7 +199,7 @@ Grid.Column="4" Width="0" Height="0" - Margin="0,0,0,0" + Margin="0,0,0,5" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Center" diff --git a/VK UI3/VK UI3.csproj b/VK UI3/VK UI3.csproj index 033e772..9bd4c19 100644 --- a/VK UI3/VK UI3.csproj +++ b/VK UI3/VK UI3.csproj @@ -36,7 +36,6 @@ - @@ -128,9 +127,6 @@ - - $(DefaultXamlRuntime) - $(DefaultXamlRuntime) diff --git a/VK UI3/Views/Controls/BlockButtonView.xaml.cs b/VK UI3/Views/Controls/BlockButtonView.xaml.cs index 46fcaf0..23295da 100644 --- a/VK UI3/Views/Controls/BlockButtonView.xaml.cs +++ b/VK UI3/Views/Controls/BlockButtonView.xaml.cs @@ -59,47 +59,65 @@ public BlockBTN(Button action, Artist artist = null, Block parentBlock = null) } public BlockBTN blockBTN; - + bool firstRefresh = false; public void Refresh() { + string txt = ""; + Symbol icon = Symbol.Accept; - switch (Action.Action.Type) + if (Action.Action.Type == "toggle_artist_subscription" && blockBTN.Artist != null && blockBTN.ParentBlock != null) + { + txt = blockBTN.Artist.IsFollowed ? "Отписаться" : "Подписаться"; + icon = blockBTN.Artist.IsFollowed ? Symbol.UnFavorite : Symbol.Favorite; + } + else if (Action.Action.Type == "play_shuffled_audios_from_block") + { + txt = "Перемешать все"; + icon = Symbol.Play; + } + else if (Action.Action.Type == "create_playlist") + { + txt = "Создать плейлист"; + icon = Symbol.Add; + } + else if (Action.Action.Type == "play_audios_from_block") + { + txt = "Слушать всё"; + icon = Symbol.Play; + } + else if (Action.Action.Type == "open_section") { - case "toggle_artist_subscription" when blockBTN.Artist is not null && blockBTN.ParentBlock is not null: - changeText.ChangeTextWithAnimation(blockBTN.Artist.IsFollowed ? "Отписаться" : "Подписаться"); - changeIcon.ChangeSymbolIconWithAnimation(blockBTN.Artist.IsFollowed ? Symbol.UnFavorite : Symbol.Favorite); - break; - case "play_shuffled_audios_from_block": - changeText.ChangeTextWithAnimation("Перемешать все"); - changeIcon.ChangeSymbolIconWithAnimation(Symbol.Play); - break; - case "create_playlist": - changeText.ChangeTextWithAnimation("Создать плейлист"); - changeIcon.ChangeSymbolIconWithAnimation(Symbol.Add); - break; - case "play_audios_from_block": - changeText.ChangeTextWithAnimation("Слушать всё"); - changeIcon.ChangeSymbolIconWithAnimation(Symbol.Play); - break; - case "open_section": - changeText.ChangeTextWithAnimation(Action.Title ?? "Открыть"); - changeIcon.ChangeSymbolIconWithAnimation(Symbol.OpenFile); - break; - case "music_follow_owner": - changeText.ChangeTextWithAnimation(Action.IsFollowing ? "Вы подписаны на музыку" : "Подписаться на музыку"); - changeIcon.ChangeSymbolIconWithAnimation(Action.IsFollowing ? Symbol.SolidStar : Symbol.Add); - break; - case "open_url": - changeText.ChangeTextWithAnimation(Action.Title); - break; - default: - changeIcon.ChangeSymbolIconWithAnimation(Symbol.Accept); - changeText.ChangeTextWithAnimation("content"); - break; + txt = Action.Title ?? "Открыть"; + icon = Symbol.OpenFile; } + else if (Action.Action.Type == "music_follow_owner") + { + txt = Action.IsFollowing ? "Вы подписаны на музыку" : "Подписаться на музыку"; + icon = Action.IsFollowing ? Symbol.SolidStar : Symbol.Add; + } + else if (Action.Action.Type == "open_url") + { + txt = Action.Title; + } + if (!firstRefresh) + { + + text.Text = txt; + symbolIcon.Symbol = icon; + + } + else + { + changeText.ChangeTextWithAnimation(txt); + changeIcon.ChangeSymbolIconWithAnimation(icon); + } } + + + + private async void Invoke() { try diff --git a/VK UI3/Views/PlayList.xaml b/VK UI3/Views/PlayList.xaml index dafb695..80918af 100644 --- a/VK UI3/Views/PlayList.xaml +++ b/VK UI3/Views/PlayList.xaml @@ -13,20 +13,26 @@ - + - + diff --git a/VK UI3/Views/PlayListPage.xaml.cs b/VK UI3/Views/PlayListPage.xaml.cs index b9aa8f7..41ac230 100644 --- a/VK UI3/Views/PlayListPage.xaml.cs +++ b/VK UI3/Views/PlayListPage.xaml.cs @@ -86,7 +86,7 @@ protected override void OnNavigatedFrom(NavigationEventArgs e) } } - + AudioPlaylist audioPlaylistOriginal; AnimationsChangeText MainText; AnimationsChangeText descriptionText; @@ -102,6 +102,9 @@ private void updateUI(bool load = false) if (vkGetAudio is (PlayListVK)) { var playlist = (vkGetAudio as PlayListVK).playlist; + if (audioPlaylistOriginal == null) + audioPlaylistOriginal = playlist; + if (!playlist.Permissions.Edit) { stackPanel.Items.Remove(EditPlaylist); @@ -152,27 +155,31 @@ private void updateUI(bool load = false) string qownerName = ""; bool hasOwner = false; - if (playlist.userOwner != null) + if (audioPlaylistOriginal.userOwner != null) { hasOwner = true; ownerGrid.Visibility = Visibility.Visible; var a = new Helpers.Animations.AnimationsChangeImage(ownerPictire, DispatcherQueue); - a.ChangeImageWithAnimation(playlist.userOwner.Photo100); - qownerName = playlist.userOwner.FirstName + " " + playlist.userOwner.LastName; + a.ChangeImageWithAnimation(audioPlaylistOriginal.userOwner.Photo100); + qownerName = audioPlaylistOriginal.userOwner.FirstName + " " + audioPlaylistOriginal.userOwner.LastName; } - if (playlist.groupOwner != null) + if (audioPlaylistOriginal.groupOwner != null) { hasOwner = true; ownerGrid.Visibility = Visibility.Visible; var a = new Helpers.Animations.AnimationsChangeImage(ownerPictire, DispatcherQueue); - a.ChangeImageWithAnimation(playlist.groupOwner.Photo100); - qownerName = playlist.groupOwner.Name; + a.ChangeImageWithAnimation(audioPlaylistOriginal.groupOwner.Photo100); + qownerName = audioPlaylistOriginal.groupOwner.Name; } if (!hasOwner) { stackPanel.Items.Remove(ownerGrid); } - ownerName.Text = qownerName; + else + { + ownerName.Text = qownerName; + } +