Finish Playlist databinding development
continuous-integration/drone/push Build is failing Details

pull/28/head^2
Corentin LEMAIRE 2 years ago
parent 5bb8321bfa
commit bced09d995

@ -26,7 +26,7 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0">
<Frame IsClippedToBounds="True" CornerRadius="75" HeightRequest="150" WidthRequest="150" HorizontalOptions="Center" VerticalOptions="Center">
<Frame IsClippedToBounds="True" CornerRadius="75" HeightRequest="150" WidthRequest="150" HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Transparent">
<Image Source="{Binding ImageURL}" Aspect="AspectFill" WidthRequest="150" HeightRequest="150" Margin="-20"/>
</Frame>
<Label Text="{Binding Name}"

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Linaris.EditPlaylistPage"
Title="EditPlaylistPage">
<VerticalStackLayout BackgroundColor="#404040">
<Frame Margin="10" CornerRadius="75" HeightRequest="150" WidthRequest="150" IsClippedToBounds="True" HorizontalOptions="Center" VerticalOptions="Center">
<Image Source="{Binding ImageURL}" Aspect="AspectFill" WidthRequest="150" HeightRequest="150" Margin="-20" IsAnimationPlaying="True">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="ChangeImage"/>
</Image.GestureRecognizers>
</Image>
</Frame>
<Entry Text="{Binding Name}" WidthRequest="300" Placeholder="Nom de la playlist" TextColor="White" Margin="0,20,0,20" VerticalOptions="Center" HorizontalOptions="Center"/>
<Entry Text="{Binding Description}" WidthRequest="300" HeightRequest="150" Placeholder="Description de la playlist" VerticalTextAlignment="Start" TextColor="White" Margin="0,20,0,20" VerticalOptions="Center" HorizontalOptions="Center"/>
<HorizontalStackLayout HorizontalOptions="Center" Margin="10" Spacing="15">
<Button Text="Modifier la playlist" BackgroundColor="green" FontSize="20" Clicked="EditPlaylist"/>
<Button Text="Annuler" BackgroundColor="red" FontSize="20" Clicked="Cancel"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</ContentPage>

@ -0,0 +1,62 @@
using Model;
using Model.Stub;
namespace Linaris;
public partial class EditPlaylistPage : ContentPage
{
private Playlist playlist;
public Playlist Playlist { get => playlist; }
public EditPlaylistPage()
{
InitializeComponent();
CopyCurrent();
BindingContext = Playlist;
}
private void CopyCurrent()
{
playlist = new Playlist();
playlist.Name = (Application.Current as App).Manager.CurrentPlaylist.Name;
playlist.Description = (Application.Current as App).Manager.CurrentPlaylist.Description;
playlist.ImageURL = (Application.Current as App).Manager.CurrentPlaylist.ImageURL;
}
private async void ChangeImage(object sender, EventArgs e)
{
var result = await FilePicker.PickAsync(new PickOptions
{
PickerTitle = "Choisissez une nouvelle image !",
FileTypes = FilePickerFileType.Images
});
if (result == null)
{
return;
}
if (sender is Image image)
{
if (image.BindingContext is Playlist playlist)
{
playlist.ImageURL = result.FullPath;
}
}
}
private void Cancel(object sender, EventArgs e)
{
Navigation.PopModalAsync();
}
private void EditPlaylist(object sender, EventArgs e)
{
(Application.Current as App).Manager.CurrentPlaylist.Name = playlist.Name;
(Application.Current as App).Manager.CurrentPlaylist.Description = playlist.Description;
(Application.Current as App).Manager.CurrentPlaylist.ImageURL = playlist.ImageURL;
Navigation.PopModalAsync();
}
}

@ -1,16 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Linaris"
x:Class="Linaris.PlaylistPage"
xmlns:avatarview="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
Title="PlaylistPage"
xmlns:local="clr-namespace:Linaris"
Title="Playlist"
Style="{StaticResource PageFlyoutTrigger}">
<Grid Style="{StaticResource GridFlyoutTrigger}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="6*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="8*"/>
<RowDefinition Height="*"/>
@ -21,75 +17,31 @@
<ScrollView Grid.Column="1"
BackgroundColor="#404040">
<VerticalStackLayout>
<SearchBar Style="{StaticResource SearchBar}"/>
<avatarview:SfAvatarView
Style="{StaticResource pdp}"
ImageSource="playlist.jpg"/>
<Label Text="Playlist 2023"
Style="{StaticResource Titre}">
</Label>
<Label Text="Description"
Style="{StaticResource SousTitre}">
</Label>
<Grid BackgroundColor="Transparent" MinimumHeightRequest="0">
<Frame IsClippedToBounds="True" CornerRadius="75" HeightRequest="150" WidthRequest="150" HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Transparent">
<Image Source="{Binding ImageURL}" Aspect="AspectFill" WidthRequest="150" HeightRequest="150" Margin="-20" IsAnimationPlaying="True"/>
</Frame>
<Label Text="{Binding Name}" Style="{StaticResource Titre}"/>
<Label Text="{Binding Description}" Style="{StaticResource SousTitre"/>
<Grid BackgroundColor="Transparent" MinimumHeightRequest="0" Margin="0,20,0,0">
<FlexLayout Direction="Row" AlignItems="Center" JustifyContent="SpaceEvenly" Wrap="Wrap">
<Button Text="Aléatoire" Style="{StaticResource PlayButton}"/>
<Button Text="Lecture" Style="{StaticResource PlayButton}"/>
<Button Text="Modifier" Style="{StaticResource PlayButton}"/>
<Button Text="Partager" Style="{StaticResource PlayButton}"/>
<Button Text="Modifier" Style="{StaticResource PlayButton}" Clicked="EditPlaylist"/>
</FlexLayout>
</Grid>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 1"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 2"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 3"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 4"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 5"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 6"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<Frame Style="{StaticResource Song}">
<Label Text="Morceau 7"
FontSize="20"
TextColor="white"
HorizontalTextAlignment="Center"/>
</Frame>
<ListView ItemsSource="{Binding Titles}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame Style="{StaticResource Song}">
<Label Text="{Binding Name}" FontSize="20" TextColor="white" HorizontalTextAlignment="Center"/>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ScrollView>
<local:FooterPage Grid.Row="1" Grid.ColumnSpan="2"/>

