Feat : Je sais même pas ce que j'ai fait

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 4b1b48330b
commit d2fd826cbc

@ -6,10 +6,12 @@ namespace Model
{
public IPersistance Mgrpersistance;
public ObservableCollection<Game> GameList { get;}
public User CurrentUser { get; set; }
public Manager(IPersistance persistance)
{
Mgrpersistance = persistance;
CurrentUser = new User("username", "bio", "email@email.com", "password88");
GameList = persistance.LoadGame();
if (GameList == null) { GameList = new ObservableCollection<Game>();}
}
@ -26,10 +28,6 @@ namespace Model
Mgrpersistance.SaveGame(GameList);
}
/*public void LoadGames()
{
_persistance.LoadGame();
}*/
public void SaveGames()
{
Mgrpersistance.SaveGame(GameList);

@ -1,8 +1,10 @@
using System.Text.RegularExpressions;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text.RegularExpressions;
namespace Model
{
public class User
public class User : INotifyPropertyChanged
{
public string Username
{
@ -44,23 +46,36 @@ namespace Model
get => password;
private set
{
Regex rg = new Regex("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,32}$");
if (string.IsNullOrWhiteSpace(value) || !rg.IsMatch(value)) value="Default";
password = value;
Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$");
if (string.IsNullOrWhiteSpace(value) || !rg.IsMatch(value)) return;//throw new ArgumentNullException("password");
else password = value;
}
}
private string password;
public event PropertyChangedEventHandler? PropertyChanged;
//public int Role { get; }
//private int role;
public List<Game> Followed_Games
public ObservableCollection<Game> Followed_Games
{
get;
private init;
}
/*public string UserImage
{ get => userImage;
private set
{
if (!string.IsNullOrWhiteSpace(value)) userImage = value;
else userImage = "no_cover.png";
}
}
private string userImage;*/
public User(string username, string biographie, string email, string password)
public User(/*string userImage,*/string username, string biographie, string email, string password)
{
/*if (userImage == null) UserImage="no_cover.png";
else UserImage = userImage;*/
if (username == null) Username = "Default";
else Username = username;
if (biographie == null) Biographie = "Default";
@ -69,7 +84,7 @@ namespace Model
else Email = email;
if (password == null) throw new ArgumentNullException("password");
else Password = password;
Followed_Games = new List<Game>();
Followed_Games = new ObservableCollection<Game>();
//Role = 0;
}
public void AddReview(Game game, float rate, string text)

@ -43,7 +43,7 @@
<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}"/>
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}"/>

@ -5,11 +5,12 @@ namespace Stim;
public partial class DetailledPage : ContentPage
{
public Game CurrGame { get; set; }
public DetailledPage(Game game)
{
InitializeComponent();
BindingContext = game;
CurrGame= game;
avgLabel.Text = game.Average.ToString();
AddStars(starsContainer, game.Average);
}
@ -37,4 +38,9 @@ public partial class DetailledPage : ContentPage
{
//popup add review
}
private void AddFollow(object sender, EventArgs e)
{
((App)App.Current).Manager.CurrentUser.FollowAGame(CurrGame);
}
}

@ -29,85 +29,82 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0" Margin="10,0,0,0">
<Image Source="eldenring.jpg" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<Image Source="{Binding UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<Grid HeightRequest="20">
<Grid HeightRequest="40" Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Label Text="Username"/>
<Label Text="{Binding CurrentUser.Username}"/>
</Border>
<Image Source="pen.png" Grid.Column="1" HeightRequest="64"/>
</Grid>
<Grid HeightRequest="20">
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Label Text="Username"/>
<Border Padding="0,200,0,0">
<Label Text="{Binding CurrentUser.Biographie}" HeightRequest="200"/>
</Border>
<Image Source="pen.png" Grid.Column="1" HeightRequest="64"/>
</Grid>
<Grid HeightRequest="20">
<Grid HeightRequest="40" Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Label Text="Biographie" Padding="50"/>
<Label Text="*************"/>
</Border>
<Image Source="pen.png" Grid.Column="1" HeightRequest="64"/>
</Grid>
<Grid HeightRequest="20">
<Grid HeightRequest="40" Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Label Text="*************"/>
<Border Margin="0,10,0,0">
<Label Text="{Binding CurrentUser.Email}"/>
</Border>
<Image Source="pen.png" Grid.Column="1" HeightRequest="64"/>
</Grid>
<Border Margin="0,10,0,0">
<Label Text="Adresse Mail"/>
</Border>
</VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Margin="100,0,0,0">
<Label HorizontalOptions="Center" Text="Mes suivis"/>
<Border>
<VerticalStackLayout HeightRequest="100">
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Image Source="eldenring.jpg" Grid.Column="0" HeightRequest="100"/>
</Border>
<Border Grid.Column="1">
<Label Text="Nom du Jeu"/>
</Border>
<Border Grid.Column="2">
<Label Text="X" FontSize="50"/>
</Border>
</Grid>
</VerticalStackLayout>
<ScrollView>
<Border>
<CollectionView ItemsSource="{Binding CurrentUser.Followed_Games}" SelectionMode="Single" SelectionChanged="CollectionView_SelectionChanged">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Image Source="{Binding Cover}" Grid.Column="0" HeightRequest="100"/>
</Border>
<Border Grid.Column="1">
<Label Text="{Binding Name}"/>
</Border>
<Border Grid.Column="2">
<Label Text="X" FontSize="50"/>
</Border>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Border>
</ScrollView>
</VerticalStackLayout>
</Grid>
</Grid>

@ -1,3 +1,5 @@
using Model;
namespace Stim;
public partial class ProfilPage : ContentPage
@ -5,5 +7,11 @@ public partial class ProfilPage : ContentPage
public ProfilPage()
{
InitializeComponent();
}
BindingContext = ((App)App.Current).Manager;
}
private void CollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
((App)App.Current).Manager.CurrentUser.RemoveAGame((sender as CollectionView).SelectedItem as Game);
}
}

@ -50,12 +50,12 @@ namespace Test
public void Password()
{
User user = new("username", "biographie", "adresse.mail@gmail.com", "");
Assert.Equal("Default",user.Password);
Assert.Null(user.Password);
Assert.Throws<ArgumentNullException>(() => new User("username", "biography", "adresse.mail@gmail.com", null));
User user3 = new("username", "biographie", "adresse.mail@gmail.com", "54az6e");
Assert.Equal("Default", user3.Password);
Assert.Null(user3.Password);
}
[Fact]

Loading…
Cancel
Save