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());

@ -1,55 +1,43 @@
#if WINDOWS #if WINDOWS
using Microsoft.UI; using Microsoft.UI;
using Microsoft.UI.Windowing; using Microsoft.UI.Windowing;
using Windows.Graphics; using Windows.Graphics;
#endif #endif
using DataPersistence; using DataPersistence;
using Model; using Model;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using Model.Managers; using Model.Managers;
namespace Views 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
public User CurrentUser { get; set; }
//collection de recette de l'application /// <summary>
/// Get the current connected user.
/// </summary>
public User? CurrentUser { get; private set; }
/// <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) => UserAppTheme = AppTheme.Light;
{ MainPage = new Home();
#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;
MainPage = new Home();
//MainPage = new MyPosts();
}
}
}

@ -16,12 +16,13 @@
HorizontalOptions="Start" Padding="10, 10, 0, 0"/> HorizontalOptions="Start" Padding="10, 10, 0, 0"/>
<!-- Header --> <!-- Header -->
<ImageButton Source="person_default.png" HorizontalOptions="Center" <ImageButton Source="person_default.png" HorizontalOptions="Center"
BackgroundColor="{StaticResource Secondary}" BackgroundColor="{StaticResource Secondary}"
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"
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());
}
} }

@ -1,62 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:local="clr-namespace:Views" xmlns:local="clr-namespace:Views"
xmlns:model="clr-namespace:Model;assembly=Model" xmlns:model="clr-namespace:Model;assembly=Model"
x:Class="Views.Home"> x:Class="Views.Home">
<local:ContainerBase <local:ContainerBase
IsNotConnected="True"> IsNotConnected="True">
<!-- Flyout --> <!-- Flyout -->
<local:ContainerBase.MyFlyoutContent> <local:ContainerBase.MyFlyoutContent>
<VerticalStackLayout Grid.Row="1"> <VerticalStackLayout Grid.Row="1">
<!-- Research --> <!-- Research -->
<Button <Button
Text="Recherche" Text="Recherche"
ImageSource="search_icon.png" ImageSource="search_icon.png"
MaximumHeightRequest="20" MaximumHeightRequest="20"
Style="{StaticResource button1}"/> Style="{StaticResource button1}"/>
<SearchBar <SearchBar
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 -->
<Button <!-- Direct research -->
Text="Entrées" <Button
ImageSource="flatware_icon.png" Text="Entrées"
Style="{StaticResource button1}"/> ImageSource="flatware_icon.png"
<Button Style="{StaticResource button1}"/>
Text="Plats" <Button
ImageSource="room_service_icon.png" Text="Plats"
Style="{StaticResource button1}"/> ImageSource="room_service_icon.png"
<Button Style="{StaticResource button1}"/>
Text="Desserts" <Button
ImageSource="coffee_icon.png" Text="Desserts"
Style="{StaticResource button1}"/> ImageSource="coffee_icon.png"
</VerticalStackLayout> Style="{StaticResource button1}"/>
</local:ContainerBase.MyFlyoutContent> </VerticalStackLayout>
</local:ContainerBase.MyFlyoutContent>
<!-- Master -->
<local:ContainerBase.MyContent> <!-- Master -->
<ScrollView> <local:ContainerBase.MyContent>
<StackLayout BindingContext="{Binding AllRecipes}" MinimumWidthRequest="400"> <ScrollView>
<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}"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
FontSize="24" FontSize="24"
Padding="15"/> Padding="15"/>
<FlexLayout <FlexLayout
Margin="0, 15" Margin="0, 15"
Wrap="Wrap" Wrap="Wrap"
JustifyContent="Start" JustifyContent="Start"
AlignItems="Center" AlignItems="Center"
AlignContent="SpaceEvenly" AlignContent="SpaceEvenly"
HorizontalOptions="Center" HorizontalOptions="Center"
BindableLayout.ItemsSource="{Binding}"> BindableLayout.ItemsSource="{Binding}">
@ -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,17 +77,18 @@
<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>
</BindableLayout.ItemTemplate> </BindableLayout.ItemTemplate>
</FlexLayout> </FlexLayout>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
</local:ContainerBase.MyContent> </local:ContainerBase.MyContent>
</local:ContainerBase> </local:ContainerBase>
</ContentPage> </ContentPage>

@ -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 AllRecipes => (App.Current as App).AllRecipes; public RecipeCollection RecipesDisplayed { get; private set; }
public Home()
{
//DataMgr = new DataManager(new Stubs());
//AllRecipes = new RecipeCollection("Toutes les recettes", DataMgr.Data[nameof(Recipe)].Cast<Recipe>().ToArray());
InitializeComponent(); public Home()
{
RecipesDisplayed = AllRecipe;
InitializeComponent();
BindingContext = this; BindingContext = this;
} }
}
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
{
RecipesDisplayed = AllRecipe.ResearchByName((sender as SearchBar).Text);
}
}
} }

@ -11,9 +11,10 @@
<Image <Image
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>

@ -1,19 +1,24 @@
namespace Views; namespace Views;
public partial class ReturnButton : ContentView public partial class ReturnButton : ContentView
{ {
public ReturnButton() public ReturnButton()
{ {
InitializeComponent(); InitializeComponent();
} }
// 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);
public bool NeedReturn public bool NeedReturn
{ {
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