@ -5,5 +5,11 @@ public partial class PlaylistPage : ContentPage
public PlaylistPage()
{
InitializeComponent();
BindingContext = (Application.Current as App).Manager.CurrentPlaylist;
}
private async void EditPlaylist(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new EditPlaylistPage());
}
}

@ -103,6 +103,13 @@ public partial class PlaylistsPage : ContentPage
async void GoToPlaylist(object sender, EventArgs e)
{
if (sender is Button button)
{
if (button.BindingContext is Playlist playlist)
{
(Application.Current as App).Manager.CurrentPlaylist = playlist;
}
}
await Navigation.PushAsync(new PlaylistPage());
}
}

@ -28,7 +28,7 @@ public interface IDataManager
// Read
ObservableCollection<CustomTitle> GetCustomTitles();
CustomTitle? GetCustomTitleByName(string custom);
CustomTitle? GetCustomTitleByUrl(string custom);
ObservableCollection<InfoTitle> GetInfoTitles();
@ -50,7 +50,7 @@ public interface IDataManager
// Update
void UpdateCustomTitle(CustomTitle title, string name, string url, string info, string path);
void UpdateCustomTitleByName(string name, string newUrl, string info, string path);
void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path);
void UpdateInfoTitle(InfoTitle title, string name, string url, string info, Artist artist, string description, Genre genre);

@ -68,6 +68,17 @@ public class Manager
}
}
private Playlist? currentPlaylist;
public Playlist? CurrentPlaylist
{
get => currentPlaylist;
set
{
currentPlaylist = value;
}
}
public Manager(IDataManager dataManager)
{
DataManager = dataManager;
@ -77,6 +88,8 @@ public class Manager
infoTitles = DataManager.GetInfoTitles();
playlists = DataManager.GetPlaylists();
artists = DataManager.GetArtists();
currentPlaylist = playlists.FirstOrDefault();
}
public void AddAlbum(Album album)

@ -258,7 +258,7 @@ public class LinqXmlSerialization : IDataManager
foreach(var custom in customsList)
{
CustomTitle? customTitle = GetCustomTitleByName(custom);
CustomTitle? customTitle = GetCustomTitleByUrl(custom);
if (customTitle == null)
{
@ -741,11 +741,11 @@ public class LinqXmlSerialization : IDataManager
return null;
}
public CustomTitle? GetCustomTitleByName(string custom)
public CustomTitle? GetCustomTitleByUrl(string custom)
{
foreach(CustomTitle customTitle in customTitles)
{
if(customTitle.Name == custom)
if(customTitle.ImageURL == custom)
{
return customTitle;
}
@ -813,9 +813,9 @@ public class LinqXmlSerialization : IDataManager
title.Path = path;
}
public void UpdateCustomTitleByName(string name, string newUrl, string info, string path)
public void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path)
{
CustomTitle? title = GetCustomTitleByName(name);
CustomTitle? title = GetCustomTitleByUrl(url);
if (title != null)
{
title.Name = name;

@ -236,11 +236,11 @@ public class StubManager : IDataManager
// Doesn't do anything because it's Stubs
}
public CustomTitle? GetCustomTitleByName(string custom)
public CustomTitle? GetCustomTitleByUrl(string custom)
{
foreach (CustomTitle customTitle in StubCustomTitle.GetCustomTitles())
{
if (customTitle.Name == custom)
if (customTitle.ImageURL == custom)
{
return customTitle;
}
@ -344,9 +344,9 @@ public class StubManager : IDataManager
title.Path = path;
}
public void UpdateCustomTitleByName(string name, string newUrl, string info, string path)
public void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path)
{
CustomTitle? title = GetCustomTitleByName(name);
CustomTitle? title = GetCustomTitleByUrl(url);
if (title != null)
{
title.Name = name;

Loading…
Cancel
Save