diff --git a/source/Trek-12/Trek-12/Views/pageProfils.xaml b/source/Trek-12/Trek-12/Views/pageProfils.xaml
index ac1720c..6f33a7e 100644
--- a/source/Trek-12/Trek-12/Views/pageProfils.xaml
+++ b/source/Trek-12/Trek-12/Views/pageProfils.xaml
@@ -3,8 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Trek_12.Views.PageProfils"
xmlns:views="clr-namespace:Trek_12.Views.Components"
+ xmlns:game="clr-namespace:Models.Game;assembly=Models"
Title="pageProfils">
+
+
+
+
+
+
@@ -14,7 +21,7 @@
-
diff --git a/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs b/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs
index 9047a40..749144a 100644
--- a/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs
+++ b/source/Trek-12/Trek-12/Views/pageProfils.xaml.cs
@@ -1,46 +1,68 @@
-namespace Trek_12.Views;
+using Models.Game;
using Stub;
using System.Diagnostics;
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
+using Models.Interfaces;
+
+namespace Trek_12.Views;
public partial class PageProfils : ContentPage
{
- public Stub MyStub { get; set; } = new Stub();
+ public Game ProfileManager => (App.Current as App).Manager;
public PageProfils()
{
InitializeComponent();
- BindingContext = MyStub;
+ BindingContext = ProfileManager;
}
async void Button_ClickedAdd(System.Object sender, System.EventArgs e)
{
- string result = await DisplayPromptAsync("Info", $"Choose a name : ", "Ok");
- Debug.WriteLine("Answer: " + result);
- if (result != null)
- {
- Debug.WriteLine("bam, added");
- MyStub.Add(result, "profile.jpg");
- }
- }
+ string pseudo = await DisplayPromptAsync("Info", $"Choose a name : ", "Ok");
+ if (pseudo == null) return;
+
+ var profilePicture = await MediaPicker.PickPhotoAsync();
+ if (profilePicture == null) return;
+
+ IImageConverter converter = new Base64Converter();
+ string convertedProfilePicture = converter.ConvertImage(profilePicture.FullPath);
+
+ Player player = new Player(pseudo, convertedProfilePicture);
+ ProfileManager.AddPlayer(player);
+ Debug.WriteLine("Player " + pseudo + " added with profile picture " + convertedProfilePicture);
+ Debug.WriteLine("It's the number" + ProfileManager.Players.Count + " player");
+
+ ProfileManager.OnPropertyChanged(nameof(ProfileManager.Players));
+ ProfileManager.SaveData();
+ }
async void Button_ClickedPop(System.Object sender, System.EventArgs e)
{
- string result = await DisplayPromptAsync("Info", $"Choose a name to delete : ", "Ok");
+ if (ProfileManager.Players.Count == 0)
+ {
+ await DisplayAlert("Info", "There is no player actually\nPlease add one", "Ok");
+ return;
+ }
+
+ string result = await DisplayPromptAsync("Info", $"Choose a pseudo to delete : ", "Ok");
+ if (result == null) return;
Debug.WriteLine("Answer: " + result);
- if (result != null)
+ if (ProfileManager.RemovePlayer(result))
{
Debug.WriteLine("bam, deleted");
- MyStub.Pop(result, "profile.jpg");
+ OnPropertyChanged(nameof(ProfileManager));
}
- else Debug.WriteLine("Pseudo not found");
+ else Debug.WriteLine("Player not found");
+
}
async void Button_ClickedModify(System.Object sender, System.EventArgs e)
{
+ throw new NotImplementedException();
+ /*
string result = await DisplayPromptAsync("Info", $"Choose a name to modify : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
@@ -60,7 +82,7 @@ public partial class PageProfils : ContentPage
}
}
else Debug.WriteLine("Did not found");
+ */
}
-
}