Format (Front-End): Pipeline

pull/2/head
Louis DUFOUR 1 year ago
parent acae7d1ff0
commit 9bf2306417

@ -4,8 +4,13 @@ namespace BookApp.Composants;
public partial class RatingView : ContentView public partial class RatingView : ContentView
{ {
public static readonly BindableProperty RatingProperty = public static readonly BindableProperty RatingProperty = BindableProperty.Create(
BindableProperty.Create(nameof(Rating), typeof(Star), typeof(RatingView), default(Star), BindingMode.TwoWay); nameof(Rating),
typeof(Star),
typeof(RatingView),
default(Star),
BindingMode.TwoWay
);
public Star Rating public Star Rating
{ {
@ -13,7 +18,6 @@ public partial class RatingView : ContentView
set { SetValue(RatingProperty, value); } set { SetValue(RatingProperty, value); }
} }
public RatingView() public RatingView()
{ {
InitializeComponent(); InitializeComponent();

@ -8,8 +8,9 @@ namespace BookApp.Model
{ {
public class Star public class Star
{ {
public static int MaxStars { get; private set; } = 5; public static int MaxStars { get; private set; } = 5;
public int CurrentRating { get; private set; } public int CurrentRating { get; private set; }
public Star(int rating) public Star(int rating)
{ {
if (rating < 0 || rating > MaxStars) if (rating < 0 || rating > MaxStars)

@ -7,10 +7,6 @@ public partial class DetailBook : ContentPage
private int maxStars = 5; private int maxStars = 5;
private int currentRating = 0; private int currentRating = 0;
public DetailBook() public DetailBook()
{ {
InitializeComponent(); InitializeComponent();
@ -19,17 +15,16 @@ public partial class DetailBook : ContentPage
{ {
var star = new Image var star = new Image
{ {
Source = "empty_star.svg", // image d'une étoile vide Source = "empty_star.svg", // image d'une étoile vide
WidthRequest = 30, WidthRequest = 30,
HeightRequest = 30 HeightRequest = 30
}; };
int currentStar = i; int currentStar = i;
star.GestureRecognizers.Add(new TapGestureRecognizer star.GestureRecognizers.Add(
{ new TapGestureRecognizer { Command = new Command(() => StarTapped(currentStar)), }
Command = new Command(() => StarTapped(currentStar)), );
});
StarLayout.Children.Add(star); StarLayout.Children.Add(star);
} }
@ -38,7 +33,6 @@ public partial class DetailBook : ContentPage
BindingContext = this; BindingContext = this;
} }
private void StarTapped(int rating) private void StarTapped(int rating)
{ {
if (rating > maxStars) if (rating > maxStars)
@ -58,10 +52,9 @@ public partial class DetailBook : ContentPage
{ {
var star = (Image)StarLayout.Children[i]; var star = (Image)StarLayout.Children[i];
if (i < currentRating) if (i < currentRating)
star.Source = "filled_star.svg"; // image d'une étoile remplie star.Source = "filled_star.svg"; // image d'une étoile remplie
else else
star.Source = "empty_star.svg"; star.Source = "empty_star.svg";
} }
} }
} }

@ -10,7 +10,5 @@ namespace BookApp
InitializeComponent(); InitializeComponent();
BindingContext = new TousViewModel(); BindingContext = new TousViewModel();
} }
} }
} }

@ -14,13 +14,19 @@ namespace BookApp.UseCase
int currentRating = (int)value; int currentRating = (int)value;
int index = System.Convert.ToInt32(parameter); int index = System.Convert.ToInt32(parameter);
return index < currentRating ? "../Ressources/Images/filled_star.svg" : "../Ressources/Images/empty_star.svg"; return index < currentRating
? "../Ressources/Images/filled_star.svg"
: "../Ressources/Images/empty_star.svg";
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(
object value,
Type targetType,
object parameter,
CultureInfo culture
)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

Loading…
Cancel
Save