Merge
continuous-integration/drone/push Build was killed Details

Popup_qui_marche_pas
BelsethUwU 2 years ago
commit bc1129c003

@ -12,9 +12,15 @@ namespace StimPersistance
[ExcludeFromCodeCoverage]
public class Persistance : IPersistance
{
public Persistance(string chemin)
private const string gameFileName = "games.xml";
private const string userFileName = "users.xml";
private readonly string fullGamePath;
private readonly string fullUserPath;
public Persistance(string path)
{
Directory.SetCurrentDirectory(chemin);
fullGamePath = Path.Combine(path, gameFileName);
fullUserPath = Path.Combine(path, userFileName);
}
public void SaveGame(List<Game> games)
@ -22,7 +28,7 @@ namespace StimPersistance
XmlWriterSettings settings = new() { Indent = true };
DataContractSerializer serializer = new(typeof(List<Game>));
using (TextWriter tw = File.CreateText("games.xml"))
using (TextWriter tw = File.CreateText(fullGamePath))
using (XmlWriter writer = XmlWriter.Create(tw, settings)) serializer.WriteObject(writer, games);
}
@ -31,26 +37,26 @@ namespace StimPersistance
XmlWriterSettings settings = new() { Indent = true };
DataContractSerializer serializer = new(typeof(HashSet<User>));
using (TextWriter tw = File.CreateText("users.xml"))
using (TextWriter tw = File.CreateText(fullUserPath))
using (XmlWriter writer = XmlWriter.Create(tw, settings)) serializer.WriteObject(writer, users);
}
public List<Game> LoadGame()
{
if (File.Exists("games.xml"))
if (File.Exists(fullGamePath))
{
DataContractSerializer serializer = new(typeof(List<Game>));
using (Stream stream = File.OpenRead("games.xml")) return serializer.ReadObject(stream) as List<Game> ?? new();
using (Stream stream = File.OpenRead(fullGamePath)) return serializer.ReadObject(stream) as List<Game> ?? new();
}
return new();
}
public HashSet<User> LoadUser()
{
if (File.Exists("users.xml"))
if (File.Exists(fullUserPath))
{
DataContractSerializer serializer = new(typeof(HashSet<User>));
using (Stream stream = File.OpenRead("users.xml")) return serializer.ReadObject(stream) as HashSet<User> ?? new();
using (Stream stream = File.OpenRead(fullUserPath)) return serializer.ReadObject(stream) as HashSet<User> ?? new();
}
return new();
}

