You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Projet_IHM/Sources/Stim/DetailledPage.xaml.cs

65 lines
1.6 KiB

using CommunityToolkit.Maui.Views;
using Model;
using StimPersistance;
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();
}
private async void GoToMainPage(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new MainPage());
}
private void AddReview(object sender, EventArgs e)
{
//popup add review
}
private async void AddFollow(object sender, EventArgs e)
{
bool flag = false;
foreach (Game game in ((App)App.Current).Manager.CurrentUser.Followed_Games)
{
if (game == null) throw new Exception();
else if (currentGame == game) { flag = true; break; }
}
if (!flag)
{
await this.ShowPopupAsync(new MessagePopup("Jeu ajouté dans les suivis !"));
((App)App.Current).Manager.CurrentUser.FollowAGame(currentGame);
}
else
{
await this.ShowPopupAsync(new MessagePopup("Jeu déjà suivis !"));
}
}
protected override void OnNavigatedFrom(NavigatedFromEventArgs args)
{
Navigation.PopAsync();
base.OnNavigatedFrom(args);
}
protected override void OnDisappearing()
{
Navigation.PopAsync();
base.OnDisappearing();
}
protected override void OnAppearing()
{
base.OnAppearing();
}
}