start home binding
continuous-integration/drone/push Build is passing Details

pull/65/head
Alexandre AGOSTINHO 2 years ago
parent 35b9317bd0
commit bd44ed2135

@ -68,6 +68,9 @@ namespace Model
/// <returns>A collection of Recipe where their Title contain the string.</returns> /// <returns>A collection of Recipe where their Title contain the string.</returns>
public RecipeCollection ResearchByName(string str) public RecipeCollection ResearchByName(string str)
{ {
if (string.IsNullOrEmpty(str))
return this;
return new RecipeCollection( return new RecipeCollection(
description: $"Results of the research: {str}", description: $"Results of the research: {str}",
recipes: this.FindAll(x => x.Title.ToLower().Contains(str.ToLower())).ToArray()); recipes: this.FindAll(x => x.Title.ToLower().Contains(str.ToLower())).ToArray());

@ -13,43 +13,31 @@ namespace Views
{ {
public partial class App : Application public partial class App : Application
{ {
//Point d'entrée de l'application /// <summary>
/// Master manager - access to the Model.
/// </summary>
public MasterManager MasterMgr { get; private set; } = new MasterManager(new Stubs()); public MasterManager MasterMgr { get; private set; } = new MasterManager(new Stubs());
//L'utilisateur courant de l'application /// <summary>
public User CurrentUser { get; set; } /// Get the current connected user.
/// </summary>
public User? CurrentUser { get; private set; }
//collection de recette de l'application /// <summary>
/// Get all the recipes loaded.
/// </summary>
public RecipeCollection AllRecipes { get; set; } public RecipeCollection AllRecipes { get; set; }
//const int WindowWidth = 1200;
//const int WindowHeight = 800;
public App() public App()
{ {
CurrentUser = MasterMgr.DataMgr.GetUsers().Last(); CurrentUser = MasterMgr.CurrentConnectedUser;
AllRecipes = MasterMgr.DataMgr.GetRecipes("All recipes"); AllRecipes = MasterMgr.DataMgr.GetRecipes("All recipes");
InitializeComponent(); InitializeComponent();
/*
Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) =>
{
#if WINDOWS
var mauiWindow = handler.VirtualView;
var nativeWindow = handler.PlatformView;
nativeWindow.Activate();
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow);
WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
appWindow.Resize(new SizeInt32(WindowWidth, WindowHeight));
#endif
});
*/
/* - Comment(ctrl-k + ctrl-c)/Uncomment(ctrl-k + ctrl-u) to change page - */
UserAppTheme = AppTheme.Light; UserAppTheme = AppTheme.Light;
MainPage = new Home(); MainPage = new Home();
//MainPage = new MyPosts();
} }
} }
} }

@ -21,7 +21,8 @@
CornerRadius="50" Margin="0, 30, 0, 10" CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black" BorderWidth="5" BorderColor="Black"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}" IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"
Grid.RowSpan="2"/> Grid.RowSpan="2"
Clicked="ProfileButton_Clicked"/>
</Grid> </Grid>
<Button Text="Connection" ImageSource="login_icon.png" <Button Text="Connection" ImageSource="login_icon.png"

@ -17,6 +17,7 @@ public partial class ContainerFlyout : ContentView
} }
#region Bindable XAML Properties
// Bind MyFlyoutContent // Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty = public static readonly BindableProperty MyFlyoutContentProperty =
BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerFlyout), new Grid()); BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerFlyout), new Grid());
@ -46,4 +47,10 @@ public partial class ContainerFlyout : ContentView
get => (bool)GetValue(NeedReturnProperty); get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value); set => SetValue(NeedReturnProperty, value);
} }
#endregion
public async void ProfileButton_Clicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new MyProfil());
}
} }