@ -15,15 +15,12 @@ namespace Model
get => name;
private set
{
if (string.IsNullOrWhiteSpace(value)) name="Default";
else
{
name = value;
if (string.IsNullOrWhiteSpace(value)) name = "Default";
else name = value;
NotifyPropertyChanged();
}
}
}
private string name;
private string name = default!;
[DataMember]
public string Description
@ -31,15 +28,12 @@ namespace Model
get => description;
private set
{
if (string.IsNullOrWhiteSpace(value)) return;
else
{
description = value;
if (string.IsNullOrWhiteSpace(value)) description = "Defaut";
else description = value;
NotifyPropertyChanged();
}
}
}
private string description;
private string description = default!;
[DataMember]
public int Year
@ -47,15 +41,12 @@ namespace Model
get => year;
private set
{
if (value < 1957 || value > 2023) return;
else
{
year = value;
if (value < 1957 || value > 2023) year = 2023;
else year = value;
NotifyPropertyChanged();
}
}
}
private int year;
private int year = default!;
[DataMember]
public string Cover
@ -63,15 +54,12 @@ namespace Model
get => cover;
private set
{
if (string.IsNullOrWhiteSpace(value)) cover="no_cover.png";
else
{
cover = value;
if (string.IsNullOrWhiteSpace(value)) cover = "no_cover.png";
else cover = value;
NotifyPropertyChanged();
}
}
}
private string cover;
private string cover = default!;
[DataMember]
public ObservableCollection<string> Tags
@ -79,40 +67,29 @@ namespace Model
get => tags;
private set
{
if (value == null || value.Count > 3) return;
else
{
tags = value;
if (value == null || value.Count > 3) tags = new ObservableCollection<string>();
else tags = value;
NotifyPropertyChanged();
}
}
}
private ObservableCollection<string> tags;
[DataMember]
public List<Review> Reviews { get; private init; }
public double Average => AverageCalc();
public double AverageCalc()
{
if (Reviews.Count > 0) return Math.Round((double)Reviews.Select(review => review.Rate).Average(), 1);
else return 0;
}
public double Average => Reviews.Any() ? Math.Round(Reviews.Select(review => review.Rate).Average(), 1) : 0;
[DataMember]
public string Lien {
get => lien;
private set
{
if (string.IsNullOrWhiteSpace(value)) return;
else
{
lien = value;
if (string.IsNullOrWhiteSpace(value)) lien = "Pas de lien";
else lien = value;
NotifyPropertyChanged();
}
}
}
private string lien;
private string lien = default!;
public Game(string name, string description, int year, List<string> c_tags, string cover, string c_lien)
{
@ -133,12 +110,7 @@ namespace Model
public event PropertyChangedEventHandler? PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public override int GetHashCode()
{

@ -6,9 +6,9 @@ namespace Model
{
public class Manager
{
private readonly IPersistance mgrpersistance;
public IReadOnlyList<Game> GameList => gameList.AsReadOnly();
private List<Game> gameList;
public readonly IPersistance mgrpersistance;
public ReadOnlyCollection<Game> GameList { get; private set; }
private readonly List<Game> gameList;
public Game? SelectedGame { get; set; }
public User? CurrentUser { get; set; }
public HashSet<User> Users { get; private set; }
@ -17,38 +17,40 @@ namespace Model
{
mgrpersistance = persistance;
gameList = persistance.LoadGame();
GameList = new ReadOnlyCollection<Game>(gameList);
Users = persistance.LoadUser();
}
public IEnumerable<Game> FilterGames(string? filterName, string? filterTag1, string? filterTag2)
{
IEnumerable<Game> retList;
retList = GameList;
retList = gameList;
if (filterName != null) retList = retList
.Where(game => game.Name.IndexOf(filterName, StringComparison.OrdinalIgnoreCase) >= 0
.Where(game => game.Name.Contains(filterName, StringComparison.OrdinalIgnoreCase)
);
if (filterTag1 != null) retList = retList
.Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.IndexOf(filterTag1, StringComparison.OrdinalIgnoreCase) >= 0)
.Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.Contains(filterTag1, StringComparison.OrdinalIgnoreCase))
);
if (filterTag2 != null) retList = retList
.Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.IndexOf(filterTag2, StringComparison.OrdinalIgnoreCase) >= 0)
.Where(game => game.Tags != null && game.Tags.Any(tag => tag != null && tag.Contains(filterTag2, StringComparison.OrdinalIgnoreCase))
);
return retList;
}
public void AddGametoGamesList(Game game)
{
gameList.Add(game);
if (!gameList.Contains(game)) gameList.Add(game);
mgrpersistance.SaveGame(gameList);
}
public void AddUsertoUserList(User user)
{
Users.Add(user);
if (!Users.Contains(user)) Users.Add(user);
mgrpersistance.SaveUser(Users);
}
public void RemoveGameFromGamesList(Game game)
{
SelectedGame = null;
gameList.Remove(game);
mgrpersistance.SaveGame(gameList);
}

@ -1,21 +1,24 @@
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace Model
{
[DataContract]
public class Review
public class Review :INotifyPropertyChanged
{
[DataMember]
public float Rate
public double Rate
{
get => rate;
private set
{
if (value < 0 || value > 5) return;
rate = value;
if (value < 0 || value > 5) rate = 0;
else rate = value;
NotifyPropertyChanged();
}
}
private float rate;
private double rate;
[DataMember]
public string? Text
@ -23,16 +26,21 @@ namespace Model
get => text;
private set
{
if (string.IsNullOrWhiteSpace(value)) return;
text = value;
if (string.IsNullOrWhiteSpace(value)) text = "Default";
else text = value;
NotifyPropertyChanged();
}
}
private string? text;
public event PropertyChangedEventHandler? PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
[DataMember]
public string AuthorName { get; set; }
public Review(string username, float rate, string text)
public Review(string username, double rate, string text)
{
AuthorName = username;
Rate = rate;
@ -48,7 +56,7 @@ namespace Model
{
if (!string.IsNullOrWhiteSpace(text)) Text = text+" (Modifié)";
}
public void EditRate(float newval)
public void EditRate(double newval)
{
Rate= newval;
}

@ -11,35 +11,41 @@ namespace Model
public sealed class User : INotifyPropertyChanged , IEquatable<User>
{
[DataMember]
public string Username
public string UserImage
{
get => userImage;
private set
{
if (!string.IsNullOrWhiteSpace(value)) userImage = value;
else userImage = "no_cover.png";
NotifyPropertyChanged();
}
}
private string userImage = default!;
[DataMember]
public string? Username
{
get => username;
set
{
if (string.IsNullOrWhiteSpace(value)) username = "Default";
else
{
username = value;
else username = value;
NotifyPropertyChanged();
}
}
}
private string username;
private string username=default!;
[DataMember]
public string Biographie
{
get => biographie ?? "Pas de biographie";
set
get => biographie;
private set
{
if (string.IsNullOrWhiteSpace(value)) biographie = "Pas de biographie";
else
{
biographie = value;
else biographie = value;
NotifyPropertyChanged();
}
}
}
private string biographie;
private string biographie = default!;
[DataMember]
public string Email
{
@ -55,7 +61,7 @@ namespace Model
else email = "Default";
}
}
private string email;
private string email = default!;
[DataMember]
public string Password
{
@ -71,17 +77,12 @@ namespace Model
}
}
}
private string password;
private string password = default!;
public event PropertyChangedEventHandler? PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
[DataMember]
public ObservableCollection<Game> Followed_Games
@ -89,17 +90,6 @@ namespace Model
get;
private init;
}
[DataMember]
public string? UserImage
{
get => userImage;
private set
{
if (!string.IsNullOrWhiteSpace(value)) userImage = value;
else userImage = "no_cover.png";
}
}
private string? userImage;
public User(string userImage,string username, string biographie, string email, string password)
{
@ -111,7 +101,7 @@ namespace Model
else Biographie = biographie;
if (email == null) Email = "Default";
else Email = email;
if (password == null) throw new ArgumentNullException("password");
if (password == null) throw new ArgumentNullException(nameof(password));
else Password = password;
Followed_Games = new ObservableCollection<Game>();
}
@ -120,6 +110,15 @@ namespace Model
if (string.IsNullOrWhiteSpace(Username)) return false;
return other != null && Username.Equals(other.Username);
}
public override bool Equals(object? obj)
{
if (obj == null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return this.Equals((User)obj);
}
public override int GetHashCode()
{
if (Username!=null) return Username.GetHashCode();
@ -152,14 +151,6 @@ namespace Model
Followed_Games.Remove(game);
}
public override bool Equals(object? obj)
{
if (obj == null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return this.Equals((User)obj);
}
public override string ToString()
{
StringBuilder builder = new();

@ -5,6 +5,7 @@
x:Class="Stim.AddGamePage"
Title="Ajouter un jeu"
Background="{StaticResource Secondary}">
<ScrollView>
<Grid>
<Grid.ColumnDefinitions>
@ -23,9 +24,9 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="0"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0"/>
<VerticalStackLayout Background="{StaticResource Tertiary}" Grid.Column="1" Grid.RowSpan="7"/>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="4"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="4"/>
<VerticalStackLayout Grid.Column="1">
<Label Text="Nom" FontSize="30" HorizontalOptions="Center"/>
@ -41,7 +42,6 @@
</VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Grid.Row="3" Padding="0,150,0,0">
<Label Text="Jaquette" FontSize="30" HorizontalOptions="Center"/>
<!-- Please faut commenter quand y'a des trucs à implémenter ou alors faire un ticket-->
<Button Margin="5" Clicked="Button_Clicked"/>
</VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Grid.Row="4" Padding="0,150,0,0">

@ -21,19 +21,19 @@ public partial class AddGamePage : ContentPage
string message = "";
if (string.IsNullOrEmpty(NameEntry.Text)) message += "Nom invalide\n";
if (string.IsNullOrEmpty(DescriptionEntry.Text)) message += "Description invalide\n";
if (string.IsNullOrEmpty(YearEntry.Text) || !int.TryParse(YearEntry.Text, out year)) message += "Année invalide\n";
if (string.IsNullOrEmpty(YearEntry.Text) || !int.TryParse(YearEntry.Text, out year) || year < 1957 || year > 2023) message += "Année invalide\n";
if (string.IsNullOrEmpty(LinkEntry.Text)) message += "Lien invalide\n";
if (!string.IsNullOrEmpty(NameEntry.Text) && !string.IsNullOrEmpty(DescriptionEntry.Text) && !string.IsNullOrEmpty(YearEntry.Text) && int.TryParse(YearEntry.Text, out year) && !string.IsNullOrWhiteSpace(LinkEntry.Text) /*|| _ImgPath is null*/)
if (message == "" && int.TryParse(YearEntry.Text, out year))
{
Game game = new(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text);
if ((App.Current as App).Manager.GameList.Contains(game)) message = "Jeu déjà existant\n";
else
{
message = "Jeu ajouté !";
((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text));
await this.ShowPopupAsync(new MessagePopup(message));
await Navigation.PopModalAsync();
((App)App.Current).Manager.SaveGames();
((App)App.Current).Manager.AddGametoGamesList(game);
await Navigation.PopAsync();
}
}
// //if (_ImgPath!=null) NameEntry.Text + ".png";
// //System.IO.File.Copy(_ImgPath, /**/, true);
await this.ShowPopupAsync(new MessagePopup(message));
}

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Stim"
x:Class="Stim.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@ -15,65 +16,48 @@
</DataTemplate>
<DataTemplate x:Key="gameTemplate">
<Border MinimumWidthRequest="200" Margin="10, 10, 10, 10">
<Grid HeightRequest="635">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Source="{Binding Cover}" Aspect="AspectFit" Margin="0,0,0,0" WidthRequest="900" HeightRequest="455"/>
<Label FontAttributes="Bold" FontSize="30" Text="{Binding Name}" Grid.Row="1" HorizontalTextAlignment="Center"/>
<Grid HeightRequest="635" RowDefinitions="auto, auto, auto">
<Image Source="{Binding Cover, FallbackValue='no_cover.png'}" Aspect="AspectFit" Margin="0,0,0,0" WidthRequest="900" HeightRequest="455"/>
<Label FontAttributes="Bold" FontSize="30" Text="{Binding Name, FallbackValue='Default'}" Grid.Row="1" HorizontalTextAlignment="Center"/>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="2" ColumnDefinitions="*, auto" RowDefinitions="auto, auto">
<Label Text="Tags :" Margin="0" Padding="0"/>
<CollectionView ItemsSource="{Binding Tags}" Grid.Row="1" Margin="0" ItemTemplate="{StaticResource tagsTemplate}"/>
<Label Text="{Binding Year}" Grid.Row="1" Grid.Column="2" HorizontalTextAlignment="End" VerticalTextAlignment="End"/>
<Label Text="{Binding Year, FallbackValue='2023'}" Grid.Row="1" Grid.Column="2" HorizontalTextAlignment="End" VerticalTextAlignment="End"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="reviewTemplate">
<Border Margin="0, 5">
<VerticalStackLayout>
<HorizontalStackLayout> <!--BindingContextChanged="AddStars"-->
<Label Text="{Binding AuthorName}" FontSize="20"/>
</HorizontalStackLayout>
<Label Text="{Binding Text}"/>
<Grid ColumnDefinitions="auto, *">
<Label Text="{Binding AuthorName, FallbackValue='Default'}" FontSize="20"/>
<local:StarsContainer Rate="{Binding Rate, FallbackValue='0'}" Grid.Column="2"/>
</Grid>
<Label Text="{Binding Text, FallbackValue='Default'}"/>
</VerticalStackLayout>
</Border>
</DataTemplate>
<DataTemplate x:Key="followTemplate">
<Border HeightRequest="150" Margin="10">
<Grid ColumnDefinitions="auto,*,3*,auto" RowDefinitions="*">
<Image Source="{Binding Cover}"/>
<Label Grid.Column="1" Text="{Binding Name}" FontSize="50"/>
<Grid ColumnDefinitions="auto, *, 3*, auto" RowDefinitions="*">
<Image Source="{Binding Cover, FallbackValue='no_cover.png'}"/>
<Label Grid.Column="1" Text="{Binding Name, FallbackValue='Default'}" FontSize="50"/>
<ScrollView Grid.Column="2">
<Label Text="{Binding Description}"/>
<Label Text="{Binding Description, FallbackValue='Default'}"/>
</ScrollView>
<CollectionView Grid.Column="3" ItemsSource="{Binding Tags}" Grid.Row="1" Margin="0" ItemTemplate="{StaticResource tagsTemplate}" HorizontalOptions="End"/>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="followLoginTemplate">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Margin="10" ColumnDefinitions="*, 5*, *">
<Border>
<Image Source="{Binding Cover}" Grid.Column="0" HeightRequest="100"/>
<Image Source="{Binding Cover, FallbackValue='no_cover.png'}" Grid.Column="0" HeightRequest="100"/>
</Border>
<Border Grid.Column="1">
<Label Text="{Binding Name}"/>
<Label Text="{Binding Name, FallbackValue='Default'}"/>
</Border>
<Border Grid.Column="2">
<Label Text="X" FontSize="50"/>

@ -8,34 +8,18 @@ namespace Stim;
public partial class App : Application
{
public Manager Manager { get; set; }
public App()
{
InitializeComponent();
MainPage = new LoginPage();
if (File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, "games.xml"))) Manager = new Manager(new Persistance(FileSystem.Current.AppDataDirectory));
else Manager = new(new Stub());
MainPage = new NavigationPage(new LoginPage());
Manager = new(new Persistance(FileSystem.Current.AppDataDirectory));
if (!File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, "games.xml"))) FirstStart();
}
protected override Window CreateWindow(IActivationState activationState)
{
Window window = base.CreateWindow(activationState);
window.Stopped += (s, e) =>
private void FirstStart()
{
if (!(File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, "games.xml"))))
{
Manager Manager2 = new(new Persistance(FileSystem.Current.AppDataDirectory));
foreach (var game in Manager.GameList) Manager2.AddGametoGamesList(game);
foreach (var user in Manager.Users) Manager2.AddUsertoUserList(user);
Manager2.SaveGames();
Manager2.SaveUser();
}
else
{
Manager.SaveGames();
Manager.SaveUser();
}
};
return window;
Manager mgrtmp = new(new Stub());
foreach (var game in mgrtmp.GameList) Manager.AddGametoGamesList(game);
}
}

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Stim.ConfirmationPopup"
CanBeDismissedByTappingOutsideOfPopup="False">
<Grid RowDefinitions="*, *" ColumnDefinitions="*, *">
<Label Grid.ColumnSpan="2" x:Name="placeholder" Style="{StaticResource popupLabel}"/>
<Button Grid.Row="2" Style="{StaticResource popupButton}" Text="Non" Clicked="No"/>
<Button Grid.Row="2" Grid.Column="2" Style="{StaticResource popupButton}" Text="Oui" Clicked="Yes"/>
</Grid>
</toolkit:Popup>

