Skip to content

Commit

Permalink
Main Page Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
MaKrotos committed Apr 19, 2024
1 parent 80989ab commit 6b91c62
Show file tree
Hide file tree
Showing 20 changed files with 259 additions and 221 deletions.
12 changes: 12 additions & 0 deletions MusicX.Core/Models/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public class Block

[JsonProperty("Banners")]
public List<CatalogBanner> Banners { get; set; } = new List<CatalogBanner>();

[JsonProperty("meta")]
public MetaBLock? Meta { get; set; }



public List<Link> Links { get; set; } = new List<Link>();
public List<Suggestion> Suggestions { get; set; } = new List<Suggestion>();
public List<Artist> Artists { get; set; } = new List<Artist>();
Expand All @@ -120,4 +126,10 @@ public class Block

public List<Station> Stations { get; set; } = new List<Station>();
}

public class MetaBLock
{
[JsonProperty("anchor")]
public string? anchor { get; set; }
}
}
2 changes: 1 addition & 1 deletion VK UI3 (Package)/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="FDW.VKM"
Publisher="CN=FDW"
Version="0.1.5.8" />
Version="0.1.6.0" />

<mp:PhoneIdentity PhoneProductId="b7c1f34e-9025-4935-9d7a-7d0a632a368d" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
3 changes: 1 addition & 2 deletions VK UI3/Controls/Blocks/ArtistBannerBlockControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -45,7 +44,7 @@ private void ArtistBannerBlockControl_Loading(FrameworkElement sender, object ar

ArtistText.Text = block.Artists[0].Name;

var sectionView = FindParent<SectionView>(this);
// var sectionView = FindParent<SectionView>(this);

for (var i = 0; i < block.Actions.Count; i++)
{
Expand Down
9 changes: 4 additions & 5 deletions VK UI3/Controls/Blocks/Buttons.xaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<UserControl
x:Class="VK_UI3.Controls.Blocks.Buttons"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:VK_UI3.Controls.Blocks"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:VK_UI3.Controls.Blocks"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Margin="16,0,16,-15"
mc:Ignorable="d">

<GridView ItemsSource="{x:Bind block.Actions}">

</GridView>
<GridView x:Name="gridV" SelectionMode="None" />
</UserControl>
37 changes: 37 additions & 0 deletions VK UI3/Controls/Blocks/Buttons.xaml.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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);
}

}
}
Expand Down
11 changes: 8 additions & 3 deletions VK UI3/Controls/Blocks/ListPlaylists.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<UserControl.Resources>
<local:PlayListTemplateSelector x:Key="PlayListTemplateSelector" />
<DataTemplate x:Key="default">
<local:PlaylistControl />
</DataTemplate>
<DataTemplate x:Key="compact">
<local:VibeControl />
</DataTemplate>
</UserControl.Resources>
<UserControl.Shadow>
<ThemeShadow />
Expand All @@ -23,7 +29,6 @@
CornerRadius="8">
<GridView
x:Name="gridV"
ItemTemplateSelector="{StaticResource PlayListTemplateSelector}"
ItemsSource="{x:Bind playlists, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollMode="Enabled"
Expand Down
46 changes: 11 additions & 35 deletions VK UI3/Controls/Blocks/ListPlaylists.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.ObjectModel;
using VK_UI3.Helpers;
using VkNet.Model.Attachments;


namespace VK_UI3.Controls.Blocks
Expand Down Expand Up @@ -35,6 +34,17 @@ private void ListPlaylists_Loading(FrameworkElement sender, object args)
if (DataContext is not Block block)
return;


if (block.Meta != null && block.Meta.anchor == "vibes")

{
gridV.ItemTemplate = this.Resources["compact"] as DataTemplate;
}
else
{
gridV.ItemTemplate = this.Resources["default"] as DataTemplate;
}

var pl = (DataContext as Block).Playlists;


Expand All @@ -56,41 +66,7 @@ private void ListPlaylists_Loading(FrameworkElement sender, object args)

}

public class PlayListTemplateSelector : DataTemplateSelector
{
public VibeControl VibeControlTemplate { get; set; }
public PlaylistControl playlistControl { get; set; }

protected override DataTemplate? SelectTemplateCore(object? item, DependencyObject container)
{
if (item is AudioPlaylist)
{
string key;
if ((item as AudioPlaylist).meta != null && (item as AudioPlaylist).meta.View != null)
{
key = (item as AudioPlaylist).meta.View;
}
else
{
key = "default";

}

PlayListTemplate playListTemplate = new PlayListTemplate();

playListTemplate.Resources.TryGetValue(key, out object resource);
if (resource != null)
{
return resource as DataTemplate;
}
else
playListTemplate.Resources.TryGetValue("default", out resource);
return resource as DataTemplate;
}

return null;
}
}



Expand Down
1 change: 1 addition & 0 deletions VK UI3/Controls/Blocks/MixControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:palks="using:VK_UI3.Helpers.Animations"
Height="300"
Margin="0,8,0,0"
Background="Transparent"
PointerPressed="UserControl_PointerPressed"
mc:Ignorable="d">
Expand Down
2 changes: 0 additions & 2 deletions VK UI3/Controls/Blocks/MixControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 0 additions & 25 deletions VK UI3/Controls/Blocks/PlayListTemplate.xaml

This file was deleted.

16 changes: 0 additions & 16 deletions VK UI3/Controls/Blocks/PlayListTemplate.xaml.cs

This file was deleted.

2 changes: 1 addition & 1 deletion VK UI3/Controls/TitleBlockControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 0 additions & 2 deletions VK UI3/Controls/TitleBlockControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 6b91c62

Please sign in to comment.