work on user dysplay name on flayout page

pull/56/head
Alexandre AGOSTINHO 2 years ago
parent 962264a19d
commit e5ad35c0a0

@ -2,8 +2,10 @@
using Model; using Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -11,7 +13,7 @@ using System.Threading.Tasks;
namespace Managers namespace Managers
{ {
public class UserDefaultManager : IUserManager public class UserDefaultManager : IUserManager, INotifyPropertyChanging
{ {
private IDataManager _dataManager; private IDataManager _dataManager;
private IPasswordManager _passwordManager; private IPasswordManager _passwordManager;
@ -25,11 +27,25 @@ namespace Managers
} }
public User? CurrentConnected => _currentConnected; public User? CurrentConnected
{
get => _currentConnected;
private set
{
_currentConnected = value;
OnPropertyChanged();
}
}
public IPasswordManager PasswordManager => _passwordManager; public IPasswordManager PasswordManager => _passwordManager;
public event PropertyChangingEventHandler? PropertyChanging;
public void OnPropertyChanged([CallerMemberName] string pname = "")
=> PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(pname));
public bool AddUserToData(User user) public bool AddUserToData(User user)
{ {
var userList = _dataManager.Data[nameof(User)]; var userList = _dataManager.Data[nameof(User)];

@ -7,9 +7,9 @@
x:Class="Views.Home" x:Class="Views.Home"
x:Name="homepage"> x:Name="homepage">
<local:ContainerBase <local:ContainerBase x:Name="container_base"
IsNotConnected="{Binding IsNotConnected, Source={x:Reference homepage}}" NeedReturn="False"
NeedReturn="{Binding NeedReturn, Source={x:Reference homepage}}"> IsConnected="True">
<!-- Flyout --> <!-- Flyout -->
<local:ContainerBase.MyFlyoutContent> <local:ContainerBase.MyFlyoutContent>

@ -13,20 +13,7 @@ namespace Views
public static readonly BindableProperty IsNotConnectedProperty = public static readonly BindableProperty IsNotConnectedProperty =
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(bool)); BindableProperty.Create("IsNotConnected", typeof(bool), typeof(bool));
public bool IsNotConnected
{
get => (bool)GetValue(IsNotConnectedProperty);
set => SetValue(IsNotConnectedProperty, value);
}
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(bool));
public bool NeedReturn
{
get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value);
}
public Home() public Home()
@ -37,8 +24,9 @@ namespace Views
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = this;
IsNotConnected = true;
NeedReturn = false; //container_base.IsConnected = Master.User.CurrentConnected is not null;
Master.User.LogIn("admin@mctg.fr", "admin");
} }

@ -6,7 +6,7 @@
Title="MyPosts"> Title="MyPosts">
<local:ContainerBase <local:ContainerBase
IsNotConnected="False" IsConnected="False"
NeedReturn="True"> NeedReturn="True">
<local:ContainerBase.MyFlyoutContent> <local:ContainerBase.MyFlyoutContent>

@ -7,7 +7,7 @@
Title="MyProfil"> Title="MyProfil">
<local:ContainerBase <local:ContainerBase
IsNotConnected="False" IsConnected="False"
NeedReturn="True"> NeedReturn="True">
<local:ContainerBase.MyFlyoutContent> <local:ContainerBase.MyFlyoutContent>

@ -17,8 +17,7 @@
Grid.RowSpan="2" Grid.RowSpan="2"
MinimumWidthRequest="300" MinimumWidthRequest="300"
HorizontalOptions="StartAndExpand" HorizontalOptions="StartAndExpand"
IsNotConnected="{Binding IsNotConnected, Source={x:Reference root}}" x:Name="container_flayout">
NeedReturn="{Binding NeedReturn, Source={x:Reference root}}">
<local:ContainerFlyout.MyFlyoutContent> <local:ContainerFlyout.MyFlyoutContent>
<ContentView <ContentView
Content="{Binding MyFlyoutContent, Source={x:Reference root}}"/> Content="{Binding MyFlyoutContent, Source={x:Reference root}}"/>