@ -0,0 +1,17 @@
using CommunityToolkit.Maui.Views;
namespace Stim;
public partial class ConfirmationPopup : Popup
{
public ConfirmationPopup(string message)
{
InitializeComponent();
placeholder.Text = message;
}
public void Yes(object sender, EventArgs e)
=> Close(true);
public void No(object sender, EventArgs e)
=> Close(false);
}

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Stim.Create"
Title="Create">
<ScrollView>
<Grid BackgroundColor="{StaticResource Tertiary}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -16,10 +17,10 @@
</Grid.RowDefinitions>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="500"/>
@ -50,4 +51,5 @@
</HorizontalStackLayout>
</Grid>
</Grid>
</ScrollView>
</ContentPage>

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Stim"
x:Class="Stim.DetailledPage"
Title="{Binding Name}"
Title="{Binding Name, FallbackValue='Default'}"
Background="{StaticResource Secondary}">
<Grid>
@ -10,65 +11,37 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ScrollView>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="0"/>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="2"/>
<Grid Background="{StaticResource Tertiary}" Grid.Column="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Grid.RowSpan="4" Margin="5, 0, 0, 0" Source="{Binding Cover}" Aspect="AspectFit"/>
<Label Grid.Column="1" Text="{Binding Name}" FontSize="30"/>
<Label Grid.Column="2" Text="{Binding Year}" HorizontalOptions="Center"/>
<Button Grid.Column="3" Margin="10" Text="Suivre" HorizontalOptions="Center"
VerticalOptions="Center" Background="transparent" CornerRadius="0" BorderWidth="3" BorderColor="{StaticResource Secondary}" Clicked="AddFollow"/>
<ScrollView Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="1">
<Label Text="{Binding Description}"/>
<Grid ColumnDefinitions="*, 10*, *">
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2"/>
<Grid Background="{StaticResource Tertiary}" Grid.Column="1" ColumnDefinitions="*, *, *, *" RowDefinitions="auto, *, auto, auto, auto">
<Image Grid.RowSpan="4" Margin="5, 0, 0, 0" Source="{Binding Cover, FallbackValue='no_cover.png'}" Aspect="AspectFit"/>
<Label Grid.Column="1" Text="{Binding Name, FallbackValue='Default'}" FontSize="30"/>
<Label Grid.Column="2" Text="{Binding Year, FallbackValue='2023'}" HorizontalOptions="Center"/>
<ImageButton Grid.Column="3" Style="{StaticResource removeButton}" Clicked="RemoveGame" HorizontalOptions="Start"/>
<Button Grid.Column="4" Style="{StaticResource followButton}" Clicked="AddFollow"/>
<ScrollView Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="1">
<Label Text="{Binding Description, FallbackValue='Default'}"/>
</ScrollView>
<Grid Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="2" RowDefinitions="auto, auto">
<Label Text="Tags :"/>
<CollectionView Grid.Row="1" ItemsSource="{Binding Tags}" ItemTemplate="{StaticResource tagsTemplate}"/>
</Grid>
<Label Grid.Column="1" Grid.Row="3" Text="{Binding Lien}"/>
<HorizontalStackLayout Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="3" x:Name="starsContainer" HorizontalOptions="End">
<Label Padding="0,5,0,0" FontSize="25" Text="{Binding Average}"/>
</HorizontalStackLayout>
<Label Grid.Column="1" Grid.Row="3" Text="{Binding Lien, FallbackValue='Default'}"/>
<local:StarsContainer Rate="{Binding Average, FallbackValue='0'}" Grid.Column="4" Grid.Row="3"/>
<VerticalStackLayout Grid.ColumnSpan="4" Grid.Row="4">
<Label Text="Avis de la communauté :" FontSize="30"/>
<CollectionView ItemsSource="{Binding Reviews}" ItemTemplate="{StaticResource reviewTemplate}"/>
</VerticalStackLayout>
</Grid>
</Grid>
</ScrollView>
<ImageButton Source="add_white.png" Background="transparent" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="End" Margin="0, 0, 10, 10" Clicked="AddReview"/>
<ImageButton Style="{StaticResource addButton}" Clicked="AddReview"/>
</Grid>
</ContentPage>

