La modification et la suppression de commentaires fonctionne + BUG FIX du User qui restait connecté même en tant qu'invité
continuous-integration/drone/push Build is passing Details

develop
ImNicolasTheDev 2 years ago
parent 33200d002a
commit 11fe85db23

@ -21,6 +21,7 @@ namespace Vues
private async void Invite_Clicked(object sender, EventArgs e)
{
(Application.Current as App).User = null;
await Navigation.PushAsync(new SearchMob());
}
}

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:shape="Microsoft.Maui.Controls.Shapes"
xmlns:model="clr-namespace:Model;assembly=Modèle"
x:Class="Vues.SearchMob"
BackgroundImageSource="backcollection.jpg">
<!--BackgroundImageSource="backcollection.jpg"-->
@ -200,6 +201,29 @@
<Label TextDecorations="Underline" Text="Conseils :" FontSize="Medium"/>
<!-- Bouton d'ajout de conseil -->
<Button x:Name="ButtonAddConseil" Margin="8" HorizontalOptions="End" IsVisible="False" Text="Ajouter un conseil" Grid.Row="0" Grid.Column="1" Clicked="OnAddConseilClicked" />
<HorizontalStackLayout>
<!-- On devrait faire des styles globaux pour ces boutons, comme en haut du XAML -->
<ImageButton
x:Name="ConseilOptionModify"
IsVisible="False"
IsEnabled="False"
CornerRadius="5"
Scale="0.7"
Source="pencil.png"
HeightRequest="12" WidthRequest="12"
CommandParameter="{Binding .}"
Clicked="ConseilOptionModify_Clicked"/>
<ImageButton
x:Name="ConseilOptionDelete"
IsVisible="False"
IsEnabled="False"
CornerRadius="5"
Scale="0.7"
Source="bin.png"
HeightRequest="12" WidthRequest="12"
CommandParameter="{Binding .}"
Clicked="ConseilOptionDelete_Clicked"/>
</HorizontalStackLayout>
<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="*,*" Padding="8" HorizontalOptions="CenterAndExpand">
@ -207,51 +231,30 @@
<Button Grid.Column="1" Text="Annuler" Clicked="OnExitConseilClicked" />
</Grid>
</VerticalStackLayout>
<ListView x:Name="ListViewConseils" VerticalOptions="Fill" ItemsSource="{Binding ListConseils}">
<VerticalStackLayout x:Name="ModifyConseilLayout" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" IsVisible="False">
<Editor x:Name="conseilEditor" TextChanged="conseilEditor_TextChanged" AutoSize="TextChanges" Placeholder="Texte du conseil" PlaceholderColor="{StaticResource Gray500}"/>
<Grid ColumnDefinitions="*,*" Padding="8" HorizontalOptions="CenterAndExpand">
<Button Grid.Column="0" Text="Valider" Clicked="OnValiderModifConseilClicked" />
<Button Grid.Column="1" Text="Annuler" Clicked="OnExitModifConseilClicked" />
</Grid>
</VerticalStackLayout>
<ListView x:Name="ListViewConseils" VerticalOptions="Fill" ItemsSource="{Binding ListConseils}" ItemTapped="ListViewConseils_ItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<!-- x:DataType="model:Conseil" Besoin de préciser pour pouvoir passer
l'objet en tant que Conseil en paramètre -->
<ViewCell>
<Border BackgroundColor="AntiqueWhite" StrokeThickness="2" StrokeShape="RoundRectangle 10">
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter TargetName="ConseilOptions" Property="IsVisible"
Value="true" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter TargetName="ConseilOptions" Property="IsVisible"
Value="false" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
<Grid ColumnDefinitions="*,90" RowDefinitions="*" Padding="0" MinimumHeightRequest="50" HorizontalOptions="Fill" VerticalOptions="Fill">
<Grid ColumnDefinitions="*,70,70" RowDefinitions="*" Padding="0" MinimumHeightRequest="50" HorizontalOptions="Fill" VerticalOptions="Fill">
<!-- 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...-->
fonctionnent sur tout le grid, et pas que sur le texte du label, il faut rajouter un background?? Bizarre-->
<VerticalStackLayout Padding="15,10,10,10" Grid.Column="0" VerticalOptions="Center">
<Label BindingContext="{Binding Auteur}" Text="{Binding Pseudo, StringFormat='{0} :'}"/>
<Label VerticalOptions="Fill" LineBreakMode="WordWrap" Text="{Binding Texte, StringFormat='{0}'}" />
<Label x:Name="labelConseil" VerticalOptions="Fill" LineBreakMode="WordWrap" Text="{Binding Texte, StringFormat='{0}'}" />
<Editor x:Name="editorConseil" IsVisible="false" VerticalOptions="Fill" Text="{Binding Texte, StringFormat='{0}'}" />
</VerticalStackLayout>
<!-- Les boutons de modifications et de suppression-->
<HorizontalStackLayout x:Name="ConseilOptions" Grid.Column="1" HorizontalOptions="End" IsVisible="False">
<ImageButton x:Name="lolilol" CornerRadius="5" Scale="0.7" Source="bin.png" HeightRequest="12" WidthRequest="12"/>
<ImageButton CornerRadius="5" Scale="0.7" Source="pencil.png" HeightRequest="12" WidthRequest="12" Clicked="ImageButton_Clicked"/>
<VerticalStackLayout x:Name="VerticalModifConseil" Grid.Row="2" IsVisible="False">
<Editor Text="{Binding ListConseils}"></Editor>
<Button x:Name="BoutonValidModif" Text="Confirmer les modifications"/>
</VerticalStackLayout>
</HorizontalStackLayout>
</Grid>
</Border>
</ViewCell>

