Merge dev-binding -> dev-binding-album
continuous-integration/drone/push Build is passing Details

pull/28/head
Corentin LEMAIRE 2 years ago
commit c25a43c415

@ -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.AddPlaylistPage"
Title="AddPlaylistPage">
<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="Créer la playlist" BackgroundColor="green" FontSize="20" Clicked="AddPlaylist"/>
<Button Text="Annuler" BackgroundColor="red" FontSize="20" Clicked="Cancel"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</ContentPage>

@ -0,0 +1,58 @@
using Model;
using System.Collections.ObjectModel;
namespace Linaris;
public partial class AddPlaylistPage : ContentPage
{
public Playlist NewPlaylist { get; } = new Playlist();
public AddPlaylistPage()
{
InitializeComponent();
BindingContext = NewPlaylist;
}
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 async void AddPlaylist(object sender, EventArgs e)
{
if ((Application.Current as App).Manager.GetPlaylistByName(NewPlaylist.Name) != null)
{
await DisplayAlert("Erreur !", "La playlist existe déjà", "OK");
return;
}
if (string.IsNullOrWhiteSpace(NewPlaylist.Name))
{
await DisplayAlert("Erreur !", "Le nom de la playlist ne doit pas être vide !", "OK");
return;
}
(Application.Current as App).Manager.AddPlaylist(NewPlaylist);
await Navigation.PopModalAsync();
}
}

@ -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();
}
}

@ -34,7 +34,7 @@
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg"/>
<MauiIcon Include="Resources\AppIcon\appicon.svg" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
@ -73,9 +73,15 @@
</ItemGroup>
<ItemGroup>
<MauiXaml Update="AddPlaylistPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="AlbumPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="EditPlaylistPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="FooterPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -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());
}
}

@ -43,8 +43,7 @@
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
<Button WidthRequest="300" HeightRequest="50" Margin="0,20,0,20" BackgroundColor="{StaticResource Primary}" Text="Ajouter d'autres playlists" Clicked="ShowEntryPlaylist" TextColor="White"/>
<Entry WidthRequest="300" HeightRequest="50" Margin="0,20,0,20" BackgroundColor="DimGrey" Text="" Placeholder="Nom de la nouvelle playlist" Completed="CreatePlaylist" IsVisible="{Binding IsNewPlaylist}"/>
<Button WidthRequest="300" HeightRequest="50" Margin="0,20,0,20" BackgroundColor="{StaticResource Primary}" Text="Ajouter d'autres playlists" Clicked="AddPlaylist" TextColor="White"/>
</VerticalStackLayout>
</ScrollView>
<local:FooterPage Grid.Row="1" Grid.ColumnSpan="2"/>

@ -1,30 +1,13 @@
using Model;
using Model.Stub;
using System.Collections.ObjectModel;
namespace Linaris;
public partial class PlaylistsPage : ContentPage
{
private ObservableCollection<Playlist> playlists = (Application.Current as App).Manager.GetPlaylists();
public ObservableCollection<Playlist> Playlists
{
get => playlists;
}
private bool isNewPlaylist = false;
public bool IsNewPlaylist
{
get => isNewPlaylist;
set
{
isNewPlaylist = value;
OnPropertyChanged(nameof(IsNewPlaylist));
}
}
public ObservableCollection<Playlist> Playlists { get => playlists; }
public PlaylistsPage()
{
@ -37,7 +20,6 @@ public partial class PlaylistsPage : ContentPage
void ResetAll(object sender, EventArgs e)
{
ResetSubMenus(sender, e);
IsNewPlaylist = false;
}
void ResetSubMenus(object sender, EventArgs e)
@ -51,19 +33,9 @@ public partial class PlaylistsPage : ContentPage
// Add methods
void CreatePlaylist(object sender, EventArgs e)
async void AddPlaylist(object sender, EventArgs e)
{
if (sender is Entry entry)
{
if (!HasSameName(entry.Text))
{
Playlist playlist = new Playlist(entry.Text, "", "none.png");
(Application.Current as App).Manager.AddPlaylist(playlist);
playlists.Add(playlist);
IsNewPlaylist = false;
entry.Text = "";
}
}
await Navigation.PushModalAsync(new AddPlaylistPage());
}
@ -75,7 +47,6 @@ public partial class PlaylistsPage : ContentPage
{
if (button.BindingContext is Playlist playlist)
{
(Application.Current as App).Manager.RemovePlaylist(playlist);
playlists.Remove(playlist);
}
}
@ -103,11 +74,6 @@ public partial class PlaylistsPage : ContentPage
}
}
void ShowEntryPlaylist(object sender, EventArgs e)
{
IsNewPlaylist = true;
}
// Change methods
@ -133,24 +99,17 @@ public partial class PlaylistsPage : ContentPage
}
}
// Search methods
// Navigation
bool HasSameName(string name)
async void GoToPlaylist(object sender, EventArgs e)
{
foreach(Playlist playlist in playlists)
if (sender is Button button)
{
if (playlist.Name == name)
if (button.BindingContext is Playlist playlist)
{
return true;
(Application.Current as App).Manager.CurrentPlaylist = playlist;
}
}
return false;
}
// Navigation
async void GoToPlaylist(object sender, EventArgs e)
{
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);

