Finish Playlist databinding development
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
5bb8321bfa
commit
bced09d995
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue