Skip to content

Commit

Permalink
Added Buttons In Horizontal Lists all 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
MaKrotos committed May 22, 2024
1 parent 4bc4e5e commit 6c76639
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 446 deletions.
119 changes: 20 additions & 99 deletions VK UI3/Controls/Blocks/ListPlaylists.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,107 +26,28 @@
<Grid
x:Name="gridCh"
Height="Auto"
CornerRadius="8"
PointerEntered="gridCh_PointerEntered"
PointerExited="gridCh_PointerExited">
<customV:CustomGridView
x:Name="gridV"
Margin="20,0,20,0"
ItemsSource="{x:Bind playlists, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.IsScrollInertiaEnabled="False"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollMode="Disabled"
SelectionMode="None">
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridViewItem">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GridView.ItemContainerStyle>
<GridView.ItemsPanel>
CornerRadius="8">


<customV:UniversalControl
x:Name="myControl"
ItemsSource="{x:Bind playlists}"
itsAll="{x:Bind itsAll}"
>
<customV:UniversalControl.ItemsPanelTemplate>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="1" Orientation="Vertical" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</customV:CustomGridView>
<Grid
x:Name="LeftGrid"
Width="50"
Height="50"
HorizontalAlignment="Left"
Background="{StaticResource SystemControlBackgroundAltMediumHighBrush}"
CornerRadius="50"
Opacity="0"
Visibility="Collapsed">
<Grid.Resources>
<Storyboard x:Name="FadeInAnimationLeftBTN">
<DoubleAnimation
Storyboard.TargetName="LeftGrid"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:0.15" />
</Storyboard>
<!-- Анимация прозрачности от 1 до 0 -->
<Storyboard x:Name="FadeOutAnimationLeftBTN" Completed="FadeOutAnimationLeftBTN_Completed">
<DoubleAnimation
Storyboard.TargetName="LeftGrid"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.15" />
</Storyboard>
</Grid.Resources>
<Button
x:Name="ScrollLeft"
Width="50"
Height="50"
Click="ScrollLeft_Click"
CornerRadius="50">
<FontIcon Glyph="&#xE76B;" />
</Button>
</Grid>

<Grid
x:Name="RightGrid"
Width="50"
Height="50"
HorizontalAlignment="Right"
Background="{StaticResource SystemControlBackgroundAltMediumHighBrush}"
CornerRadius="50"
Opacity="0"
Visibility="Collapsed">
<Grid.Resources>
<Storyboard x:Name="FadeInAnimationRightBTN">
<DoubleAnimation
Storyboard.TargetName="RightGrid"
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:0.15" />
</Storyboard>
<!-- Анимация прозрачности от 1 до 0 -->
<Storyboard x:Name="FadeOutAnimationRightBTN" Completed="FadeOutAnimationRightBTN_Completed">
<DoubleAnimation
Storyboard.TargetName="RightGrid"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.15" />
</Storyboard>
</Grid.Resources>
<Button
x:Name="ScrollRight"
Width="50"
Height="50"
HorizontalAlignment="Right"
Click="ScrollRight_Click"
CornerRadius="50">
<FontIcon Glyph="&#xE76C;" />
</Button>
</Grid>
</customV:UniversalControl.ItemsPanelTemplate>
<customV:UniversalControl.ItemTemplate>
<DataTemplate>
<custom:TrackControl
x:Name="trControl"
MinWidth="300"
FocusVisualPrimaryBrush="Transparent"
FocusVisualSecondaryThickness="0" />
</DataTemplate>
</customV:UniversalControl.ItemTemplate>
</customV:UniversalControl>
</Grid>
</UserControl>
121 changes: 16 additions & 105 deletions VK UI3/Controls/Blocks/ListPlaylists.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,34 @@ public ListPlaylists()
this.Loading += ListPlaylists_Loading;
this.Loaded += ListPlaylists_Loaded;
this.Unloaded += ListPlaylists_Unloaded;
myControl.loadMore = load;

}

private void ListPlaylists_Loaded(object sender, RoutedEventArgs e)
{
if (gridV.CheckIfAllContentIsVisible())
if (myControl.CheckIfAllContentIsVisible())
load();
gridV.loadMore += loadMore;
gridV.LeftChange += LeftChange;
gridV.RightChange += RightChange;

}

private void ListPlaylists_Unloaded(object sender, RoutedEventArgs e)
{
this.Unloaded -= ListPlaylists_Unloaded;
gridV.loadMore -= loadMore;
myControl.loadMore = null;

gridV.loadMore -= loadMore;
gridV.LeftChange -= LeftChange;
gridV.RightChange -= RightChange;
}


private SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);

public bool itsAll
{
get
{
if (localBlock == null) return true;
if (localBlock.NextFrom == null) return true; else return false;
}
}
private async void load()
{
await semaphore.WaitAsync();
Expand All @@ -61,7 +64,7 @@ private async void load()
{
playlists.Add(item);
}
if (gridV.CheckIfAllContentIsVisible())
if (myControl.CheckIfAllContentIsVisible())
load();
});
}
Expand All @@ -85,11 +88,11 @@ private void ListPlaylists_Loading(FrameworkElement sender, object args)
if (block.Meta != null && block.Meta.anchor == "vibes")

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

var pl = (DataContext as Block).Playlists;
Expand All @@ -111,99 +114,7 @@ private void ListPlaylists_Loading(FrameworkElement sender, object args)



private void LeftChange(object sender, EventArgs e)
{
LeftCh();
}
private void RightChange(object sender, EventArgs e)
{
RightCh();
}

private void RightCh()
{
if (gridV.showRight)
{
RightGrid.Visibility = Visibility.Visible;

FadeOutAnimationRightBTN.Pause();
FadeInAnimationRightBTN.Begin();

}
else
{
if (localBlock.NextFrom != null)
{
FadeInAnimationRightBTN.Pause();
FadeOutAnimationRightBTN.Begin();
}
}
}
private void FadeOutAnimationRightBTN_Completed(object sender, object e)
{
if (!gridV.showRight || !enterpoint)
{
RightGrid.Visibility = Visibility.Collapsed;
}
}

private void FadeOutAnimationLeftBTN_Completed(object sender, object e)
{
if (!gridV.showLeft || !enterpoint)
{
LeftGrid.Visibility = Visibility.Collapsed;
}

}

private void gridCh_PointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
{
enterpoint = true;
var a = gridV.ShowLeftChecker;
a = gridV.ShowRightChecker;
LeftCh();
RightCh();
}
bool enterpoint;
private void gridCh_PointerExited(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
{
this.enterpoint = false;
FadeInAnimationLeftBTN.Pause();
FadeOutAnimationLeftBTN.Begin();
FadeInAnimationRightBTN.Pause();
FadeOutAnimationRightBTN.Begin();
}
private void LeftCh()
{
if (gridV.showLeft)
{
LeftGrid.Visibility = Visibility.Visible;

FadeOutAnimationLeftBTN.Pause();
FadeInAnimationLeftBTN.Begin();
}
else
{
FadeInAnimationLeftBTN.Pause();
FadeOutAnimationLeftBTN.Begin();

}
}
private void loadMore(object sender, EventArgs e)
{
load();
}


private void ScrollRight_Click(object sender, RoutedEventArgs e)
{
gridV.ScrollRight();
}

private void ScrollLeft_Click(object sender, RoutedEventArgs e)
{
gridV.ScrollLeft();
}


}
}
5 changes: 4 additions & 1 deletion VK UI3/Controls/Blocks/ListTracks.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
Margin="0,0,0,0"
mc:Ignorable="d">

<customV:UniversalControl x:Name="myControl" ItemsSource="{x:Bind sectionAudio.listAudio}">
<customV:UniversalControl
x:Name="myControl"
ItemsSource="{x:Bind sectionAudio.listAudio}"
itsAll="{x:Bind sectionAudio.itsAll}">
<customV:UniversalControl.ItemsPanelTemplate>
<ItemsPanelTemplate>
<ItemsWrapGrid MaximumRowsOrColumns="3" Orientation="Vertical" />
Expand Down
15 changes: 4 additions & 11 deletions VK UI3/Controls/Blocks/ListTracks.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ private void ListTracks_Unloaded(object sender, RoutedEventArgs e)

}

private void loadMore(object sender, EventArgs e)
{
sectionAudio.GetTracks();
}


private void ListTracks_Loaded(object sender, RoutedEventArgs e)
{
Expand All @@ -51,10 +48,12 @@ private void ListTracks_Loaded(object sender, RoutedEventArgs e)
sectionAudio?.NotifyOnListUpdate();
}
catch { }

myControl.loadMore = sectionAudio.GetTracks;
if (myControl.CheckIfAllContentIsVisible()) sectionAudio.GetTracks();
}


bool connected = false;
private void ListTracks_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
{
Expand Down Expand Up @@ -85,12 +84,6 @@ private void SectionAudio_onListUpdate(object sender, EventArgs e)
}

private SectionAudio sectionAudio;






}
}

Loading

0 comments on commit 6c76639

Please sign in to comment.