binding name, surname and mail of user in profil view
continuous-integration/drone/push Build is passing Details

pull/48/head
Roxane 2 years ago
parent 54cf493fba
commit 5a255642b5

@ -8,6 +8,7 @@ using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel;
namespace Model
{
@ -16,7 +17,7 @@ namespace Model
/// This user can login with an Id and a password
/// </summary>
[DataContract(Name = "user")]
public class User : IEquatable<User>
public class User : IEquatable<User> , INotifyPropertyChanged
{
#region Private Attributes
@ -26,6 +27,8 @@ namespace Model
[DataMember] private string picture = "";
[DataMember] private int password ;
[DataMember] private List<Priority> priorities;
public event PropertyChangedEventHandler? PropertyChanged;
#endregion
#region Properties
@ -44,6 +47,7 @@ namespace Model
throw new ArgumentException("Impossible d'avoir un champ Nom vide!");
}
name = value;
OnPropertyChanged();
}
}
@ -61,6 +65,7 @@ namespace Model
throw new ArgumentException("Impossible d'avoir un champ Prénom vide!");
}
surname = value;
OnPropertyChanged();
}
}
@ -130,6 +135,21 @@ namespace Model
throw new NotImplementedException();
}
protected void OnPropertyChanged ([CallerMemberName] string? propertyName = null)
{
if (PropertyChanged != null)
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override string ToString()
{
return $"{Name} {Surname}";
}
#endregion

@ -4,10 +4,13 @@ using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
using DataPersistence;
namespace Views
{
public partial class App : Application
{
public DataManager DataMgr { get; private set; } = new DataManager(new Stubs());
const int WindowWidth = 1200;
const int WindowHeight = 800;

@ -28,7 +28,7 @@
Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Source={x:Reference fl}}"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"/>
<Label Text="Jean-Baptiste De La Fontaine"
<Label Text="{Binding user}"
HorizontalOptions="Center" Margin="15"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"

@ -1,11 +1,21 @@
using DataPersistence;
using Model;
namespace Views;
public partial class ContainerFlyout : ContentView
{
public ContainerFlyout()
public DataManager DataMgr => (App.Current as App).DataMgr;
public User user { get; private set; }
public ContainerFlyout()
{
InitializeComponent();
}
BindingContext = this;
user = DataMgr.Data[nameof(User)].Cast<User>().Last();
}
// Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty =

@ -24,7 +24,7 @@
<local:ContainerBase.MyContent>
<ScrollView>
<StackLayout ><!--Attention debut de binding-->
<StackLayout >
<Label Text="Mon profil" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
FontAttributes="Bold"
FontSize="24" Padding="15, 15, 20, 5"/>
@ -41,14 +41,15 @@
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"/>
Margin="50,10,0,20"
Text="{Binding Surname} "/>
<Label Text="Mail :"
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"
IsEnabled="False"
Text="truc@gmail"/>
Text="{Binding Mail}"/>
<Label Text="Pseudo :"
Padding="50,0,0,0"
FontSize="18"/>

@ -1,9 +1,21 @@
using DataPersistence;
using Model;
namespace Views;
public partial class MyProfil : ContentPage
{
public DataManager DataMgr = (App.Current as App).DataMgr;
public User user { get; private set; }
public MyProfil()
{
DataMgr = new DataManager(new Stubs());
user = DataMgr.Data[nameof(User)].Cast<User>().Last();
InitializeComponent();
BindingContext = user;
}
}

@ -57,6 +57,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataPersistence\DataPersistence.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>

Loading…
Cancel
Save