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

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

@ -13,20 +13,7 @@ namespace Views
public static readonly BindableProperty IsNotConnectedProperty =
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()
@ -37,8 +24,9 @@ namespace Views
InitializeComponent();
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">
<local:ContainerBase
IsNotConnected="False"
IsConnected="False"
NeedReturn="True">
<local:ContainerBase.MyFlyoutContent>

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

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

@ -2,11 +2,26 @@ namespace Views;
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()
{
InitializeComponent();
BindingContext = this;
}
// Bind MyContent
public static readonly BindableProperty MyContentProperty =
BindableProperty.Create("MyContent", typeof(View), typeof(ContainerBase), new Grid());
@ -26,24 +41,4 @@ public partial class ContainerBase : ContentView
get => (View)GetValue(MyFlyoutContentProperty);
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"
CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"
IsVisible="{Binding IsConnected, Source={x:Reference fl}}"
Grid.RowSpan="2"
Clicked="ProfileButton_Clicked"/>
</Grid>
<!-- Connection button -->
<Button Text="Connection" ImageSource="login_icon.png"
Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Source={x:Reference fl}}"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"
Margin="15, 120"
IsVisible="{Binding IsConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}"
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}"
HorizontalOptions="Center" Margin="0,15"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
<Label Text="{Binding Surname}"
HorizontalOptions="Center"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
</StackLayout>
</VerticalStackLayout>
@ -56,7 +58,7 @@
<!-- Footer -->
<Button Text="Déconnection" ImageSource="logout_icon.png"
Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}"/>
IsVisible="{Binding IsConnected, Source={x:Reference fl}}"/>
</VerticalStackLayout>
</Grid>

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

Loading…
Cancel
Save