Merge pull request 'pageProfils' (#94) from pageProfils into dev
continuous-integration/drone/push Build is passing Details

Reviewed-on: #94
Reviewed-by: Rémi LAVERGNE <remi.lavergne@etu.uca.fr>
pull/99/head
Remi NEVEU 11 months ago
commit feb662dd39

@ -1,15 +1,37 @@
namespace Models.Game
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Models.Game
{
/// <summary>
/// Represents a player in the game.
/// </summary>
public class Player
public class Player : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/// <summary>
/// It is he pseudo of the player.
/// </summary>
public string Pseudo { get; private set; }
private string _pseudo;
public string Pseudo
{
get => _pseudo;
set
{
if (_pseudo == value)
return;
_pseudo = value;
OnPropertyChanged();
}
}
private int hairCount;
/// <summary>
/// It is the profile picture of the player.
@ -46,6 +68,7 @@
ProfilePicture = profilePicture;
}
/// <summary>
/// Chooses the operation for the player.
/// </summary>

@ -0,0 +1,51 @@
using System.Collections.ObjectModel;
using System.Data;
using System.Numerics;
using Models.Game;
namespace Stub
{
public class Stub
{
public ReadOnlyObservableCollection<Player> ListPlayer { get; private set; }
private readonly ObservableCollection<Player> listplayer = new ObservableCollection<Player>();
public Stub()
{
LoadPlayer();
ListPlayer = new ReadOnlyObservableCollection<Player>(listplayer);
}
public void LoadPlayer()
{
listplayer.Add(new Player());
listplayer.Add(new Player("Lucas", "profile.jpg"));
listplayer.Add(new Player("relavergne", "profile.jpg"));
listplayer.Add(new Player("reneveu", "profile.jpg"));
}
public void Add(string pseudo, string profilePicture)
{
listplayer.Add(new Player(pseudo, profilePicture));
}
public void Pop(string pseudo, string profilePicture)
{
listplayer.Remove(new Player(pseudo, profilePicture));
}
public bool Modify(string pseudo, string newpseudo)
{
foreach(var index in listplayer)
{
if (index.Pseudo == pseudo)
{
index.Pseudo = newpseudo;
return true;
}
}
return false;
}
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
</Project>

@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataContractPersistence", "DataContractPersistence\DataContractPersistence.csproj", "{FC6A23C3-A1E3-4BF4-85B0-404D8574E190}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stub", "Stub\Stub.csproj", "{49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -41,6 +43,10 @@ Global
{FC6A23C3-A1E3-4BF4-85B0-404D8574E190}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC6A23C3-A1E3-4BF4-85B0-404D8574E190}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC6A23C3-A1E3-4BF4-85B0-404D8574E190}.Release|Any CPU.Build.0 = Release|Any CPU
{49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49360F7D-C59D-4B4F-AF5A-73FF61D9EF9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -63,6 +63,11 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj" />
<ProjectReference Include="..\Stub\Stub.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\PageLeaderBoard.xaml.cs">
<DependentUpon>PageLeaderBoard.xaml</DependentUpon>
@ -82,9 +87,6 @@
<MauiXaml Update="Views\PageLeaderBoard.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\PageConnexion.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Trek_12.Views.Components.viewsProfils">
x:Class="Trek_12.Views.Components.viewsProfils"
x:Name="this">
<VerticalStackLayout>
<Grid ColumnDefinitions="*,*,*,*" >
<Frame Margin="10"
@ -13,11 +14,11 @@
IsClippedToBounds="True"
HasShadow="True"
HorizontalOptions="CenterAndExpand">
<Image Source="profile.jpg"
<Image Source="{Binding ProfilePicture, Source={x:Reference this}}"
Aspect="AspectFill"
Margin="-20"/>
</Frame>
<Label Text="Profile n°*" Grid.Column="2" TextColor="Black" FontSize="Large" HorizontalTextAlignment="Center" Margin="100"/>
<Label Text="{Binding Pseudo, Source={x:Reference this}}" Grid.Column="2" TextColor="Black" FontSize="Large" HorizontalTextAlignment="Center" Margin="100"/>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -6,4 +6,23 @@ public partial class viewsProfils : ContentView
{
InitializeComponent();
}
public static readonly BindableProperty PseudoProperty =
BindableProperty.Create("Pseudo", typeof(string), typeof(ContentLeaderBoard), "Profile n°*");
public string Pseudo
{
get => (string)GetValue(PseudoProperty);
set => SetValue(PseudoProperty, value);
}
public static readonly BindableProperty ProfilePictureProperty =
BindableProperty.Create("ProfilePicture", typeof(string), typeof(ContentLeaderBoard), "profile.jpg");
public string ProfilePicture
{
get => (string)GetValue(ProfilePictureProperty);
set => SetValue(ProfilePictureProperty, value);
}
}

@ -1,43 +1,43 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Trek_12.Views.Components"
x:Class="Trek_12.Views.PageLeaderBoard"
Title="PageLeaderBoard">
<Grid BackgroundColor="BlanchedAlmond"
RowDefinitions="auto,6*,*">
<VerticalStackLayout>
<Label
Text="Leader board"
VerticalOptions="Center"
HorizontalOptions="Center"
FontSize="Title"/>
<BoxView
Color="DarkSalmon"
HeightRequest="1"
WidthRequest="125"/>
</VerticalStackLayout>
<ScrollView Grid.Row="1"
VerticalOptions="FillAndExpand"
VerticalScrollBarVisibility="Never"
Margin="0,10">
<VerticalStackLayout>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
</VerticalStackLayout>
</ScrollView>
<Button Text="Back"
BackgroundColor="OliveDrab"
FontSize="Title"
Grid.Row="2"
HorizontalOptions="Start"
CornerRadius="20"
WidthRequest="150"
HeightRequest="75"
Margin="10"/>
</Grid>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Trek_12.Views.Components"
x:Class="Trek_12.Views.PageLeaderBoard"
Title="PageLeaderBoard">
<Grid BackgroundColor="BlanchedAlmond"
RowDefinitions="auto,6*,*">
<VerticalStackLayout>
<Label
Text="Leader board"
VerticalOptions="Center"
HorizontalOptions="Center"
FontSize="Title"/>
<BoxView
Color="DarkSalmon"
HeightRequest="1"
WidthRequest="125"/>
</VerticalStackLayout>
<ScrollView Grid.Row="1"
VerticalOptions="FillAndExpand"
VerticalScrollBarVisibility="Never"
Margin="0,10">
<VerticalStackLayout>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
<views:ContentLeaderBoard/>
</VerticalStackLayout>
</ScrollView>
<Button Text="Back"
BackgroundColor="OliveDrab"
FontSize="Title"
Grid.Row="2"
HorizontalOptions="Start"
CornerRadius="20"
WidthRequest="150"
HeightRequest="75"
Margin="10"/>
</Grid>
</ContentPage>

@ -1,9 +1,9 @@
namespace Trek_12.Views;
public partial class PageLeaderBoard : ContentPage
{
public PageLeaderBoard()
{
InitializeComponent();
}
namespace Trek_12.Views;
public partial class PageLeaderBoard : ContentPage
{
public PageLeaderBoard()
{
InitializeComponent();
}
}

@ -14,22 +14,22 @@
<Label Text="Profils" TextColor="black" HorizontalTextAlignment="Center" FontSize="Header" Margin="30"/>
<ScrollView Grid.Row="1">
<Grid RowDefinitions="*,*,*,*,*,*">
<views:viewsProfils />
<views:viewsProfils Grid.Row="1" />
<views:viewsProfils Grid.Row="2"/>
<views:viewsProfils Grid.Row="3"/>
<views:viewsProfils Grid.Row="4"/>
<views:viewsProfils Grid.Row="5"/>
<CollectionView Grid.Row="1" ItemsSource="{Binding ListPlayer}"
ItemsLayout="VerticalList"
VerticalOptions="Center">
<CollectionView.ItemTemplate>
<DataTemplate>
<views:viewsProfils
Pseudo="{Binding Pseudo}"
ProfilePicture="{Binding ProfilePicture}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ScrollView>
<HorizontalStackLayout Grid.Row="2" HorizontalOptions="Center" Spacing="50">
<Button Text="Modifier" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Créer" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Supprimer" WidthRequest="300" HeightRequest="60" CornerRadius="4"/>
<Button Text="Modifier" WidthRequest="300" HeightRequest="60" CornerRadius="4" Clicked="Button_ClickedModify"/>
<Button Text="Créer" WidthRequest="300" HeightRequest="60" CornerRadius="4" Clicked="Button_ClickedAdd"/>
<Button Text="Supprimer" WidthRequest="300" HeightRequest="60" CornerRadius="4" Clicked="Button_ClickedPop"/>
</HorizontalStackLayout>
</Grid>

@ -1,9 +1,66 @@
namespace Trek_12.Views;
using Stub;
using System.Diagnostics;
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
public partial class PageProfils : ContentPage
{
public PageProfils()
public Stub MyStub { get; set; } = new Stub();
public PageProfils()
{
InitializeComponent();
BindingContext = MyStub;
}
}
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");
}
}
async void Button_ClickedPop(System.Object sender, System.EventArgs e)
{
string result = await DisplayPromptAsync("Info", $"Choose a name to delete : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
{
Debug.WriteLine("bam, deleted");
MyStub.Pop(result, "profile.jpg");
}
else Debug.WriteLine("Pseudo not found");
}
async void Button_ClickedModify(System.Object sender, System.EventArgs e)
{
string result = await DisplayPromptAsync("Info", $"Choose a name to modify : ", "Ok");
Debug.WriteLine("Answer: " + result);
if (result != null)
{
string tomodify = await DisplayPromptAsync("Info", $"How will you rename it ?: ", "Ok");
Debug.WriteLine("Answer: " + tomodify);
if (tomodify != null)
{
Debug.WriteLine("bam, modified");
bool ismodified = MyStub.Modify(result, tomodify);
if (ismodified)
{
Debug.WriteLine("Modified");
}
else Debug.WriteLine("Player not found");
}
}
else Debug.WriteLine("Did not found");
}
}

Loading…
Cancel
Save