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

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

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

@ -1,9 +1,26 @@
using Model;
namespace Views;
public partial class Login : ContentPage
{
MasterManager Master => (Application.Current as App).Master;
public Login()
{
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">
<local:ContainerBase
IsConnected="False"
NeedReturn="True">
<local:ContainerBase.MyFlyoutContent>

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

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

@ -20,7 +20,7 @@
WidthRequest="100" HeightRequest="100"
CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black"
IsVisible="{Binding IsConnected, Source={x:Reference fl}}"
IsVisible="{Binding ConnectedUser, Converter={toolkit:IsNotNullConverter}}"
Grid.RowSpan="2"
Clicked="ProfileButton_Clicked"/>
</Grid>
@ -29,7 +29,7 @@
<Button Text="Connection" ImageSource="login_icon.png"
Style="{StaticResource button2}"
Margin="15, 50"
IsVisible="{Binding IsConnected, Converter={toolkit:InvertedBoolConverter}, Source={x:Reference fl}}"
IsVisible="{Binding ConnectedUser, Converter={toolkit:IsNullConverter}}"
Clicked="ConnectionButton_Clicked"/>
<!-- Display name -->
@ -39,7 +39,7 @@
AlignItems="Center"
HorizontalOptions="Center"
BindingContext="{Binding ConnectedUser}"
IsVisible="{Binding IsConnected, Source={x:Reference fl}}">
IsVisible="{Binding ., Converter={toolkit:IsNotNullConverter}}">
<Label Text="{Binding Name}"
HorizontalOptions="Center" Margin="2,0"
@ -67,7 +67,7 @@
<!-- Footer -->
<Button Text="Déconnection" ImageSource="logout_icon.png"
Style="{StaticResource button2}"
IsVisible="{Binding IsConnected, Source={x:Reference fl}}"/>
IsVisible="{Binding ConnectedUser, Converter={toolkit:IsNotNullConverter}}"/>
</VerticalStackLayout>
</Grid>

@ -27,16 +27,6 @@ public partial class ContainerFlyout : ContentView
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
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);

Loading…
Cancel
Save