@ -1,9 +1,11 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Model.Stub;
public class Manager
{
{
public readonly static int MAX_NAME_LENGTH = 75;
public readonly static int MAX_DESCRIPTION_LENGTH = 500;
@ -66,9 +68,9 @@ public class Manager
}
}
private Album currentAlbum;
private Album? currentAlbum;
public Album CurrentAlbum
public Album? CurrentAlbum
{
get
{
@ -80,6 +82,17 @@ public class Manager
}
}
private Playlist? currentPlaylist;
public Playlist? CurrentPlaylist
{
get => currentPlaylist;
set
{
currentPlaylist = value;
}
}
public Manager(IDataManager dataManager)
{
DataManager = dataManager;
@ -89,35 +102,42 @@ public class Manager
infoTitles = DataManager.GetInfoTitles();
playlists = DataManager.GetPlaylists();
artists = DataManager.GetArtists();
currentAlbum = albums.First();
currentAlbum = albums.FirstOrDefault();
currentPlaylist = playlists.FirstOrDefault();
}
public void AddAlbum(Album album)
{
if (GetAlbumByName(album.Name) != null) return;
DataManager.AddAlbum(album);
albums = DataManager.GetAlbums();
}
public void AddCustomTitle(CustomTitle title)
{
if (GetInfoTitleByName(title.Name) != null) return;
DataManager.AddCustomTitle(title);
customTitles = DataManager.GetCustomTitles();
}
public void AddInfoTitle(InfoTitle title)
{
if (GetInfoTitleByName(title.Name) != null) return;
DataManager.AddInfoTitle(title);
infoTitles = DataManager.GetInfoTitles();
}
public void AddPlaylist(Playlist playlist)
{
if (GetPlaylistByName(playlist.Name) != null) return;
DataManager.AddPlaylist(playlist);
playlists = DataManager.GetPlaylists();
}
public void AddArtist(Artist artist)
{
if (GetArtistByName(artist.Name) != null) return;
DataManager.AddArtist(artist);
artists = DataManager.GetArtists();
}
@ -186,4 +206,24 @@ public class Manager
return DataManager.GetPlaylistByName(name);
}
public Artist? GetArtistByName(string name)
{
return DataManager.GetArtistByName(name);
}
public CustomTitle? GetCustomTitleByUrl(string url)
{
return DataManager.GetCustomTitleByUrl(url);
}
public InfoTitle? GetInfoTitleByName(string name)
{
return DataManager.GetInfoTitleByName(name);
}
public Album? GetAlbumByName(string name)
{
return DataManager.GetAlbumByName(name);
}
}

@ -3,7 +3,6 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Xml.Serialization;
namespace Model;
@ -20,9 +19,9 @@ public class Playlist : INotifyPropertyChanged
set
{
if (string.IsNullOrWhiteSpace(value) || value.Length > Manager.MAX_NAME_LENGTH)
if (string.IsNullOrEmpty(value) || value.Length > Manager.MAX_NAME_LENGTH)
{
value = "IncorrectName";
return;
}
name = value;
OnPropertyChanged();

@ -108,8 +108,6 @@ public class LinqXmlSerialization : IDataManager
Directory.CreateDirectory(XMLPATH);
}
Directory.SetCurrentDirectory(XMLPATH);
SaveAlbums();
SaveInfoTitles();
LoadSerialization();
}
@ -260,7 +258,7 @@ public class LinqXmlSerialization : IDataManager
foreach(var custom in customsList)
{
CustomTitle? customTitle = GetCustomTitleByName(custom);
CustomTitle? customTitle = GetCustomTitleByUrl(custom);
if (customTitle == null)
{
@ -743,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;
}
@ -815,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