@ -6,33 +6,11 @@ namespace Stim;
public partial class DetailledPage : ContentPage
{
private Game currentGame;
public DetailledPage()
{
InitializeComponent();
currentGame = (App.Current as App).Manager.SelectedGame;
BindingContext = currentGame;
if (currentGame is null) Navigation.PopAsync();
else
{
AddStars(starsContainer, currentGame.Average);
}
}
public void AddStars(object sender, EventArgs e)
{
HorizontalStackLayout layout = sender as HorizontalStackLayout;
Review rev = layout.BindingContext as Review;
AddStars(layout, rev.Rate);
}
public static void AddStars(HorizontalStackLayout container, double rate)
{
for (int i = 0; i < (int)rate; i++) container.Children.Add(new Image { Source = "etoile_pleine.png", WidthRequest = 30 });
if ((int)rate != rate) container.Children.Add(new Image { Source = "etoile_mi_pleine.png", WidthRequest = 30 });
while (container.Children.Count != 6) container.Children.Add(new Image { Source = "etoile_vide.png", WidthRequest = 30 });
BindingContext = (App.Current as App).Manager.SelectedGame;
if ((App.Current as App).Manager.SelectedGame is null) Navigation.RemovePage(this);
}
private async void GoToMainPage(object sender, EventArgs e)
@ -51,12 +29,12 @@ public partial class DetailledPage : ContentPage
foreach (Game game in ((App)App.Current).Manager.CurrentUser.Followed_Games)
{
if (game == null) throw new Exception();
else if (currentGame == game) { flag = true; break; }
else if ((App.Current as App).Manager.SelectedGame == game) { flag = true; break; }
}
if (!flag)
{
await this.ShowPopupAsync(new MessagePopup("Jeu ajouté dans les suivis !"));
((App)App.Current).Manager.CurrentUser.FollowAGame(currentGame);
((App)App.Current).Manager.CurrentUser.FollowAGame((App.Current as App).Manager.SelectedGame);
}
else
{
@ -64,20 +42,14 @@ public partial class DetailledPage : ContentPage
}
}
protected override void OnNavigatedFrom(NavigatedFromEventArgs args)
private async void RemoveGame(object sender, EventArgs e)
{
Navigation.PopAsync();
base.OnNavigatedFrom(args);
}
protected override void OnDisappearing()
var res = await this.ShowPopupAsync(new ConfirmationPopup("Voulez-vous vraiment supprimer " + (App.Current as App).Manager.SelectedGame.Name + " ?"));
if (res != null && res is bool && (bool)res)
{
Navigation.PopAsync();
base.OnDisappearing();
(App.Current as App).Manager.RemoveGameFromGamesList((App.Current as App).Manager.SelectedGame);
await Navigation.PopAsync();
await this.ShowPopupAsync(new MessagePopup("Jeu supprimé !"));
}
protected override void OnAppearing()
{
base.OnAppearing();
}
}

@ -0,0 +1,29 @@
using System.Globalization;
namespace Stim.Converter
{
public class DoubleToStar : IValueConverter
{
public string EtoileVide { get; set; }
public string EtoileMiPleine { get; set; }
public string EtoilePleine { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is double && parameter is string)
{
double rate = double.Parse(value.ToString());
int pos = int.Parse(parameter as string);
if (pos <= rate) return EtoilePleine;
if (pos - 1 < rate && rate < pos) return EtoileMiPleine;
}
return EtoileVide;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -4,13 +4,11 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Stim.EntryPopup"
CanBeDismissedByTappingOutsideOfPopup="False">
<VerticalStackLayout>
<Grid ColumnDefinitions="*" RowDefinitions="auto, auto, auto,auto">
<Label x:Name="LabelTxt"/>
<Entry Grid.Row="1" x:Name="Entrytxt"/>
<Button Grid.Row="2" Text="Valider" HorizontalOptions="Center" VerticalOptions="End" Background="{StaticResource Transparent}" Clicked="Valider"/>
<Button Grid.Row="3" Text="Annuler" HorizontalOptions="Center" VerticalOptions="End" Background="{StaticResource Transparent}" Clicked="CloseButton"/>
<HorizontalStackLayout x:Name="Error"></HorizontalStackLayout>
<Grid ColumnDefinitions="*" RowDefinitions="*, *, *, *">
<Label x:Name="placeholder" Style="{StaticResource popupLabel}"/>
<Entry Grid.Row="1" x:Name="Entrytxt" VerticalOptions="Center" HorizontalOptions="Center"/>
<Button Grid.Row="2" Text="Valider" Style="{StaticResource popupButton}" Clicked="Valider"/>
<Button Grid.Row="3" Text="Annuler" Style="{StaticResource popupButton}" Clicked="CloseButton"/>
</Grid>
</VerticalStackLayout>
</toolkit:Popup>

@ -7,7 +7,7 @@ public partial class EntryPopup : Popup
public EntryPopup(string fieldName)
{
InitializeComponent();
LabelTxt.Text = fieldName;
placeholder.Text = fieldName;
}
public void CloseButton(object sender, EventArgs e)

@ -4,21 +4,9 @@
x:Class="Stim.FollowPage"
Title="Suivis">
<ScrollView>
<Grid BackgroundColor="#495057">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid BackgroundColor="#495057" ColumnDefinitions="*, 5*, *" RowDefinitions="auto, *">
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.RowSpan="2"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.RowSpan="2"/>
<CollectionView ItemsSource="{Binding Followed_Games}" SelectionMode="Single" Grid.Column="1" SelectionChanged="GoToDetail" ItemTemplate="{StaticResource followTemplate}"/>
</Grid>
</ScrollView>

@ -15,4 +15,9 @@ public partial class FollowPage : ContentPage
(App.Current as App).Manager.SelectedGame = (sender as CollectionView).SelectedItem as Game;
await Navigation.PushAsync(new DetailledPage());
}
protected override void OnAppearing()
{
base.OnAppearing();
}
}

