rm IsConnected, use converter insted - bug: no view update on connection

pull/60/head
Alexandre AGOSTINHO 2 years ago
parent 842c6af17c
commit c4d3ed2043

@ -30,7 +30,7 @@
ImageSource="home_icon.png" ImageSource="home_icon.png"
Style="{StaticResource button1}" Style="{StaticResource button1}"
Clicked="Suggestions_Clicked" Clicked="Suggestions_Clicked"
IsVisible="{Binding IsConnected, Source={x:Reference container_base}}"/> IsVisible="{Binding Master.User.CurrentConnected, Source={x:Reference homepage}, Converter={toolkit:IsNotNullConverter}}"/>
<Button <Button
Text="Toutes les recettes" Text="Toutes les recettes"
ImageSource="home_icon.png" ImageSource="home_icon.png"

@ -16,19 +16,21 @@ namespace Views
{ {
// Master.User.LogIn("pedrosamigos@hotmail.com", "pamigos"); // Master.User.LogIn("pedrosamigos@hotmail.com", "pamigos");
_recipesDisplayed = Master.Recipe.GetAllRecipes();
if (Master.User.CurrentConnected is null) if (Master.User.CurrentConnected is null)
{
_recipesDisplayed = Master.Recipe.GetAllRecipes();
_recipesDisplayed.Description = "Toutes les recettes"; _recipesDisplayed.Description = "Toutes les recettes";
}
else else
{
_recipesDisplayed = Master.Recipe.GetRecipesByPriorityOrder(Master.User.CurrentConnected.Priorities);
_recipesDisplayed.Description = "Suggestions"; _recipesDisplayed.Description = "Suggestions";
}
RecipesDisplayed = new ReadOnlyObservableRecipeCollection(_recipesDisplayed); RecipesDisplayed = new ReadOnlyObservableRecipeCollection(_recipesDisplayed);
InitializeComponent(); InitializeComponent();
container_base.IsConnected = Master.User.CurrentConnected is not null;
suggestions_button.IsVisible = container_base.IsConnected;
BindingContext = this; BindingContext = this;
} }

@ -5,6 +5,7 @@
xmlns:local="clr-namespace:Views" xmlns:local="clr-namespace:Views"
Title="Login" Title="Login"
x:Name="nlogin"> x:Name="nlogin">
<VerticalStackLayout> <VerticalStackLayout>
<local:MiniHeader <local:MiniHeader
TitleMini="Connection" TitleMini="Connection"
@ -12,14 +13,16 @@
HeightRequest="100"/> HeightRequest="100"/>
<Grid ColumnDefinitions="350,*,350"> <Grid ColumnDefinitions="350,*,350">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Login -->
<Label Grid.Column="1" <Label Grid.Column="1"
Grid.Row="0" Grid.Row="0"
Text="Login :" Text="Login :"
@ -27,10 +30,13 @@
FontSize="Medium" FontSize="Medium"
Padding="0,50,0,10" Padding="0,50,0,10"
MinimumWidthRequest="200"/> MinimumWidthRequest="200"/>
<Entry Grid.Column="1" <Entry x:Name="login_entry"
Grid.Column="1"
Grid.Row="1" Grid.Row="1"
BackgroundColor="#D1E8E2" BackgroundColor="#D1E8E2"
Margin="0,0,0,20"/> Margin="0,0,0,20"/>
<!-- Password -->
<Label Grid.Column="1" <Label Grid.Column="1"
Grid.Row="2" Grid.Row="2"
Text="Mot de passe :" Text="Mot de passe :"
@ -38,22 +44,29 @@
FontSize="Medium" FontSize="Medium"
Padding="0,50,0,10" Padding="0,50,0,10"
MinimumWidthRequest="200"/> MinimumWidthRequest="200"/>
<Entry Grid.Column="1" <Entry x:Name="passwd_entry"
Grid.Column="1"
Grid.Row="3" Grid.Row="3"
BackgroundColor="#D1E8E2" BackgroundColor="#D1E8E2"
Margin="0,0,0,50"/> Margin="0,0,0,50"/>
<CheckBox Grid.Column="1"
<!-- Checkbox first login -->
<CheckBox x:Name="firstLogin_checkbox"
Grid.Column="1"
Grid.Row="4"/> Grid.Row="4"/>
<Label Grid.Column="1" <Label Grid.Column="1"
Grid.Row="4" Grid.Row="4"
Text="première connection" Text="première connection"
Margin="50,0,0,0" Margin="50,0,0,0"
FontAttributes="Italic"/> FontAttributes="Italic"/>
<!-- Return button -->
<Button BackgroundColor="#D1E8E2" <Button BackgroundColor="#D1E8E2"
Grid.Column="1" Grid.Column="1"
Grid.Row="5"/> Grid.Row="5"
Clicked="LoginButton_Clicked"/>
</Grid> </Grid>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