@ -2,11 +2,26 @@ namespace Views;
public partial class ContainerBase : ContentView public partial class ContainerBase : ContentView
{ {
public bool IsConnected
{
get => container_flayout.IsConnected;
set => container_flayout.IsConnected = value;
}
public bool NeedReturn
{
get => container_flayout.NeedReturn;
set => container_flayout.NeedReturn = value;
}
public ContainerBase() public ContainerBase()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = this;
} }
// Bind MyContent // Bind MyContent
public static readonly BindableProperty MyContentProperty = public static readonly BindableProperty MyContentProperty =
BindableProperty.Create("MyContent", typeof(View), typeof(ContainerBase), new Grid()); BindableProperty.Create("MyContent", typeof(View), typeof(ContainerBase), new Grid());
@ -26,24 +41,4 @@ public partial class ContainerBase : ContentView
get => (View)GetValue(MyFlyoutContentProperty); get => (View)GetValue(MyFlyoutContentProperty);
set => SetValue(MyFlyoutContentProperty, value); set => SetValue(MyFlyoutContentProperty, value);
} }
// Bind IsNotConnected
public static readonly BindableProperty IsNotConnectedProperty =
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(Button), true);
public bool IsNotConnected
{
get => (bool)GetValue(IsNotConnectedProperty);
set => SetValue(IsNotConnectedProperty, value);
}
// bind NeedReturn
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);
public bool NeedReturn
{
get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value);
}
} }

@ -20,27 +20,29 @@
WidthRequest="100" HeightRequest="100" WidthRequest="100" HeightRequest="100"
CornerRadius="50" Margin="0, 30, 0, 10" CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black" BorderWidth="5" BorderColor="Black"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}" IsVisible="{Binding IsConnected, Source={x:Reference fl}}"
Grid.RowSpan="2" Grid.RowSpan="2"
Clicked="ProfileButton_Clicked"/> Clicked="ProfileButton_Clicked"/>
</Grid> </Grid>
<!-- Connection button -->
<Button Text="Connection" ImageSource="login_icon.png" <Button Text="Connection" ImageSource="login_icon.png"
Style="{StaticResource button2}" Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Source={x:Reference fl}}" Margin="15, 120"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}" IsVisible="{Binding IsConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}"
Clicked="ConnectionButton_Clicked"/> Clicked="ConnectionButton_Clicked"/>
<StackLayout BindingContext="{Binding user}">
<!-- Display name -->
<StackLayout BindingContext="{Binding user}"
IsVisible="{Binding IsConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}">
<Label Text="{Binding Name}" <Label Text="{Binding Name}"
HorizontalOptions="Center" Margin="0,15" HorizontalOptions="Center" Margin="0,15"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center" FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
<Label Text="{Binding Surname}" <Label Text="{Binding Surname}"
HorizontalOptions="Center" HorizontalOptions="Center"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center" FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
</StackLayout> </StackLayout>
</VerticalStackLayout> </VerticalStackLayout>
@ -56,7 +58,7 @@
<!-- Footer --> <!-- Footer -->
<Button Text="Déconnection" ImageSource="logout_icon.png" <Button Text="Déconnection" ImageSource="logout_icon.png"
Style="{StaticResource button2}" Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}"/> IsVisible="{Binding IsConnected, Source={x:Reference fl}}"/>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>

@ -26,13 +26,13 @@ public partial class ContainerFlyout : ContentView
} }
// Bind IsNotConnected // Bind IsNotConnected
public static readonly BindableProperty IsNotConnectedProperty = public static readonly BindableProperty IsConnectedProperty =
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(Button), true); BindableProperty.Create("IsConnected", typeof(bool), typeof(Button), true);
public bool IsNotConnected public bool IsConnected
{ {
get => (bool)GetValue(IsNotConnectedProperty); get => (bool)GetValue(IsConnectedProperty);
set => SetValue(IsNotConnectedProperty, value); set => SetValue(IsConnectedProperty, value);
} }
// bind NeedReturn // bind NeedReturn

Loading…
Cancel
Save