@ -3,56 +3,31 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Stim.LoginPage"
Title="LoginPage">
<Grid BackgroundColor="{StaticResource Tertiary}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollView>
<Grid BackgroundColor="{StaticResource Tertiary}" ColumnDefinitions="*, 5*, *" RowDefinitions="auto, *">
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="500"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Column="1" RowDefinitions="500, auto, auto">
<Image Source="no_cover.png" HeightRequest="490" Margin="0,10,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Entry Text="Bel"
Placeholder="Username" PlaceholderColor="{StaticResource Primary}"
<Grid Grid.Row="1" RowDefinitions="auto, auto, auto">
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}"
IsPassword="False"
x:Name="Username"
HeightRequest="50"
ClearButtonVisibility="WhileEditing"/>
<Entry Text="BelBel1*"
Placeholder="Mot de passe"
ClearButtonVisibility="WhileEditing"
Text="anthony"/>
<Entry Placeholder="Mot de passe"
PlaceholderColor="{StaticResource Primary}"
IsPassword="True" x:Name="Pswd"
HeightRequest="50"
Grid.Row="1"
ClearButtonVisibility="WhileEditing"/>
ClearButtonVisibility="WhileEditing"
Text="anthony5"/>
<Grid Grid.Row="2"
Margin="10,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
Margin="10,0,0,10" ColumnDefinitions="3*, *">
<Button Text="Se connecter"
Clicked="Se_connecter"
HeightRequest="50"
@ -68,4 +43,5 @@
</HorizontalStackLayout>
</Grid>
</Grid>
</ScrollView>
</ContentPage>

