From e5ad35c0a0f042d267ce2bce02807f4ec054a65a Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Mon, 5 Jun 2023 14:31:45 +0200 Subject: [PATCH] work on user dysplay name on flayout page --- MCTG/Managers/UserDefaultManager.cs | 22 ++++++++++-- MCTG/Views/ContentPages/Home.xaml | 6 ++-- MCTG/Views/ContentPages/Home.xaml.cs | 20 +++-------- MCTG/Views/ContentPages/MyPosts.xaml | 2 +- MCTG/Views/ContentPages/MyProfil.xaml | 2 +- MCTG/Views/ContentViews/ContainerBase.xaml | 3 +- MCTG/Views/ContentViews/ContainerBase.xaml.cs | 35 ++++++++----------- MCTG/Views/ContentViews/ContainerFlyout.xaml | 20 ++++++----- .../ContentViews/ContainerFlyout.xaml.cs | 10 +++--- 9 files changed, 60 insertions(+), 60 deletions(-) diff --git a/MCTG/Managers/UserDefaultManager.cs b/MCTG/Managers/UserDefaultManager.cs index db94186..f4a289f 100644 --- a/MCTG/Managers/UserDefaultManager.cs +++ b/MCTG/Managers/UserDefaultManager.cs @@ -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) diff --git a/MCTG/Views/ContentPages/Home.xaml b/MCTG/Views/ContentPages/Home.xaml index 60f2a66..1f2536b 100644 --- a/MCTG/Views/ContentPages/Home.xaml +++ b/MCTG/Views/ContentPages/Home.xaml @@ -7,9 +7,9 @@ x:Class="Views.Home" x:Name="homepage"> - + diff --git a/MCTG/Views/ContentPages/Home.xaml.cs b/MCTG/Views/ContentPages/Home.xaml.cs index 508484e..6fe6b17 100644 --- a/MCTG/Views/ContentPages/Home.xaml.cs +++ b/MCTG/Views/ContentPages/Home.xaml.cs @@ -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"); } diff --git a/MCTG/Views/ContentPages/MyPosts.xaml b/MCTG/Views/ContentPages/MyPosts.xaml index d77a15b..b99ae2f 100644 --- a/MCTG/Views/ContentPages/MyPosts.xaml +++ b/MCTG/Views/ContentPages/MyPosts.xaml @@ -6,7 +6,7 @@ Title="MyPosts"> diff --git a/MCTG/Views/ContentPages/MyProfil.xaml b/MCTG/Views/ContentPages/MyProfil.xaml index 9faedb3..74465e5 100644 --- a/MCTG/Views/ContentPages/MyProfil.xaml +++ b/MCTG/Views/ContentPages/MyProfil.xaml @@ -7,7 +7,7 @@ Title="MyProfil"> diff --git a/MCTG/Views/ContentViews/ContainerBase.xaml b/MCTG/Views/ContentViews/ContainerBase.xaml index 4a45c77..86d3314 100644 --- a/MCTG/Views/ContentViews/ContainerBase.xaml +++ b/MCTG/Views/ContentViews/ContainerBase.xaml @@ -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"> diff --git a/MCTG/Views/ContentViews/ContainerBase.xaml.cs b/MCTG/Views/ContentViews/ContainerBase.xaml.cs index 422f0d5..d8e0eba 100644 --- a/MCTG/Views/ContentViews/ContainerBase.xaml.cs +++ b/MCTG/Views/ContentViews/ContainerBase.xaml.cs @@ -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); - } } diff --git a/MCTG/Views/ContentViews/ContainerFlyout.xaml b/MCTG/Views/ContentViews/ContainerFlyout.xaml index 2bfe91d..4acf519 100644 --- a/MCTG/Views/ContentViews/ContainerFlyout.xaml +++ b/MCTG/Views/ContentViews/ContainerFlyout.xaml @@ -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"/> +