Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
commit 7e08de53bd

@ -1,4 +1,5 @@
using Model;
using Microsoft.VisualBasic;
using Model;
using StimPersistance;
using StimStub;
using System.Diagnostics.CodeAnalysis;
@ -10,9 +11,7 @@ namespace AppConsole
{
static void Main(string[] args)
{
Manager stub = new(new Stub());
Manager persistance = new(new Persistance("../../../../"));
persistance.Mgrpersistance.SaveGame(stub.GameList);
Console.WriteLine("");
}
}
}

@ -19,20 +19,16 @@ namespace Model
// 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 User CurrentUser { get; set; }
public Game? SelectedGame { get; set; }
public User? CurrentUser { get; set; }
public HashSet<User> Users { get; set; }
public Manager(IPersistance persistance)
{
Mgrpersistance = persistance;
CurrentUser = new User("","", "", "", "Azerty123*");
GameList = persistance.LoadGame();
ResearchedGame = persistance.LoadGame();
Users = persistance.LoadUser();
if (GameList == null)
{
GameList = new ObservableCollection<Game>();
}
}
public IEnumerable<Game> FilterGames(string? filterName, string? filterTag1, string? filterTag2)

@ -9,6 +9,73 @@
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="tagsTemplate">
<Label Padding="5,0,0,0" Margin="0" Text="{Binding}"/>
</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 Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<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"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="reviewTemplate">
<VerticalStackLayout>
<HorizontalStackLayout> <!--BindingContextChanged="AddStars"-->
<Label Text="{Binding AuthorName}" FontSize="20"/>
</HorizontalStackLayout>
<Label Text="{Binding Text}"/>
</VerticalStackLayout>
</DataTemplate>
<DataTemplate x:Key="followTemplate">
<Border HeightRequest="150">
<Grid ColumnDefinitions="*, *" RowDefinitions="*">
<Image Source="{Binding Cover}"/>
<Label Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</Border>
</DataTemplate>
<DataTemplate x:Key="followLoginTemplate">
<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>
</ResourceDictionary>
</Application.Resources>
</Application>

@ -1,6 +1,7 @@
using Model;
using StimPersistance;
using StimStub;
using System.Diagnostics;
namespace Stim;
@ -20,9 +21,19 @@ public partial class App : Application
window.Stopped += (s, e) =>
{
Manager.Mgrpersistance = new Persistance(FileSystem.Current.AppDataDirectory);
Manager.SaveGames();
Manager.SaveUser();
if (!(File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, "games.xml"))))
{
Manager Manager2 = new(new Persistance(FileSystem.Current.AppDataDirectory));
Manager2.GameList = Manager.GameList;
Manager2.Users = Manager2.Users;
Manager2.SaveGames();
Manager2.SaveUser();
}
else
{
Manager.SaveGames();
Manager.SaveUser();
}
};
return window;

@ -53,13 +53,7 @@
</Grid.RowDefinitions>
<Label Text="Tags :"/>
<CollectionView Grid.Row="1" ItemsSource="{Binding Tags}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Padding="10,0,0,0" Text="{Binding}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView Grid.Row="1" ItemsSource="{Binding Tags}" ItemTemplate="{StaticResource tagsTemplate}"/>
</Grid>
<Label Grid.Column="1" Grid.Row="3" Text="{Binding Lien}"/>
@ -69,18 +63,8 @@
<VerticalStackLayout Grid.ColumnSpan="4" Grid.Row="4">
<Label Text="Avis de la communauté :" FontSize="30"/>
<CollectionView ItemsSource="{Binding Reviews}">
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<HorizontalStackLayout BindingContextChanged="AddStars">
<Label Text="{Binding AuthorName}" FontSize="20"/>
</HorizontalStackLayout>
<Label Text="{Binding Text}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding Reviews}" ItemTemplate="{StaticResource reviewTemplate}"/>
</VerticalStackLayout>
</Grid>
</Grid>