@ -22,7 +22,7 @@ public partial class LoginPage : ContentPage
{
((App)App.Current).Manager.CurrentUser = user;
Application.Current.MainPage = new AppShell();
await Shell.Current.GoToAsync("//MainPage");
await Navigation.PushModalAsync(new MainPage());//Shell.Current.GoToAsync("//MainPage");
}
else Error.Children.Add(new Label { Text = "Mot de passe incorrect",
TextColor = Colors.Red,

@ -6,42 +6,20 @@
Background="{StaticResource Secondary}">
<Grid>
<ScrollView>
<Grid BackgroundColor="{StaticResource Tertiary}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="0"/>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="2"/>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout BackgroundColor="{StaticResource Secondary}" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid BackgroundColor="{StaticResource Tertiary}" ColumnDefinitions="*, 10*, *" RowDefinitions="auto, *">
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1" ColumnDefinitions="*, *" RowDefinitions="auto, auto">
<SearchBar x:Name="Game" TextChanged="SearchBar_GameChanged" Grid.ColumnSpan="2" Placeholder="Rechercher un jeu" Margin="5"/>
<SearchBar x:Name="Tag1" TextChanged="SearchBar_GameChanged" Grid.Column="0" Grid.Row="1" Placeholder="Tag 1" WidthRequest="200" HorizontalOptions="End" Margin="5"/>
<SearchBar x:Name="Tag2" TextChanged="SearchBar_GameChanged" Grid.Column="1" Grid.Row="1" Placeholder="Tag 2" WidthRequest="200" HorizontalOptions="Start" Margin="5"/>
</Grid>
<CollectionView ItemsSource="{Binding}" SelectionMode="Single" SelectionChanged="OnClickGameList" ItemsLayout="VerticalGrid, 5" Grid.Column="1" Grid.Row="1" ItemTemplate="{StaticResource gameTemplate}"/>
</Grid>
</ScrollView>
<ImageButton Source="add_white.png" Background="transparent" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="End" Margin="0, 0, 10, 10" Clicked="GoToAddGamePage"/>
<ImageButton Style="{StaticResource addButton}" Clicked="Addgame"/>
</Grid>
</ContentPage>

@ -23,9 +23,9 @@ public partial class MainPage : ContentPage
await Navigation.PushAsync(new DetailledPage());
}
private async void GoToAddGamePage(object sender, EventArgs e)
private async void Addgame(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new AddGamePage());
await Navigation.PushAsync(new AddGamePage());
}
private void SearchBar_GameChanged(object sender, TextChangedEventArgs e)
@ -36,9 +36,13 @@ public partial class MainPage : ContentPage
BindingContext=((App)App.Current).Manager.FilterGames(GameText, Tag1Text, Tag2Text);
}
protected override void OnAppearing()
{
SearchBar_GameChanged(null,null);
Game.Text = "";
Tag1.Text = "";
Tag2.Text = "";
SearchBar_GameChanged(null, null);
base.OnAppearing();
}
}

@ -5,8 +5,8 @@
x:Class="Stim.MessagePopup"
CanBeDismissedByTappingOutsideOfPopup ="False">
<Grid RowDefinitions="auto, auto" ColumnDefinitions="*">
<Label x:Name="placeholder" Text="" HorizontalOptions="Center"/>
<Button Grid.Row="1" Text="Fermer" HorizontalOptions="Center" VerticalOptions="End" Background="{StaticResource Transparent}" Clicked="CloseButton"/>
<Grid RowDefinitions="*, *" ColumnDefinitions="*">
<Label x:Name="placeholder" Style="{StaticResource popupLabel}"/>
<Button Grid.Row="1" Text="Fermer" Style="{StaticResource popupButton}" Clicked="CloseButton"/>
</Grid>
</toolkit:Popup>

@ -6,12 +6,11 @@
Title="Profil">
<ScrollView>
<Grid BackgroundColor="#495057">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid BackgroundColor="#495057" ColumnDefinitions="*, 5*, *" RowDefinitions="auto, *">
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout Style="{StaticResource pageBorder}" Grid.Column="2" Grid.Row="1"/>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

@ -385,4 +385,64 @@
<Setter Property="SelectedTabColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray200}}" />
</Style>
<!-- Styles ajoutés-->
<Style TargetType="Label" x:Key="popupLabel">
<Setter Property="Text" Value=""/>
<Setter Property="FontSize" Value="30"/>
<Setter Property="HorizontalOptions" Value="Center"/>
<Setter Property="VerticalOptions" Value="Center"/>
</Style>
<Style TargetType="Button" x:Key="followButton">
<Setter Property="Text" Value="Suivre"/>
<Setter Property="Background" Value="{StaticResource Transparent}"/>
<Setter Property="HorizontalOptions" Value="Center"/>
<Setter Property="VerticalOptions" Value="Center"/>
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="BorderWidth" Value="3"/>
<Setter Property="BorderColor" Value="{StaticResource Secondary}"/>
<Setter Property="Margin" Value="10"/>
</Style>
<Style TargetType="Button" x:Key="popupButton">
<Setter Property="FontSize" Value="30"/>
<Setter Property="BorderColor" Value="{StaticResource Secondary}"/>
<Setter Property="BorderWidth" Value="2"/>
<Setter Property="HorizontalOptions" Value="Center"/>
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Background" Value="{StaticResource Transparent}"/>
</Style>
<Style TargetType="ImageButton" x:Key="addButton">
<Setter Property="Source" Value="add_white.png"/>
<Setter Property="Background" Value="{StaticResource Transparent}"/>
<Setter Property="WidthRequest" Value="50"/>
<Setter Property="HeightRequest" Value="50"/>
<Setter Property="HorizontalOptions" Value="End"/>
<Setter Property="VerticalOptions" Value="End"/>
<Setter Property="Margin" Value="0, 0, 10, 10"/>
</Style>
<Style TargetType="ImageButton" x:Key="removeButton">
<Setter Property="Source" Value="remove_red.png"/>
<Setter Property="Background" Value="{StaticResource Transparent}"/>
<Setter Property="WidthRequest" Value="50"/>
<Setter Property="HeightRequest" Value="50" />
<Setter Property="VerticalOptions" Value="Center"/>
<Setter Property="HorizontalOptions" Value="Center"/>
</Style>
<Style TargetType="Image" x:Key="star">
<Setter Property="Background" Value="{StaticResource Transparent}"/>
<Setter Property="HeightRequest" Value="30"/>
<Setter Property="WidthRequest" Value="30" />
</Style>
<Style TargetType="VerticalStackLayout" x:Key="pageBorder">
<Setter Property="Background" Value="{StaticResource Secondary}"/>
</Style>
</ResourceDictionary>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:conv="clr-namespace:Stim.Converter"
x:Class="Stim.StarsContainer"
x:Name="StarsContainerView">
<ContentView.Resources>
<conv:DoubleToStar x:Key="DoubleToStar" EtoilePleine="etoile_pleine.png" EtoileMiPleine="etoile_mi_pleine.png" EtoileVide="etoile_vide.png"/>
</ContentView.Resources>
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" BindingContext="{x:Reference StarsContainerView}">
<Label Text="{Binding Rate, FallbackValue='0', StringFormat='{0}/5'}" FontSize="20"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='1'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='2'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='3'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='4'}"/>
<Image Style="{StaticResource star}" Source="{Binding Rate, FallbackValue='0', Converter={StaticResource DoubleToStar}, ConverterParameter='5'}"/>
</HorizontalStackLayout>
</ContentView>

