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>
{
[DataMember]
public string? Name
public string Name
{
get => name;
private set

@ -5,8 +5,19 @@ namespace Model
{
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; }
// 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 Game? SelectedGame { get; set; }
public User? CurrentUser { get; set; }
@ -20,6 +31,22 @@ namespace Model
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)
{
GameList.Add(game);

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

@ -29,8 +29,10 @@ public partial class AddGamePage : ContentPage
{
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));
Navigation.RemovePage(this);
await this.ShowPopupAsync(new MessagePopup(message));
await Navigation.PopModalAsync();
((App)App.Current).Manager.SaveGames();
}
// //if (_ImgPath!=null) NameEntry.Text + ".png";
// //System.IO.File.Copy(_ImgPath, /**/, true);

@ -22,11 +22,11 @@
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="500"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Source="no_cover.png"/>
<Image Source="no_cover.png" HeightRequest="490" Margin="0,10,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
@ -40,13 +40,13 @@
<Grid Grid.Row="3" Margin="10,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<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"/>
</Grid>
</Grid>
<HorizontalStackLayout x:Name="Error" Grid.Row="2">
<HorizontalStackLayout x:Name="Error" Grid.Row="2" HorizontalOptions="Center">
</HorizontalStackLayout>
</Grid>
</Grid>

@ -12,7 +12,7 @@ public partial class Create : ContentPage
private async void Creer_un_compte(object sender, EventArgs e)
{
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)
{
@ -25,6 +25,11 @@ public partial class Create : ContentPage
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 });
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 });
}
@ -32,7 +37,6 @@ public partial class Create : ContentPage
}
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();
}
}

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

@ -14,4 +14,9 @@ public partial class EntryPopup : Popup
{
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"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="500"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Image Source="no_cover.png"/>
<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 Placeholder="Username" PlaceholderColor="{StaticResource Primary}" IsPassword="False" 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">
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}"
IsPassword="False"
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>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<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="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"/>
</Grid>
</Grid>
<HorizontalStackLayout x:Name="Error" Grid.Row="2">
<HorizontalStackLayout x:Name="Error" Grid.Row="2" HorizontalOptions="Center">
</HorizontalStackLayout>
</Grid>
</Grid>

@ -12,7 +12,8 @@ public partial class LoginPage : ContentPage
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);
if (user != null)
@ -23,13 +24,20 @@ public partial class LoginPage : ContentPage
Application.Current.MainPage = new AppShell();
await Shell.Current.GoToAsync("//MainPage");
}
else Error.Children.Add(new Label { Text = "Mot de passe incorrect", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start });
else Error.Children.Add(new Label { Text = "Mot de passe incorrect",
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)

@ -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"/>
</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>
</ScrollView>
<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 IEnumerable<Game> filterdGame { get; private set; }
public MainPage()
{
InitializeComponent();
BindingContext = ((App)App.Current).Manager;
BindingContext = ((App)App.Current).Manager.FilterGames(null,null,null);
}
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)
{
await Navigation.PushAsync(new AddGamePage());
await Navigation.PushModalAsync(new AddGamePage());
}
private void SearchBar_GameChanged(object sender, TextChangedEventArgs e)
@ -31,21 +33,7 @@ public partial class MainPage : ContentPage
string GameText = Game.Text;
string Tag1Text = Tag1.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)
{
((App)App.Current).Manager.ResearchedGame.Add(game);
}
BindingContext=((App)App.Current).Manager.FilterGames(GameText, Tag1Text, Tag2Text);
}
}

@ -13,7 +13,6 @@ public partial class UserInfo : ContentView
private static void OnBindChanged(BindableObject bindable, object oldValue, object newValue)
{
var contentView = (UserInfo)bindable;
contentView.OnBindChanged((string)oldValue, (string)newValue);
}
public UserInfo()
@ -22,8 +21,8 @@ public partial class UserInfo : ContentView
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