@ -22,7 +22,8 @@
Placeholder="Mots-clés (ex.: rapide, fromage)" Placeholder="Mots-clés (ex.: rapide, fromage)"
FontAttributes="Italic" TextColor="Black" FontAttributes="Italic" 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"/>
<!-- Direct research --> <!-- Direct research -->
<Button <Button
@ -43,7 +44,7 @@
<!-- Master --> <!-- Master -->
<local:ContainerBase.MyContent> <local:ContainerBase.MyContent>
<ScrollView> <ScrollView>
<StackLayout BindingContext="{Binding AllRecipes}" MinimumWidthRequest="400"> <StackLayout BindingContext="{Binding RecipesDisplayed}" 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 Description}"
@ -64,9 +65,10 @@
<DataTemplate x:DataType="model:Recipe"> <DataTemplate x:DataType="model:Recipe">
<Border Style="{StaticResource recipeCase}"> <Border Style="{StaticResource recipeCase}">
<Grid RowDefinitions="*, 40"> <Grid RowDefinitions="*, 40">
<!--<local:RecipeCase <!--<local:RecipeCase
CaseImageSource="room_service_icon.png" CaseImageSource="{Binding Image}"
Title="{Binding Title}"/>--> RecipeTitle="{Binding Title}"/>-->
<Image <Image
Grid.Row="0" VerticalOptions="Fill" Grid.Row="0" VerticalOptions="Fill"
@ -75,6 +77,7 @@
<Label <Label
Text="{Binding Title}" FontSize="18" Text="{Binding Title}" FontSize="18"
Grid.Row="1" HorizontalOptions="Center"/> Grid.Row="1" HorizontalOptions="Center"/>
</Grid> </Grid>
</Border> </Border>
</DataTemplate> </DataTemplate>

@ -1,22 +1,29 @@
using DataPersistence; using DataPersistence;
using Model; using Model;
using Model.Managers; using Model.Managers;
using System.ComponentModel;
namespace Views namespace Views
{ {
public partial class Home : ContentPage public partial class Home : ContentPage
{ {
public MasterManager MasterMgr => (App.Current as App).MasterMgr; public MasterManager MasterMgr => (App.Current as App).MasterMgr;
public User user => (App.Current as App).CurrentUser; public User? user => (App.Current as App).CurrentUser;
public RecipeCollection AllRecipe => (App.Current as App).AllRecipes;
public RecipeCollection RecipesDisplayed { get; private set; }
public RecipeCollection AllRecipes => (App.Current as App).AllRecipes;
public Home() public Home()
{ {
//DataMgr = new DataManager(new Stubs()); RecipesDisplayed = AllRecipe;
//AllRecipes = new RecipeCollection("Toutes les recettes", DataMgr.Data[nameof(Recipe)].Cast<Recipe>().ToArray());
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = this;
} }
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
{
RecipesDisplayed = AllRecipe.ResearchByName((sender as SearchBar).Text);
}
} }
} }

@ -12,8 +12,9 @@
Grid.Row="0" VerticalOptions="Fill" Grid.Row="0" VerticalOptions="Fill"
Source="{Binding CaseImageSource, Source={x:Reference rCase}}"/> Source="{Binding CaseImageSource, Source={x:Reference rCase}}"/>
<Label Text="{Binding Title, Source={x:Reference rCase}}" FontSize="18" <Label
Grid.Row="1" HorizontalOptions="Center"/> Grid.Row="1" HorizontalOptions="Center"
Text="{Binding RecipeTitle, Source={x:Reference rCase}}"/>
</Grid> </Grid>
</Border> </Border>

@ -16,12 +16,12 @@ public partial class RecipeCase : ContentView
set => SetValue(CaseImageSourceProperty, value); set => SetValue(CaseImageSourceProperty, value);
} }
public static readonly BindableProperty TitleProperty = public static readonly BindableProperty RecipeTitleProperty =
BindableProperty.Create("Title", typeof(string), typeof(Label)); BindableProperty.Create("RecipeTitle", typeof(string), typeof(Label));
public string Title public string RecipeTitle
{ {
get => (string)GetValue(TitleProperty); get => (string)GetValue(RecipeTitleProperty);
set => SetValue(TitleProperty, value); set => SetValue(RecipeTitleProperty, value);
} }
} }

@ -16,7 +16,8 @@
<ImageButton Source="arrow_back_icon.png" <ImageButton Source="arrow_back_icon.png"
HorizontalOptions="Center" VerticalOptions="Center" HorizontalOptions="Center" VerticalOptions="Center"
Aspect="Center" Scale="0.7"/> Aspect="Center" Scale="0.7"
Clicked="ImageButton_Clicked"/>
</Border> </Border>
</ContentView> </ContentView>

@ -16,4 +16,9 @@ public partial class ReturnButton : ContentView
get => (bool)GetValue(NeedReturnProperty); get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value); set => SetValue(NeedReturnProperty, value);
} }
private async void ImageButton_Clicked(object sender, EventArgs e)
{
await Navigation.PopModalAsync();
}
} }

Loading…
Cancel
Save