@ -0,0 +1,18 @@
namespace Stim;
public partial class StarsContainer : ContentView
{
public static readonly BindableProperty RateProperty =
BindableProperty.Create(nameof(Rate), typeof(double), typeof(StarsContainer), double.NaN);
public double Rate
{
get => (double)GetValue(StarsContainer.RateProperty);
set => SetValue(StarsContainer.RateProperty, value);
}
public StarsContainer()
{
InitializeComponent();
}
}

@ -80,6 +80,9 @@
<MauiXaml Update="AddGamePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="ConfirmationPopup.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="DetailledPage - Copier.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
@ -98,6 +101,9 @@
<MauiXaml Update="MessagePopup.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="StarsContainer.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="UserInfo.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -7,11 +7,11 @@ namespace StimStub
[ExcludeFromCodeCoverage]
public class Stub : IPersistance
{
public List<Game> Games = new();
public List<Game> Games { get; set; }
public Stub()
{
Games = LoadGame();
Games = LoadGame() ?? new();
}
public void SaveGame(List<Game> games)

@ -51,10 +51,10 @@ namespace Test
{
Game game = new("name", "description", 1111, new List<String> {"1","2","3"}, "cover", "www.link.com");
Assert.Equal(0, game.Year);
Assert.Equal(2023, game.Year);
Game game2 = new("name", "description", 9999, new List<String> {"1","2","3"}, "cover", "www.link.com");
Assert.Equal(0, game2.Year);
Assert.Equal(2023, game2.Year);
Game game3 = new("name", "description", 2012, new List<String> {"1","2","3"}, "cover", "www.link.com");
Assert.Equal(2012, game3.Year);

@ -121,7 +121,8 @@ namespace Test
compListAsList = compList.ToList();
compListAsList.Clear();
compList = compListAsList; list = manager.FilterGames("Elden Ring", "Action", "Solo");
compList = compListAsList;
list = manager.FilterGames("Elden Ring", "Action", "Solo");
foreach (var game in manager.GameList)
{
if (game.Name=="Elden Ring" && game.Tags.Any(tag => tag == "Action" && game.Tags.Any(tag => tag == "Solo")))
@ -133,6 +134,31 @@ namespace Test
}
}
Assert.Equal(compList, list);
list = manager.FilterGames(null, "Action", "Solo");
compListAsList = compList.ToList();
compListAsList.Clear();
compList = compListAsList;
compList = compListAsList; list = manager.FilterGames("Elden Ring", "Action", null);
foreach (var game in manager.GameList)
{
if (game.Name == "Elden Ring" && game.Tags.Any(tag => tag == "Action"))
{
compListAsList = compList.ToList();
compListAsList.Add(game);
compList = compListAsList;
break;
}
}
Assert.Equal(compList, list);
}
[Fact]
public void Search()
{
IPersistance persistance = new Stub();
Manager manager = new(persistance);
User user = new(null, "username", "biographie", "adresse.mail@gmail.com", "Azerty123*");
manager.AddUsertoUserList(user);
Assert.Equal(user, manager.SearchUser("username"));
}
}
}

@ -25,8 +25,8 @@ namespace Test
{
Review rev = new("User 1", 3, "");
Review rev2 = new("User 2", 3, null);
Assert.Null(rev.Text);
Assert.Null(rev2.Text);
Assert.Equal("Default", rev.Text);
Assert.Equal("Default", rev2.Text);
}
[Fact]
@ -58,9 +58,9 @@ namespace Test
{
Review rev = new("User 1", 3, "rev");
rev.EditRate(-2);
Assert.Equal(3, rev.Rate);
Assert.Equal(0, rev.Rate);
rev.EditRate(18);
Assert.Equal(3, rev.Rate);
Assert.Equal(0, rev.Rate);
rev.EditRate(4.5f);
Assert.Equal(4.5f, rev.Rate);
}

@ -108,5 +108,10 @@ namespace Test
Assert.False(user.Equals(user4 as object));
Assert.False(user.Equals(user2 as object));
}
[Fact]
public void Hashcode()
{
User user = new("userimage", "username", "biographie", "adresse.mail@gmail.com", "Azerty123*");
}
}
}

Loading…
Cancel
Save