Remove Rename feature
continuous-integration/drone/push Build is passing Details

pull/27/head
Corentin LEMAIRE 2 years ago
parent 6b4916e898
commit 2ed464f7ee

@ -27,14 +27,12 @@
<TapGestureRecognizer Tapped="ShowSubMenu"/>
</Image.GestureRecognizers>
</Image>
<Label Text="{Binding Name}" Style="{StaticResource Titre}" IsVisible="{Binding IsRenaming, Converter={StaticResource InverseBooleanConverter}}" HorizontalTextAlignment="Center" WidthRequest="250" LineBreakMode="TailTruncation"/>
<Entry TextChanged="CheckNewName" Text="{Binding NewName}" Placeholder="Nouveau nom" IsVisible="{Binding IsRenaming}" Completed="RenamePlaylist"/>
<Label Text="{Binding Name}" Style="{StaticResource Titre}" HorizontalTextAlignment="Center" WidthRequest="250" LineBreakMode="TailTruncation"/>
</VerticalStackLayout>
<Grid Grid.ColumnSpan="2" BackgroundColor="Grey" HeightRequest="125" WidthRequest="155" RowDefinitions="*,*,*,*" IsVisible="{Binding IsSubMenuVisible}">
<Grid Grid.ColumnSpan="2" BackgroundColor="Grey" HeightRequest="125" WidthRequest="155" RowDefinitions="*,*,*" IsVisible="{Binding IsSubMenuVisible}">
<Button Grid.Row="0" Text="Accéder à la playlist" Clicked="GoToPlaylist"/>
<Button Grid.Row="1" Text="Supprimer" Clicked="RemovePlaylist"/>
<Button Grid.Row="2" Text="Renommer" Clicked="RenamePlaylist"/>
<Button Grid.Row="3" Text="Changer l'image" Clicked="ChangeImage"/>
</Grid>
@ -45,7 +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"/>
<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}"/>
</VerticalStackLayout>
</ScrollView>

@ -37,7 +37,6 @@ public partial class PlaylistsPage : ContentPage
void ResetAll(object sender, EventArgs e)
{
ResetSubMenus(sender, e);
ResetRenaming(sender, e);
IsNewPlaylist = false;
}
@ -49,22 +48,6 @@ public partial class PlaylistsPage : ContentPage
}
}
void ResetRenaming(object sender, EventArgs e)
{
foreach (var Playlist in playlists)
{
Playlist.IsRenaming = false;
if (!CheckRenaming(Playlist))
{
Playlist.NewName = Playlist.Name;
}
else
{
Playlist.Name = Playlist.NewName;
}
}
}
// Add methods
@ -78,6 +61,7 @@ public partial class PlaylistsPage : ContentPage
App.Manager.AddPlaylist(playlist);
playlists.Add(playlist);
IsNewPlaylist = false;
entry.Text = "";
}
}
}
@ -127,41 +111,6 @@ public partial class PlaylistsPage : ContentPage
// Change methods
void RenamePlaylist(object sender, EventArgs e)
{
ResetSubMenus(sender, e);
if (sender is Button button)
{
if (button.BindingContext is Playlist playlist)
{
if (!playlist.IsRenaming)
{
ResetRenaming(sender, e);
playlist.IsRenaming = true;
}
else
{
ResetRenaming(sender, e);
}
}
}
else if (sender is Entry entry)
{
if (entry.BindingContext is Playlist playlist)
{
if (!CheckRenaming(playlist))
{
entry.TextColor = Color.FromRgb(255,0,0);
}
else
{
ResetRenaming(sender, e);
playlist.Name = playlist.NewName;
}
}
}
}
private async void ChangeImage(object sender, EventArgs e)
{
var result = await FilePicker.PickAsync(new PickOptions
@ -197,36 +146,6 @@ public partial class PlaylistsPage : ContentPage
}
return false;
}
// Check methods
void CheckNewName(object sender, EventArgs e)
{
if (sender is Entry entry)
{
if (entry.BindingContext is Playlist playlist)
{
if (!CheckRenaming(playlist))
{
entry.TextColor = Color.FromRgb(255, 0, 0);
}
else
{
entry.TextColor = Color.FromRgb(255, 255, 255);
}
}
}
}
bool CheckRenaming(Playlist playlist)
{
if (playlist.NewName.Length > Manager.MAX_NAME_LENGTH || string.IsNullOrWhiteSpace(playlist.NewName) || HasSameName(playlist.NewName))
{
return false;
}
return true;
}
// Navigation
async void GoToPlaylist(object sender, EventArgs e)

@ -148,21 +148,6 @@ public class Playlist : INotifyPropertyChanged
private bool isSubMenuVisible;
public bool IsRenaming
{
get => isRenaming;
set
{
if (isRenaming != value)
{
isRenaming = value;
}
OnPropertyChanged();
}
}
private bool isRenaming = false;
public Playlist(string nom, string description, string imageURL)
{
Name = nom;

Loading…
Cancel
Save