From 9bf230641734e212504de863b7d87b40b4461378 Mon Sep 17 00:00:00 2001 From: Louis DUFOUR Date: Mon, 11 Sep 2023 23:56:34 +0200 Subject: [PATCH] Format (Front-End): Pipeline --- src/BookApp/Composants/RatingView.xaml.cs | 10 +++++++--- src/BookApp/Model/Star.cs | 3 ++- src/BookApp/Pages/DetailBook.xaml.cs | 17 +++++------------ src/BookApp/Pages/Tous.xaml.cs | 2 -- .../UseCase/RatingToStarImageConverter.cs | 12 +++++++++--- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/BookApp/Composants/RatingView.xaml.cs b/src/BookApp/Composants/RatingView.xaml.cs index 1beddf5..8e678c2 100644 --- a/src/BookApp/Composants/RatingView.xaml.cs +++ b/src/BookApp/Composants/RatingView.xaml.cs @@ -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(); diff --git a/src/BookApp/Model/Star.cs b/src/BookApp/Model/Star.cs index 92997b6..199d9c7 100644 --- a/src/BookApp/Model/Star.cs +++ b/src/BookApp/Model/Star.cs @@ -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) diff --git a/src/BookApp/Pages/DetailBook.xaml.cs b/src/BookApp/Pages/DetailBook.xaml.cs index cf28fd6..a12bbdc 100644 --- a/src/BookApp/Pages/DetailBook.xaml.cs +++ b/src/BookApp/Pages/DetailBook.xaml.cs @@ -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"; } } - } diff --git a/src/BookApp/Pages/Tous.xaml.cs b/src/BookApp/Pages/Tous.xaml.cs index 226f8df..a49d701 100644 --- a/src/BookApp/Pages/Tous.xaml.cs +++ b/src/BookApp/Pages/Tous.xaml.cs @@ -10,7 +10,5 @@ namespace BookApp InitializeComponent(); BindingContext = new TousViewModel(); } - - } } diff --git a/src/BookApp/UseCase/RatingToStarImageConverter.cs b/src/BookApp/UseCase/RatingToStarImageConverter.cs index 5f27967..d868ec0 100644 --- a/src/BookApp/UseCase/RatingToStarImageConverter.cs +++ b/src/BookApp/UseCase/RatingToStarImageConverter.cs @@ -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(); } } - }