Merge branch 'master' of https://codefirst.iut.uca.fr/git/jade.van_brabandt/Projet_IHM
continuous-integration/drone/push Build was killed Details

Popup_qui_marche_pas
Anthony RICHARD 2 years ago
commit 03b4d2f20e

@ -10,7 +10,7 @@ namespace Model
public class Game : INotifyPropertyChanged, IEquatable<Game> public class Game : INotifyPropertyChanged, IEquatable<Game>
{ {
[DataMember] [DataMember]
public string? Name public string Name
{ {
get => name; get => name;
private set private set

@ -5,8 +5,19 @@ namespace Model
{ {
public class Manager public class Manager
{ {
private IPersistance Mgrpersistance { get; set; } public IPersistance Mgrpersistance
{
get { return mgrpersistance; }
set { mgrpersistance = value; }
}
private IPersistance mgrpersistance;
public ObservableCollection<Game> GameList { get; set; } public ObservableCollection<Game> GameList { get; set; }
// dégage ça
// fait une méthode qui te renvoie une liste filtrer avec les params (genre ton nom :D)
// Quand t'ajoute peut être que dasn un certains monde
// il y aura pas le pb car c'est le retour d'une collection Obs
// donc potentiellement si les astres sont alignés ça devrait la mettre à jour
public ObservableCollection<Game> ResearchedGame { get; set; } public ObservableCollection<Game> ResearchedGame { get; set; }
public Game? SelectedGame { get; set; } public Game? SelectedGame { get; set; }
public User? CurrentUser { get; set; } public User? CurrentUser { get; set; }
@ -20,6 +31,22 @@ namespace Model
Users = persistance.LoadUser(); Users = persistance.LoadUser();
} }
public IEnumerable<Game> FilterGames(string? filterName, string? filterTag1, string? filterTag2)
{
IEnumerable<Game> retList;
retList = GameList;
if (filterName != null) retList = retList
.Where(game => game.Name.IndexOf(filterName, StringComparison.OrdinalIgnoreCase) >= 0
);
if (filterTag1 != null) retList = retList
.Where(game => game.Tags.Any(tag => tag.IndexOf(filterTag1, StringComparison.OrdinalIgnoreCase) >= 0)
);
if (filterTag2 != null) retList = retList
.Where(game => game.Tags.Any(tag => tag.IndexOf(filterTag2, StringComparison.OrdinalIgnoreCase) >= 0)
);
return retList;
}
public void AddGametoGamesList(Game game) public void AddGametoGamesList(Game game)
{ {
GameList.Add(game); GameList.Add(game);

@ -122,8 +122,9 @@ namespace Model
return other != null && Username.Equals(other.Username); return other != null && Username.Equals(other.Username);
} }
public override int GetHashCode() public override int GetHashCode()
{ {
return Username.GetHashCode(); if (Username!=null) return Username.GetHashCode();
return 0;
} }
public void AddReview(Game game, float rate, string text) public void AddReview(Game game, float rate, string text)

@ -29,8 +29,10 @@ public partial class AddGamePage : ContentPage
{ {
message = "Jeu ajouté !"; 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)); ((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text));
Navigation.RemovePage(this); await this.ShowPopupAsync(new MessagePopup(message));
await Navigation.PopModalAsync();
((App)App.Current).Manager.SaveGames(); ((App)App.Current).Manager.SaveGames();
} }
// //if (_ImgPath!=null) NameEntry.Text + ".png"; // //if (_ImgPath!=null) NameEntry.Text + ".png";
// //System.IO.File.Copy(_ImgPath, /**/, true); // //System.IO.File.Copy(_ImgPath, /**/, true);

@ -22,11 +22,11 @@
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1"> <Grid Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="500"/>
<RowDefinition Height="*"/> <RowDefinition Height="auto"/>
<RowDefinition Height="4*"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Source="no_cover.png"/> <Image Source="no_cover.png" HeightRequest="490" Margin="0,10,0,0"/>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
@ -40,13 +40,13 @@
<Grid Grid.Row="3" Margin="10,0,0,10"> <Grid Grid.Row="3" Margin="10,0,0,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Text="Se connecter" Clicked="Se_connecter" HeightRequest="50" BackgroundColor="{StaticResource Gray500}"/> <Button Text="Se connecter" Clicked="Se_connecter" HeightRequest="50" BackgroundColor="{StaticResource Gray500}"/>
<Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/> <Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/>
</Grid> </Grid>
</Grid> </Grid>
<HorizontalStackLayout x:Name="Error" Grid.Row="2"> <HorizontalStackLayout x:Name="Error" Grid.Row="2" HorizontalOptions="Center">
</HorizontalStackLayout> </HorizontalStackLayout>
</Grid> </Grid>
</Grid> </Grid>

@ -1,38 +1,42 @@
using Microsoft.Maui.Graphics; using Microsoft.Maui.Graphics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Stim; namespace Stim;
public partial class Create : ContentPage public partial class Create : ContentPage
{ {
public Create() public Create()
{ {
InitializeComponent(); InitializeComponent();
} }
private async void Creer_un_compte(object sender, EventArgs e) private async void Creer_un_compte(object sender, EventArgs e)
{ {
Error.Clear(); Error.Clear();
if (!string.IsNullOrWhiteSpace(Username.Text) && !string.IsNullOrWhiteSpace(Pswd.Text) && !string.IsNullOrWhiteSpace(Email.Text)) if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text) || !string.IsNullOrWhiteSpace(Email.Text))
{ {
if (((App)App.Current).Manager.SearchUser(Username.Text) == null) if (((App)App.Current).Manager.SearchUser(Username.Text) == null)
{ {
Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$"); Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$");
if (rg.IsMatch(Pswd.Text)) if (rg.IsMatch(Pswd.Text))
{ {
((App)App.Current).Manager.AddUsertoUserList(new("", Username.Text, "", Email.Text, Pswd.Text)); ((App)App.Current).Manager.AddUsertoUserList(new("", Username.Text, "", Email.Text, Pswd.Text));
((App)App.Current).Manager.CurrentUser = ((App)App.Current).Manager.SearchUser(Username.Text); ((App)App.Current).Manager.CurrentUser = ((App)App.Current).Manager.SearchUser(Username.Text);
Application.Current.MainPage = new AppShell(); Application.Current.MainPage = new AppShell();
await Shell.Current.GoToAsync("//MainPage"); await Shell.Current.GoToAsync("//MainPage");
} }
else Error.Children.Add(new Label { Text = "Mot de passe invalide, votre mot de passe doit contenir une Majuscule, une minuscule, un chiffre et faire au moins 8 caractères", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); else Error.Children.Add(new Label { Text = "Mot de passe invalide, votre mot de passe doit contenir une Majuscule, une minuscule, un chiffre et faire au moins 8 caractères", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
rg = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$");
/*if ( rg.IsMatch )
{
}*/
} }
else Error.Children.Add(new Label { Text = "Ce nom d'utilisateur est déjà pris", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); else Error.Children.Add(new Label { Text = "Ce nom d'utilisateur est déjà pris", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
} }
else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
} }
private void Se_connecter(object sender, EventArgs e) private void Se_connecter(object sender, EventArgs e)
{ {
//Ca ça marche pas faut une autre commande, Marc svp aide moi Application.Current.MainPage = new LoginPage();
Application.Current.MainPage = new LoginPage(); }
}
} }

@ -3,11 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Stim.EntryPopup" x:Class="Stim.EntryPopup"
CanBeDismissedByTappingOutsideOfPopup="False"> CanBeDismissedByTappingOutsideOfPopup="False">
<VerticalStackLayout>
<Grid ColumnDefinitions="*" RowDefinitions="auto, auto, auto"> <Grid ColumnDefinitions="*" RowDefinitions="auto, auto, auto,auto">
<Label x:Name="LabelTxt"/> <Label x:Name="LabelTxt"/>
<Entry Grid.Row="1"/> <Entry Grid.Row="1" x:Name="Entrytxt"/>
<Button Grid.Row="2" x:Name="Entrytxt" Text="Valider" HorizontalOptions="Center" VerticalOptions="End" Background="{StaticResource Transparent}" Clicked="CloseButton"/> <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"/>
</Grid> </Grid>
</VerticalStackLayout>
</toolkit:Popup> </toolkit:Popup>

@ -14,4 +14,9 @@ public partial class EntryPopup : Popup
{ {
if (!string.IsNullOrWhiteSpace(Entrytxt.Text)) Close(Entrytxt.Text); if (!string.IsNullOrWhiteSpace(Entrytxt.Text)) Close(Entrytxt.Text);
} }
private void Valider(object sender, EventArgs e)
{
}
} }

@ -22,30 +22,47 @@
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1"> <Grid Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="500"/>
<RowDefinition Height="*"/> <RowDefinition Height="auto"/>
<RowDefinition Height="4*"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Source="no_cover.png"/> <Image Source="no_cover.png" HeightRequest="490" Margin="0,10,0,0"/>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}" IsPassword="False" x:Name="Username" HeightRequest="50" ClearButtonVisibility="WhileEditing"/> <Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}"
<Entry Placeholder="Mot de passe" PlaceholderColor="{StaticResource Primary}" IsPassword="True" x:Name="Pswd" HeightRequest="50" Grid.Row="1" ClearButtonVisibility="WhileEditing"/> IsPassword="False"
<Grid Grid.Row="2" Margin="10,0,0,10"> x:Name="Username"
HeightRequest="50"
ClearButtonVisibility="WhileEditing"/>
<Entry Placeholder="Mot de passe"
PlaceholderColor="{StaticResource Primary}"
IsPassword="True" x:Name="Pswd"
HeightRequest="50"
Grid.Row="1"
ClearButtonVisibility="WhileEditing"/>
<Grid Grid.Row="2"
Margin="10,0,0,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Text="Se connecter" Clicked="Se_connecter" HeightRequest="50" BackgroundColor="{StaticResource Gray500}"/> <Button Text="Se connecter"
<Button Text="Créer un compte" Clicked="Creer_un_compte" HeightRequest="50" BackgroundColor="{StaticResource Gray500}" Grid.Column="1"/> Clicked="Se_connecter"
HeightRequest="50"
BackgroundColor="{StaticResource Gray500}"/>
<Button Text="Créer un compte"
Clicked="Creer_un_compte"
HeightRequest="50"
BackgroundColor="{StaticResource Gray500}"
Grid.Column="1"/>
</Grid> </Grid>
</Grid> </Grid>
<HorizontalStackLayout x:Name="Error" Grid.Row="2"> <HorizontalStackLayout x:Name="Error" Grid.Row="2" HorizontalOptions="Center">
</HorizontalStackLayout> </HorizontalStackLayout>
</Grid> </Grid>
</Grid> </Grid>

@ -12,7 +12,8 @@ public partial class LoginPage : ContentPage
private async void Se_connecter(object sender, EventArgs e) private async void Se_connecter(object sender, EventArgs e)
{ {
if (!string.IsNullOrWhiteSpace(Username.Text) && !string.IsNullOrWhiteSpace(Pswd.Text)) Error.Clear();
if (!string.IsNullOrWhiteSpace(Username.Text) || !string.IsNullOrWhiteSpace(Pswd.Text))
{ {
User user = ((App)App.Current).Manager.SearchUser(Username.Text); User user = ((App)App.Current).Manager.SearchUser(Username.Text);
if (user != null) if (user != null)
@ -23,13 +24,20 @@ public partial class LoginPage : ContentPage
Application.Current.MainPage = new AppShell(); Application.Current.MainPage = new AppShell();
await Shell.Current.GoToAsync("//MainPage"); await Shell.Current.GoToAsync("//MainPage");
} }
else Error.Children.Add(new Label { Text = "Mot de passe incorrect",
else Error.Children.Add(new Label { Text = "Mot de passe incorrect", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); TextColor = Colors.Red,
VerticalTextAlignment = TextAlignment.Start,
HorizontalTextAlignment = TextAlignment.Start });
} }
else Error.Children.Add(new Label { Text = "Information incorrecte", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); else Error.Children.Add(new Label { Text = "Information incorrecte",
TextColor = Colors.Red,
VerticalTextAlignment = TextAlignment.Start,
HorizontalTextAlignment = TextAlignment.Start});
} }
else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); else Error.Children.Add(new Label { Text = "Champs vides",
TextColor = Colors.Red,
VerticalTextAlignment = TextAlignment.Start,
HorizontalTextAlignment=TextAlignment.Start});
} }
private void Creer_un_compte(object sender, EventArgs e) private void Creer_un_compte(object sender, EventArgs e)

@ -39,7 +39,7 @@
<SearchBar x:Name="Tag2" TextChanged="SearchBar_GameChanged" Grid.Column="1" Grid.Row="1" Placeholder="Tag 2" WidthRequest="200" HorizontalOptions="Start" 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> </Grid>
<CollectionView ItemsSource="{Binding ResearchedGame}" SelectionMode="Single" SelectionChanged="OnClickGameList" ItemsLayout="VerticalGrid, 5" Grid.Column="1" Grid.Row="1" ItemTemplate="{StaticResource gameTemplate}"/> <CollectionView ItemsSource="{Binding}" SelectionMode="Single" SelectionChanged="OnClickGameList" ItemsLayout="VerticalGrid, 5" Grid.Column="1" Grid.Row="1" ItemTemplate="{StaticResource gameTemplate}"/>
</Grid> </Grid>
</ScrollView> </ScrollView>
<ImageButton Source="add_white.png" Background="transparent" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="End" Margin="0, 0, 10, 10" Clicked="GoToAddGamePage"/> <ImageButton Source="add_white.png" Background="transparent" WidthRequest="50" HeightRequest="50" HorizontalOptions="End" VerticalOptions="End" Margin="0, 0, 10, 10" Clicked="GoToAddGamePage"/>

@ -9,10 +9,12 @@ using System.Collections.Generic;
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
public IEnumerable<Game> filterdGame { get; private set; }
public MainPage() public MainPage()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = ((App)App.Current).Manager; BindingContext = ((App)App.Current).Manager.FilterGames(null,null,null);
} }
private async void OnClickGameList(object sender, EventArgs e) private async void OnClickGameList(object sender, EventArgs e)
@ -23,7 +25,7 @@ public partial class MainPage : ContentPage
private async void GoToAddGamePage(object sender, EventArgs e) private async void GoToAddGamePage(object sender, EventArgs e)
{ {
await Navigation.PushAsync(new AddGamePage()); await Navigation.PushModalAsync(new AddGamePage());
} }
private void SearchBar_GameChanged(object sender, TextChangedEventArgs e) private void SearchBar_GameChanged(object sender, TextChangedEventArgs e)
@ -31,21 +33,7 @@ public partial class MainPage : ContentPage
string GameText = Game.Text; string GameText = Game.Text;
string Tag1Text = Tag1.Text; string Tag1Text = Tag1.Text;
string Tag2Text = Tag2.Text; string Tag2Text = Tag2.Text;
((App)App.Current).Manager.ResearchedGame.Clear();
IEnumerable<Game> filteredGames = ((App)App.Current).Manager.GameList;
if (GameText!=null) filteredGames = filteredGames
.Where(game => game.Name.IndexOf(GameText, StringComparison.OrdinalIgnoreCase) >= 0
);
if (Tag1Text != null) filteredGames = filteredGames
.Where(game => game.Tags.Any(tag => tag.IndexOf(Tag1Text, StringComparison.OrdinalIgnoreCase) >= 0)
);
if (Tag2Text != null) filteredGames = filteredGames
.Where(game => game.Tags.Any(tag => tag.IndexOf(Tag2Text, StringComparison.OrdinalIgnoreCase) >= 0)
);
foreach (var game in filteredGames) BindingContext=((App)App.Current).Manager.FilterGames(GameText, Tag1Text, Tag2Text);
{
((App)App.Current).Manager.ResearchedGame.Add(game);
}
} }
} }

@ -13,7 +13,6 @@ public partial class UserInfo : ContentView
private static void OnBindChanged(BindableObject bindable, object oldValue, object newValue) private static void OnBindChanged(BindableObject bindable, object oldValue, object newValue)
{ {
var contentView = (UserInfo)bindable; var contentView = (UserInfo)bindable;
contentView.OnBindChanged((string)oldValue, (string)newValue);
} }
public UserInfo() public UserInfo()
@ -22,8 +21,8 @@ public partial class UserInfo : ContentView
BindingContext = ((App)App.Current).Manager; BindingContext = ((App)App.Current).Manager;
} }
private void OnBindChanged(string oldValue, string newValue) private void Button_Clicked(object sender, EventArgs e)
{ {
// Réagissez aux changements de la propriété de liaison ici
} }
} }

Loading…
Cancel
Save