-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#373 Изменить дизайн плейлистов "Какой сейчас вайб"
- Loading branch information
Showing
5 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<UserControl x:Class="MusicX.Controls.CroppedPlaylistControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:MusicX.Controls" | ||
Loaded="UserControl_Loaded" | ||
Unloaded="UserControl_Unloaded" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
|
||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<Border Cursor="Hand" MouseLeftButtonDown="OpenFullPlaylist" CornerRadius="10" Height="60" Width="300" ClipToBounds="True"> | ||
|
||
<Grid ClipToBounds="True"> | ||
|
||
<Image Stretch="UniformToFill" Source="{Binding Cover, UpdateSourceTrigger=PropertyChanged}"> | ||
<Image.Clip> | ||
<RectangleGeometry Rect="0,0,300,60" RadiusX="10" RadiusY="10"/> | ||
</Image.Clip> | ||
</Image> | ||
|
||
<TextBlock HorizontalAlignment="Left" Margin="10,0,0,0" FontSize="19" VerticalAlignment="Center" FontFamily="{StaticResource VKSansMedium}" Text="{Binding Title, UpdateSourceTrigger=PropertyChanged}"/> | ||
|
||
<Border MouseLeftButtonDown="PlayPlaylist" Background="White" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave" Opacity="0.6" HorizontalAlignment="Right" CornerRadius="9999" Margin="0,0,10,0" Height="35" Width="35"> | ||
<ui:SymbolIcon x:Name="PlayIcon" HorizontalAlignment="Center" VerticalAlignment="Center" Symbol="Play24"/> | ||
</Border> | ||
|
||
</Grid> | ||
|
||
</Border> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
using Microsoft.AppCenter.Analytics; | ||
using Microsoft.AppCenter.Crashes; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using MusicX.Core.Models; | ||
using MusicX.Core.Services; | ||
using MusicX.Services; | ||
using MusicX.Services.Player.Playlists; | ||
using MusicX.Services.Player; | ||
using MusicX.Views; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using Wpf.Ui.Controls; | ||
using System; | ||
|
||
namespace MusicX.Controls | ||
{ | ||
/// <summary> | ||
/// Логика взаимодействия для CroppedPlaylistControl.xaml | ||
/// </summary> | ||
public partial class CroppedPlaylistControl : UserControl | ||
{ | ||
|
||
public static readonly DependencyProperty TitleProperty = | ||
DependencyProperty.Register("Title", typeof(string), typeof(CroppedPlaylistControl), new PropertyMetadata(string.Empty)); | ||
|
||
public string Title | ||
{ | ||
get { return (string)GetValue(TitleProperty); } | ||
set | ||
{ | ||
SetValue(TitleProperty, value); | ||
} | ||
} | ||
|
||
public static readonly DependencyProperty CoverProperty = | ||
DependencyProperty.Register("Cover", typeof(string), typeof(CroppedPlaylistControl), new PropertyMetadata(string.Empty)); | ||
|
||
public string Cover | ||
{ | ||
get { return (string)GetValue(CoverProperty); } | ||
set | ||
{ | ||
SetValue(CoverProperty, value); | ||
} | ||
} | ||
|
||
public static readonly DependencyProperty PlaylistProperty = | ||
DependencyProperty.Register("Playlist", typeof(Playlist), typeof(CroppedPlaylistControl), new PropertyMetadata(new Playlist())); | ||
|
||
public Playlist Playlist | ||
{ | ||
get { return (Playlist)GetValue(PlaylistProperty); } | ||
set | ||
{ | ||
SetValue(PlaylistProperty, value); | ||
} | ||
} | ||
|
||
public CroppedPlaylistControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private bool _nowPlay = false; | ||
|
||
private void Border_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) | ||
{ | ||
if(sender is Border border) | ||
{ | ||
border.Opacity = 1; | ||
} | ||
} | ||
|
||
private void Border_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) | ||
{ | ||
if (sender is Border border) | ||
{ | ||
border.Opacity = 0.6; | ||
} | ||
} | ||
|
||
private void OpenFullPlaylist(object sender, System.Windows.Input.MouseButtonEventArgs e) | ||
{ | ||
var notificationService = StaticService.Container.GetRequiredService<NavigationService>(); | ||
|
||
notificationService.OpenExternalPage(new PlaylistView(Playlist)); | ||
} | ||
|
||
private async void PlayPlaylist(object sender, System.Windows.Input.MouseButtonEventArgs e) | ||
{ | ||
e.Handled = true; | ||
try | ||
{ | ||
var properties = new Dictionary<string, string> | ||
{ | ||
#if DEBUG | ||
{ "IsDebug", "True" }, | ||
#endif | ||
{"Version", StaticService.Version } | ||
}; | ||
Analytics.TrackEvent("PlayPlaylistWithButton", properties); | ||
|
||
var playerService = StaticService.Container.GetRequiredService<PlayerService>(); | ||
|
||
if (!_nowPlay) | ||
{ | ||
_nowPlay = true; | ||
|
||
PlayIcon.Symbol = SymbolRegular.Timer24; | ||
var vkService = StaticService.Container.GetRequiredService<VkService>(); | ||
|
||
await playerService.PlayAsync( | ||
new VkPlaylistPlaylist(vkService, new(Playlist.Id, Playlist.OwnerId, Playlist.AccessKey))); | ||
|
||
PlayIcon.Symbol = SymbolRegular.Pause24; | ||
|
||
} | ||
else | ||
{ | ||
playerService.Pause(); | ||
PlayIcon.Symbol = SymbolRegular.Play24; | ||
|
||
_nowPlay = false; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
||
var properties = new Dictionary<string, string> | ||
{ | ||
#if DEBUG | ||
{ "IsDebug", "True" }, | ||
#endif | ||
{"Version", StaticService.Version } | ||
}; | ||
Crashes.TrackError(ex, properties); | ||
} | ||
} | ||
|
||
private void UserControl_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
var player = StaticService.Container.GetRequiredService<PlayerService>(); | ||
player.CurrentPlaylistChanged += PlayerOnCurrentPlaylistChanged; | ||
} | ||
|
||
private void UserControl_Unloaded(object sender, RoutedEventArgs e) | ||
{ | ||
var player = StaticService.Container.GetRequiredService<PlayerService>(); | ||
player.CurrentPlaylistChanged -= PlayerOnCurrentPlaylistChanged; | ||
} | ||
|
||
private void PlayerOnCurrentPlaylistChanged(object? sender, EventArgs e) | ||
{ | ||
if (sender is not PlayerService service) | ||
return; | ||
|
||
if (service.CurrentPlaylist is VkPlaylistPlaylist { Data: { } data } && data.PlaylistId == Playlist.Id) | ||
{ | ||
_nowPlay = true; | ||
PlayIcon.Symbol = SymbolRegular.Pause24; | ||
} | ||
else | ||
{ | ||
_nowPlay = false; | ||
PlayIcon.Symbol = SymbolRegular.Play24; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters