parent
ca5debb924
commit
5df7c6edb8
Binary file not shown.
@ -1,54 +1,73 @@
|
|||||||
using CommunityToolkit.Maui.Behaviors;
|
using CommunityToolkit.Maui.Behaviors;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace PocketBook;
|
namespace PocketBook
|
||||||
|
|
||||||
public partial class Stars : ContentView
|
|
||||||
{
|
{
|
||||||
public static readonly BindableProperty NbStarsProperty =
|
public partial class Stars : ContentView
|
||||||
BindableProperty.Create(nameof(NbStars), typeof(int), typeof(Stars), defaultValue: 0, propertyChanged: OnNbStarsChanged);
|
|
||||||
|
|
||||||
public int NbStars
|
|
||||||
{
|
{
|
||||||
get { return (int)GetValue(NbStarsProperty); }
|
public static readonly BindableProperty NombreEtoileProperty =
|
||||||
set { SetValue(NbStarsProperty, value); }
|
BindableProperty.Create(nameof(NombreEtoile), typeof(int), typeof(Stars), defaultValue: 0, propertyChanged: OnNbStarsChanged);
|
||||||
}
|
|
||||||
|
|
||||||
public Stars()
|
public int NombreEtoile
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
get => (int)GetValue(NombreEtoileProperty);
|
||||||
}
|
set => SetValue(NombreEtoileProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnNbStarsChanged(BindableObject bindable, object oldValue, object newValue)
|
public Stars()
|
||||||
{
|
|
||||||
if (bindable is Stars stars)
|
|
||||||
{
|
{
|
||||||
stars.UpdateStars();
|
InitializeComponent();
|
||||||
|
InitializeStars();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateStars()
|
private void InitializeStars()
|
||||||
{
|
{
|
||||||
int z = 0;
|
var behaviorGrey = new IconTintColorBehavior
|
||||||
|
{
|
||||||
|
TintColor = Color.FromArgb("#E6E6E6"),
|
||||||
|
};
|
||||||
|
|
||||||
var behaviorYellow = new IconTintColorBehavior
|
foreach (Image i in StarsList.Children.OfType<Image>())
|
||||||
|
{
|
||||||
|
i.Behaviors.Add(behaviorGrey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnNbStarsChanged(BindableObject bindable, object oldValue, object newValue)
|
||||||
{
|
{
|
||||||
TintColor = Color.FromArgb("#FFFF00"),
|
if (bindable is Stars stars)
|
||||||
};
|
{
|
||||||
|
stars.UpdateStars();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var behaviorGrey = new IconTintColorBehavior
|
private void UpdateStars()
|
||||||
{
|
{
|
||||||
TintColor = Color.FromArgb("#E6E6E6"),
|
int z = 0;
|
||||||
};
|
|
||||||
|
|
||||||
|
var behaviorGrey = new IconTintColorBehavior
|
||||||
|
{
|
||||||
|
TintColor = Color.FromArgb("#E6E6E6"),
|
||||||
|
};
|
||||||
|
|
||||||
foreach (Image i in StarsList.Children.Where(c => c is Image))
|
var behaviorYellow = new IconTintColorBehavior
|
||||||
{
|
{
|
||||||
if (z < NbStars)
|
TintColor = Color.FromArgb("#FFFF00"),
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (Image i in StarsList.Children.OfType<Image>())
|
||||||
{
|
{
|
||||||
i.Behaviors.Add(behaviorYellow);
|
if (z < NombreEtoile)
|
||||||
|
{
|
||||||
|
i.Behaviors.Add(behaviorYellow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i.Behaviors.Add(behaviorGrey);
|
||||||
|
}
|
||||||
z++;
|
z++;
|
||||||
}
|
}
|
||||||
else i.Behaviors.Add(behaviorGrey);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue