pull/29/head
Matheo HERSAN 2 years ago
commit e0b1ebdb60

@ -4,12 +4,20 @@ using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.ComponentModel;
using System.Xml.Linq;
using System.Runtime.CompilerServices;
namespace MangaMap.Model namespace MangaMap.Model
{ {
[DataContract] [DataContract]
public class Oeuvre public class Oeuvre : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
[DataMember] [DataMember]
public string Nom { get; private set; } public string Nom { get; private set; }
[DataMember] [DataMember]
@ -18,8 +26,20 @@ namespace MangaMap.Model
public string Type { get; private set; } public string Type { get; private set; }
[DataMember] [DataMember]
public string Description { get; private set; } public string Description { get; private set; }
[DataMember] [DataMember]
public int Note { get; private set; } public int Note {
get => note;
set
{
if (note == value)
return;
note = value;
OnPropertyChanged();
}
}
private int note;
[DataMember] [DataMember]
public int NbEpisodes { get; private set; } public int NbEpisodes { get; private set; }
[DataMember] [DataMember]

@ -34,7 +34,7 @@
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300,40"> <Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300,40">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/> <ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/> <Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/> <Label Grid.Column="2" Text="{Binding Note}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/> <Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>

@ -1,20 +1,18 @@
namespace MangaMap.Views; namespace MangaMap.Views;
using Model; using Model;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Windows.Input; using System.Windows.Input;
using System.Xml.Linq; using System.Xml.Linq;
public partial class ficheAnime : ContentPage, INotifyPropertyChanged public partial class ficheAnime : ContentPage, INotifyPropertyChanged
{ {
public Manager my_manager => (App.Current as App).MyManager; public Manager my_manager => (App.Current as App).MyManager;
public Oeuvre AnimeModel { get; set; } public Oeuvre AnimeModel { get; set; }
public ICommand StarCommand => new Command<string>(count => SetNote(uint.Parse(count)));
public ficheAnime() public ficheAnime()
{ {
InitializeComponent(); InitializeComponent();
@ -30,7 +28,8 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = this;
SetNote();
} }
public async void AjouterListe(object sender, EventArgs e) public async void AjouterListe(object sender, EventArgs e)
@ -81,22 +80,59 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged
} }
private void SetNote(float note) private void SetNote()
{ {
note = (int)note; stars.Children.Clear();
var starImages = star.Children.OfType<Image>().Reverse().ToList();
foreach (var img in starImages) for (int i = 0; i < 5; i++)
{ {
if (note > 0) if (i < AnimeModel.Note)
{ {
img.Opacity = 1; ImageButton imageButton = new ImageButton
note--; {
Source = "star_full.png",
WidthRequest = 50,
HeightRequest = 50,
AutomationId = i.ToString(),
Margin = 10,
};
imageButton.Clicked += StarClicked;
Grid.SetRow(imageButton, 0);
Grid.SetColumn(imageButton, i);
stars.Children.Add(imageButton);
} }
else else
{ {
img.Opacity = 0; ImageButton imageButton = new ImageButton
{
Source = "star_empty.png",
WidthRequest = 50,
HeightRequest = 50,
AutomationId = i.ToString(),
Margin = 10,
};
imageButton.Clicked += StarClicked;
Grid.SetRow(imageButton, 0);
Grid.SetColumn(imageButton, i);
stars.Children.Add(imageButton);
} }
} }
} }
private async void StarClicked(object sender, EventArgs e)
{
var button = (ImageButton)sender;
var idAutomation = button.AutomationId;
if (int.TryParse(idAutomation, out int id))
{
AnimeModel.Note = id+1;
my_manager.sauvegarder();
SetNote();
}
}
} }

@ -26,13 +26,8 @@
<Label Text="{Binding AnimeModel.Genre}" BackgroundColor="{StaticResource Primary}" TextColor="White" Margin="0,0,0,30"/> <Label Text="{Binding AnimeModel.Genre}" BackgroundColor="{StaticResource Primary}" TextColor="White" Margin="0,0,0,30"/>
<HorizontalStackLayout x:Name="star"> <Grid x:Name="stars" ColumnDefinitions="80,80,80,80,80">
<Image Source="star_full.png" WidthRequest="50" HeightRequest="50" Margin="10"/> </Grid>
<Image Source="star_full.png" WidthRequest="50" HeightRequest="50" Margin="10"/>
<Image Source="star_full.png" WidthRequest="50" HeightRequest="50" Margin="10"/>
<Image Source="star_full.png" WidthRequest="50" HeightRequest="50" Margin="10"/>
<Image Source="star_empty.png" WidthRequest="50" HeightRequest="50" Margin="10"/>
</HorizontalStackLayout>
<Button Text="Ajouter à la liste" <Button Text="Ajouter à la liste"
TextColor="#FFFFFF" TextColor="#FFFFFF"

@ -18,7 +18,6 @@
BackgroundColor="#1E1E1E" BackgroundColor="#1E1E1E"
Grid.Row="1"> Grid.Row="1">
<VerticalStackLayout <VerticalStackLayout
Spacing="70"
VerticalOptions="Center"> VerticalOptions="Center">
<SearchBar Placeholder="Recherche" <SearchBar Placeholder="Recherche"
@ -47,7 +46,9 @@
<ScrollView> <ScrollView>
<Grid x:Name="grille"> <Grid x:Name="grille">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="80"/> <RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>

Loading…
Cancel
Save