@ -1,9 +1,26 @@
using Model;
namespace Views; namespace Views;
public partial class Login : ContentPage public partial class Login : ContentPage
{ {
MasterManager Master => (Application.Current as App).Master;
public Login() public Login()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = Master.User;
} }
}
private void LoginButton_Clicked(object sender, EventArgs e)
{
if (!Master.User.LogIn(login_entry.Text, passwd_entry.Text))
{
DisplayAlert("Wrong informations", "No mail or an incorrect password have been entered.", "OK");
}
else
{
Navigation.PopModalAsync();
}
}
}

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

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

@ -1,43 +1,37 @@
namespace Views; 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 public bool NeedReturn
{ {
get => container_flayout.NeedReturn; get => container_flayout.NeedReturn;
set => container_flayout.NeedReturn = value; set => container_flayout.NeedReturn = value;
} }
public ContainerBase() public ContainerBase()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = this; 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());
public View MyContent public View MyContent
{ {
get => (View)GetValue(MyContentProperty); get => (View)GetValue(MyContentProperty);
set => SetValue(MyContentProperty, value); set => SetValue(MyContentProperty, value);
} }
// Bind MyFlyoutContent // Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty = public static readonly BindableProperty MyFlyoutContentProperty =
BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerBase), new Grid()); BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerBase), new Grid());
public View MyFlyoutContent public View MyFlyoutContent
{ {
get => (View)GetValue(MyFlyoutContentProperty); get => (View)GetValue(MyFlyoutContentProperty);
set => SetValue(MyFlyoutContentProperty, value); set => SetValue(MyFlyoutContentProperty, value);
} }
} }

@ -20,7 +20,7 @@
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"
IsVisible="{Binding IsConnected, Source={x:Reference fl}}" IsVisible="{Binding ConnectedUser, Converter={toolkit:IsNotNullConverter}}"
Grid.RowSpan="2" Grid.RowSpan="2"
Clicked="ProfileButton_Clicked"/> Clicked="ProfileButton_Clicked"/>
</Grid> </Grid>
@ -29,7 +29,7 @@
<Button Text="Connection" ImageSource="login_icon.png" <Button Text="Connection" ImageSource="login_icon.png"
Style="{StaticResource button2}" Style="{StaticResource button2}"
Margin="15, 50" Margin="15, 50"
IsVisible="{Binding IsConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}" IsVisible="{Binding ConnectedUser, Converter={toolkit:IsNullConverter}}"
Clicked="ConnectionButton_Clicked"/> Clicked="ConnectionButton_Clicked"/>
<!-- Display name --> <!-- Display name -->
@ -39,7 +39,7 @@
AlignItems="Center" AlignItems="Center"
HorizontalOptions="Center" HorizontalOptions="Center"
BindingContext="{Binding ConnectedUser}" BindingContext="{Binding ConnectedUser}"
IsVisible="{Binding IsConnected, Source={x:Reference fl}}"> IsVisible="{Binding ., Converter={toolkit:IsNotNullConverter}}">
<Label Text="{Binding Name}" <Label Text="{Binding Name}"
HorizontalOptions="Center" Margin="2,0" HorizontalOptions="Center" Margin="2,0"
@ -67,7 +67,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 IsConnected, Source={x:Reference fl}}"/> IsVisible="{Binding ConnectedUser, Converter={toolkit:IsNotNullConverter}}"/>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>

@ -27,16 +27,6 @@ public partial class ContainerFlyout : ContentView
set => SetValue(MyFlyoutContentProperty, value); set => SetValue(MyFlyoutContentProperty, value);
} }
// Bind IsNotConnected
public static readonly BindableProperty IsConnectedProperty =
BindableProperty.Create("IsConnected", typeof(bool), typeof(Button), true);
public bool IsConnected
{
get => (bool)GetValue(IsConnectedProperty);
set => SetValue(IsConnectedProperty, value);
}
// bind NeedReturn // bind NeedReturn
public static readonly BindableProperty NeedReturnProperty = public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false); BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);

Loading…
Cancel
Save