@ -6,27 +6,30 @@ namespace Stim;
public partial class DetailledPage : ContentPage
{
public Game CurrGame { get; set; }
public DetailledPage(Game game)
private Game currentGame;
public DetailledPage()
{
InitializeComponent();
BindingContext = game;
CurrGame= game;
if (CurrGame != null)
currentGame = (App.Current as App).Manager.SelectedGame;
BindingContext = currentGame;
if (currentGame is null) Navigation.PopAsync();
else
{
avgLabel.Text = game.GetAvgRate().ToString();
AddStars(starsContainer, game.GetAvgRate());
avgLabel.Text = currentGame.GetAvgRate().ToString();
AddStars(starsContainer, currentGame.GetAvgRate());
}
}
private void AddStars(object sender, EventArgs e)
public void AddStars(object sender, EventArgs e)
{
HorizontalStackLayout layout = sender as HorizontalStackLayout;
Review rev = layout.BindingContext as Review;
AddStars(layout, rev.Rate);
}
private static void AddStars(HorizontalStackLayout container, float rate)
public static void AddStars(HorizontalStackLayout container, float 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 });
@ -46,6 +49,6 @@ public partial class DetailledPage : ContentPage
private async void AddFollow(object sender, EventArgs e)
{
await this.ShowPopupAsync(new MessagePopup("Jeu ajouté dans les suivis !"));
((App)App.Current).Manager.CurrentUser.FollowAGame(CurrGame);
((App)App.Current).Manager.CurrentUser.FollowAGame(currentGame);
}
}

@ -11,5 +11,4 @@
<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>

@ -19,18 +19,8 @@
<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">
<CollectionView.ItemTemplate>
<DataTemplate>
<Border HeightRequest="150">
<Grid ColumnDefinitions="*, *" RowDefinitions="*">
<Image Source="{Binding Cover}"/>
<Label Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding Followed_Games}" SelectionMode="Single" Grid.Column="1" SelectionChanged="GoToDetail" ItemTemplate="{StaticResource followTemplate}"/>
</Grid>
</ScrollView>
</ContentPage>

@ -12,6 +12,7 @@ public partial class FollowPage : ContentPage
public async void GoToDetail(object sender, EventArgs e)
{
await Navigation.PushAsync(new DetailledPage((sender as CollectionView).SelectedItem as Game));
(App.Current as App).Manager.SelectedGame = (sender as CollectionView).SelectedItem as Game;
await Navigation.PushAsync(new DetailledPage());
}
}

@ -39,44 +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}" SelectionMode="Single" SelectionChanged="OnClickGameList" ItemsLayout="VerticalGrid, 5" Grid.Column="1" Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<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 Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Text="Tags :" Margin="0" Padding="0"/>
<CollectionView ItemsSource="{Binding Tags}" Grid.Row="1" Margin="0">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Padding="5,0,0,0" Margin="0" Text="{Binding}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label Text="{Binding Year}" Grid.Row="1" Grid.Column="2" HorizontalTextAlignment="End" VerticalTextAlignment="End"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding ResearchedGame}" 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"/>

@ -19,7 +19,8 @@ public partial class MainPage : ContentPage
private async void OnClickGameList(object sender, EventArgs e)
{
await Navigation.PushAsync(new DetailledPage((sender as CollectionView).SelectedItem as Game));
(App.Current as App).Manager.SelectedGame = (sender as CollectionView).SelectedItem as Game;
await Navigation.PushAsync(new DetailledPage());
}
private async void GoToAddGamePage(object sender, EventArgs e)

@ -5,10 +5,8 @@
x:Class="Stim.MessagePopup"
CanBeDismissedByTappingOutsideOfPopup ="False">
<VerticalStackLayout>
<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>
</VerticalStackLayout>
<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>
</toolkit:Popup>

@ -61,30 +61,8 @@
<Label HorizontalOptions="Center" Text="Mes suivis"/>
<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>
<CollectionView ItemsSource="{Binding CurrentUser.Followed_Games}" SelectionMode="Single" SelectionChanged="CollectionView_SelectionChanged" ItemTemplate="{StaticResource followLoginTemplate}"/>
</Border>
</ScrollView>
</VerticalStackLayout>
</Grid>

Loading…
Cancel
Save