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 static readonly BindableProperty RatingProperty =
BindableProperty.Create(nameof(Rating), typeof(Star), typeof(RatingView), default(Star), BindingMode.TwoWay);
public static readonly BindableProperty RatingProperty = BindableProperty.Create(
nameof(Rating),
typeof(Star),
typeof(RatingView),
default(Star),
BindingMode.TwoWay
);
public Star Rating
{
@ -13,7 +18,6 @@ public partial class RatingView : ContentView
set { SetValue(RatingProperty, value); }
}
public RatingView()
{
InitializeComponent();

@ -8,8 +8,9 @@ namespace BookApp.Model
{
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 Star(int rating)
{
if (rating < 0 || rating > MaxStars)

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

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

@ -14,13 +14,19 @@ namespace BookApp.UseCase
int currentRating = (int)value;
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();
}
}
}

Loading…
Cancel
Save