feat : review pop up
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7f116ed0eb
commit
ad3905d359
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
||||
x:Class="Stim.ReviewPopUp"
|
||||
CanBeDismissedByTappingOutsideOfPopup="False">
|
||||
|
||||
<Grid ColumnDefinitions="*" RowDefinitions="*, *, *, *, *">
|
||||
<Label x:Name="placeholder" Style="{StaticResource popupLabel}"/>
|
||||
<Entry Grid.Row="1" x:Name="Entrytxt" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||
<Entry Grid.Row="2" x:Name="Val" VerticalOptions="Center" HorizontalOptions="Center"/>
|
||||
<Button Grid.Row="3" Text="Valider" Style="{StaticResource popupButton}" Clicked="Valider"/>
|
||||
<Button Grid.Row="4" Text="Annuler" Style="{StaticResource popupButton}" Clicked="CloseButton"/>
|
||||
<HorizontalStackLayout x:Name="Error"/>
|
||||
</Grid>
|
||||
</toolkit:Popup>
|
@ -0,0 +1,35 @@
|
||||
using CommunityToolkit.Maui.Views;
|
||||
using Model;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Stim;
|
||||
|
||||
public partial class ReviewPopUp : Popup
|
||||
{
|
||||
Game CurrGame { get; set; }
|
||||
public ReviewPopUp(Game currGame)
|
||||
{
|
||||
InitializeComponent();
|
||||
CurrGame = currGame;
|
||||
}
|
||||
|
||||
public void CloseButton(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Valider(object sender, EventArgs e)
|
||||
{
|
||||
if (CurrGame == null)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
bool IsFloat = float.TryParse(Val.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out float rate);
|
||||
if (!string.IsNullOrWhiteSpace(Entrytxt.Text) && IsFloat)
|
||||
{
|
||||
((App)App.Current).Manager.CurrentUser.AddReview(CurrGame, rate, Entrytxt.Text);
|
||||
Close();
|
||||
}
|
||||
else Error.Children.Add(new Label { Text="Champ vide ou invalide", TextColor=Colors.Red });
|
||||
}
|
||||
}
|
Loading…
Reference in new issue