@ -12,6 +12,7 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
{
public ObservableCollection<Monstre> MnstrTemp { get; set; }
private string searchText;
private Conseil conseilSelectionne { get; set; }
public string SearchText
{
get
@ -42,6 +43,8 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
if ((Application.Current as App).User != null)
{
ButtonAddConseil.IsVisible = true;
ConseilOptionModify.IsVisible = true;
ConseilOptionDelete.IsVisible = true;
}
}
@ -55,6 +58,7 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
(App.Current as App).MonstreSelectionne = e.Item as Monstre;
imageCollection.Source = imageLinkConverter((App.Current as App).MonstreSelectionne.AppearanceList.First());
AddConseilLayout.IsVisible = false;
conseilSelectionne = null;
refreshScrollView();
}
private void OnAddConseilClicked(object sender, EventArgs e)
@ -159,7 +163,7 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
private async void QuitClicked(object sender, EventArgs e)
{
(Application.Current as App).User = null;
await Navigation.PushAsync(new Accueil());
await Navigation.PopToRootAsync(); //Pour retourner à la page racine
}
private void CheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
@ -183,8 +187,79 @@ public partial class SearchMob : ContentPage, INotifyPropertyChanged
}
*/
///Si checkbox check
/*Si checkbox check
///add le monstre courant à la liste des monstre du user
///si unchecked, retirer le monsrte
///si unchecked, retirer le monsrte*/
}
private void ConseilOptionDelete_Clicked(object sender, EventArgs e)
{
if (conseilSelectionne != null)
{
if ((App.Current as App).User.Pseudo.Equals(conseilSelectionne.Auteur.Pseudo))
{
(App.Current as App).MonstreSelectionne.ListConseils.Remove(conseilSelectionne);
ConseilOptionModify.IsEnabled = false;
ConseilOptionDelete.IsEnabled = false;
}
}
}
private void ConseilOptionModify_Clicked(object sender, EventArgs e)
{
if (!ModifyConseilLayout.IsVisible)
{
ModifyConseilLayout.IsVisible = true;
conseilEditor.Text = conseilSelectionne.Texte;
refreshScrollView();
}
}
private void ListViewConseils_ItemTapped(object sender, ItemTappedEventArgs e)
{
if((App.Current as App).User != null)
{
conseilSelectionne = e.Item as Conseil;
if (conseilSelectionne != null && (App.Current as App).User.Pseudo.Equals(conseilSelectionne.Auteur.Pseudo))
{
ConseilOptionModify.IsEnabled = true;
ConseilOptionDelete.IsEnabled = true;
}
else
{
ConseilOptionModify.IsEnabled = false;
ConseilOptionDelete.IsEnabled = false;
}
}
}
private void conseilEditor_TextChanged(object sender, TextChangedEventArgs e)
{
(ScrollLayoutThatNeedsToBeRefreshed as IView).InvalidateMeasure();
}
private void OnValiderModifConseilClicked(object sender, EventArgs e)
{
if (ModifyConseilLayout != null)
{
string texteConseil = conseilEditor.Text;
var selectedMonstre = (App.Current as App).MonstreSelectionne;
if (selectedMonstre != null && !string.IsNullOrWhiteSpace(texteConseil) && !conseilSelectionne.Texte.Equals(texteConseil))
{
selectedMonstre.ListConseils.Remove(conseilSelectionne);
selectedMonstre.ListConseils.Add(new Conseil((App.Current as App).User, texteConseil, selectedMonstre));
}
conseilEditor.Text = null;
ModifyConseilLayout.IsVisible = false;
ConseilOptionModify.IsEnabled = false;
ConseilOptionDelete.IsEnabled = false;
}
refreshScrollView();
}
private void OnExitModifConseilClicked(object sender, EventArgs e)
{
conseilEditor.Text = null;
ModifyConseilLayout.IsVisible = false;
}
}
Loading…
Cancel
Save