Fix de très nombreux bug pour les Conseils, ajout de la fonctionalité de refresh la scrollView, et ajout des boutons pour chaque commentaire, avec de nombreuses VisualStates (aussi correction de Model.User en le nom réel de l'utilisateur hahaha) 🎉
continuous-integration/drone/push Build is passing Details

Collection
ImNicolasTheDev 2 years ago
parent 241125c9bd
commit e1efccd73f

@ -196,24 +196,29 @@
<!-- Conseils -->
<Border Grid.Row="3" Style="{StaticResource sectionStyle}">
<StackLayout>
<Label TextDecorations="Underline" Text="Conseils :" FontSize="Medium"/>
<!-- Bouton d'ajout de conseil -->
<Button x:Name="ButtonAddConseil" IsVisible="False" Text="Ajouter un conseil" Grid.Row="0" Grid.Column="1" Clicked="OnAddConseilClicked" />
<StackLayout x:Name="AddConseilLayout" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" IsVisible="False">
<Editor x:Name="texteConseilEntry" Placeholder="Texte du conseil" PlaceholderColor="{StaticResource Gray500}"/>
<Button Text="Valider" Clicked="OnValiderConseilClicked" />
<Button Text="Annuler" Clicked="OnExitConseilClicked" />
</StackLayout>
<ListView x:Name="ListViewConseils" ItemsSource="{Binding ListConseils}" Grid.Row="1">
<Button x:Name="ButtonAddConseil" HorizontalOptions="End" IsVisible="False" Text="Ajouter un conseil" Grid.Row="0" Grid.Column="1" Clicked="OnAddConseilClicked" />
<VerticalStackLayout x:Name="AddConseilLayout" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" IsVisible="False">
<Editor x:Name="texteConseilEntry" TextChanged="texteConseilEntry_TextChanged" AutoSize="TextChanges" Placeholder="Texte du conseil" PlaceholderColor="{StaticResource Gray500}"/>
<Grid ColumnDefinitions="*,*" HorizontalOptions="CenterAndExpand">
<Button Grid.Column="0" Text="Valider" Clicked="OnValiderConseilClicked" />
<Button Grid.Column="1" Text="Annuler" Clicked="OnExitConseilClicked" />
</Grid>
</VerticalStackLayout>
<ListView x:Name="ListViewConseils" VerticalOptions="Fill" ItemsSource="{Binding ListConseils}" Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid ColumnDefinitions="*, Auto" HeightRequest="15">
<Grid ColumnDefinitions="*, Auto" MinimumHeightRequest="50" HorizontalOptions="Fill" BackgroundColor="Transparent"> <!-- LA je ne comprends pas : pour que les VisualStates
fonctionnent sur tout le grid, et pas que sur le texte du label, il faut rajouter un background?? Bizarre...-->
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter TargetName="ConseilOptions" Property="IsVisible"
<Setter TargetName="ConseilOptions" Property="IsVisible"
Value="true" />
</VisualState.Setters>
</VisualState>
@ -226,22 +231,21 @@
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
<HorizontalStackLayout Grid.Column="0" VerticalOptions="Center" HorizontalOptions="Fill">
<Label BindingContext="{Binding Auteur}" Text="{Binding Pseudo, StringFormat=' {0} :'}" Grid.Column="0"/>
<Label Text="{Binding Texte, StringFormat=' {0}'}" Grid.Column="1" />
</HorizontalStackLayout>
<HorizontalStackLayout x:Name="ConseilOptions" Grid.Column="1" IsVisible="False">
<ImageButton Scale="0.8" BackgroundColor="Transparent" Source="pencil.png" HeightRequest="15" WidthRequest="15"/>
<ImageButton Scale="0.8" BackgroundColor="Transparent" Source="bin.png" HeightRequest="15" WidthRequest="15"/>
<ImageButton CornerRadius="6" Scale="0.8" Source="pencil.png" HeightRequest="15" WidthRequest="15"/>
<ImageButton CornerRadius="6" Scale="0.8" Source="bin.png" HeightRequest="15" WidthRequest="15"/>
</HorizontalStackLayout>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.GestureRecognizers>
<PointerGestureRecognizer PointerEntered="PointerGestureRecognizer_PointerEntered">
</PointerGestureRecognizer>
</ListView.GestureRecognizers>
</ListView>
</StackLayout>
</Border>

@ -1,11 +1,11 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Layouts;
using Model;
using Persistance;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Vues;
public partial class SearchMob : ContentPage, INotifyPropertyChanged
@ -45,35 +45,33 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
}
}
public void refreshScrollView()
{
ScrollLayoutThatNeedsToBeRefreshed.IsVisible = false;
ScrollLayoutThatNeedsToBeRefreshed.IsVisible = true;
}
public void OnClick(object sender, ItemTappedEventArgs e)
{
(App.Current as App).MonstreSelectionne = e.Item as Monstre;
imageCollection.Source = imageLinkConverter((App.Current as App).MonstreSelectionne.AppearanceList.First());
refreshScrollView();
}
private void OnAddConseilClicked(object sender, EventArgs e)
{
var button = sender as Button;
// Afficher les champs à remplir pour ajouter un conseil
//FAIRE UN FUCKING X:NAME :>
var addConseilLayout = button?.Parent?.FindByName<StackLayout>("AddConseilLayout");
if (addConseilLayout != null)
if (!AddConseilLayout.IsVisible)
{
ScrollLayoutThatNeedsToBeRefreshed.IsVisible = false;
addConseilLayout.IsVisible = true;
ScrollLayoutThatNeedsToBeRefreshed.IsVisible = true;
AddConseilLayout.IsVisible = true;
texteConseilEntry.Text = null;
refreshScrollView();
}
}
private void OnValiderConseilClicked(object sender, EventArgs e)
{
var button = sender as Button;
//FAIRE UN FUCKING ICI AUSSI X:NAME :>
var addConseilLayout = button?.Parent?.FindByName<StackLayout>("AddConseilLayout");
if (addConseilLayout != null)
if (AddConseilLayout != null)
{
var texteConseil = texteConseilEntry.Text;
string texteConseil = texteConseilEntry.Text;
// Ajouter le nouveau conseil à la liste des conseils du monstre sélectionné
var selectedMonstre = (App.Current as App).MonstreSelectionne;
if (selectedMonstre != null && !string.IsNullOrWhiteSpace(texteConseil))
@ -81,18 +79,16 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
var nouveauConseil = new Conseil((App.Current as App).User, texteConseil, selectedMonstre);
selectedMonstre.ListConseils.Add(nouveauConseil);
}
texteConseilEntry.Text = string.Empty;
addConseilLayout.IsVisible = false;
texteConseilEntry.Text = null;
AddConseilLayout.IsVisible = false;
}
refreshScrollView();
}
private void OnExitConseilClicked(object sender, EventArgs e)
{
var button = sender as Button;
var addConseilLayout = button?.Parent?.FindByName<StackLayout>("AddConseilLayout");
var texteConseilEntry = addConseilLayout.Children[1] as Editor;
texteConseilEntry.Text = string.Empty;
addConseilLayout.IsVisible = false;
texteConseilEntry.Text = null;
AddConseilLayout.IsVisible = false;
}
private string imageLinkConverter(string imageLink)
@ -106,21 +102,12 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
{
appearanceSelected = e.Item as string;
imageCollection.Source = imageLinkConverter(appearanceSelected);
}
private void FilterClicked(object sender, EventArgs e) // Afficher les filtres
private void FilterClicked(object sender, EventArgs e)
{
var button = sender as Button;
var afficherFiltres = button?.Parent?.FindByName<HorizontalStackLayout>("HorizonFilterClicked");
if (afficherFiltres.IsVisible)
{
afficherFiltres.IsVisible = false;
}
else
{
afficherFiltres.IsVisible |= true;
}
// Inverse la valeur booléenne de IsVisible => Permet d'afficher ou non les boutons de filtrage
HorizonFilterClicked.IsVisible = !HorizonFilterClicked.IsVisible;
}
private void UpdateAffichMobs()
@ -152,8 +139,8 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
SearchText = e.NewTextValue;
}
private void PointerGestureRecognizer_PointerEntered(object sender, PointerEventArgs e)
private void texteConseilEntry_TextChanged(object sender, TextChangedEventArgs e)
{
//ConseilOptions.IsVisible = true;
(ScrollLayoutThatNeedsToBeRefreshed as IView).InvalidateMeasure(); //Permet de recalculer la taille de la scrollView
}
}
Loading…
Cancel
Save