home working, little issue on search
continuous-integration/drone/push Build is passing Details

pull/56/head
Alexandre AGOSTINHO 2 years ago
parent d939560b4f
commit a2b75d2ce4

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class ReadOnlyObservableRecipeCollection : ReadOnlyObservableCollection<Recipe>
{
private RecipeCollection _recipeObserved;
public string Description => _recipeObserved.Description;
public ReadOnlyObservableRecipeCollection(RecipeCollection recipeCollection)
: base(recipeCollection)
{
_recipeObserved = recipeCollection;
}
}
}

@ -2,6 +2,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text; using System.Text;
namespace Model namespace Model
@ -31,6 +32,8 @@ namespace Model
_description = "No description."; _description = "No description.";
else else
_description = value; _description = value;
OnPropertyChanged(new PropertyChangedEventArgs("Description"));
} }
} }
#endregion #endregion

@ -8,8 +8,7 @@
x:Name="homepage"> x:Name="homepage">
<local:ContainerBase x:Name="container_base" <local:ContainerBase x:Name="container_base"
NeedReturn="False" NeedReturn="False">
IsConnected="True">
<!-- Flyout --> <!-- Flyout -->
<local:ContainerBase.MyFlyoutContent> <local:ContainerBase.MyFlyoutContent>
@ -20,7 +19,7 @@
Margin="20, 10, 15, 0"/> Margin="20, 10, 15, 0"/>
<SearchBar <SearchBar
Placeholder="Mots-clés (ex.: rapide, fromage)" Placeholder="Mots-clés (ex.: rapide, fromage)"
FontAttributes="Italic" TextColor="Black" TextColor="Black"
BackgroundColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray300}}" BackgroundColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray300}}"
Margin="15, 10, 15, 40" Margin="15, 10, 15, 40"
SearchButtonPressed="SearchBar_SearchButtonPressed"/> SearchButtonPressed="SearchBar_SearchButtonPressed"/>
@ -52,10 +51,11 @@
<!-- Master --> <!-- Master -->
<local:ContainerBase.MyContent> <local:ContainerBase.MyContent>
<ScrollView> <ScrollView>
<StackLayout BindingContext="{Binding RecipesDisplayed}" MinimumWidthRequest="400"> <StackLayout BindingContext="{Binding ., Source={x:Reference homepage}}"
MinimumWidthRequest="400">
<!--Modification du prof apportée sur le stacklayout pour empecher l'affichage d'une seule case recipe--> <!--Modification du prof apportée sur le stacklayout pour empecher l'affichage d'une seule case recipe-->
<Label <Label
Text="{Binding Description}" Text="{Binding RecipesDisplayed.Description}"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
FontSize="24" FontSize="24"
Padding="15"/> Padding="15"/>
@ -67,7 +67,7 @@
AlignItems="Center" AlignItems="Center"
AlignContent="SpaceEvenly" AlignContent="SpaceEvenly"
HorizontalOptions="Center" HorizontalOptions="Center"
BindableLayout.ItemsSource="{Binding}"> BindableLayout.ItemsSource="{Binding RecipesDisplayed}">
<BindableLayout.ItemTemplate> <BindableLayout.ItemTemplate>
<DataTemplate x:DataType="model:Recipe"> <DataTemplate x:DataType="model:Recipe">

@ -8,18 +8,14 @@ namespace Views
public MasterManager Master => (Application.Current as App).Master; public MasterManager Master => (Application.Current as App).Master;
private readonly RecipeCollection _recipesDisplayed; private readonly RecipeCollection _recipesDisplayed;
public ReadOnlyObservableCollection<Recipe> RecipesDisplayed { get; private set; } public ReadOnlyObservableRecipeCollection RecipesDisplayed { get; private set; }
public string Description => _recipesDisplayed.Description;
public static readonly BindableProperty IsNotConnectedProperty =
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(bool));
public Home() public Home()
{ {
_recipesDisplayed = Master.Recipe.GetAllRecipes(); _recipesDisplayed = Master.Recipe.GetAllRecipes();
RecipesDisplayed = new ReadOnlyObservableCollection<Recipe>(_recipesDisplayed); RecipesDisplayed = new ReadOnlyObservableRecipeCollection(_recipesDisplayed);
InitializeComponent(); InitializeComponent();

@ -17,7 +17,6 @@ public partial class ContainerBase : ContentView
public ContainerBase() public ContainerBase()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = this;
} }

Loading…
Cancel
Save