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>
public RecipeCollection ResearchByName(string str)
{
if (string.IsNullOrEmpty(str))
return this;
return new RecipeCollection(
description: $"Results of the research: {str}",
recipes: this.FindAll(x => x.Title.ToLower().Contains(str.ToLower())).ToArray());

@ -1,55 +1,43 @@
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
using DataPersistence;
using Model;
using System.Collections.ObjectModel;
using Model.Managers;
namespace Views
{
public partial class App : Application
namespace Views
{
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());
//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; }
//const int WindowWidth = 1200;
//const int WindowHeight = 800;
public App()
{
CurrentUser = MasterMgr.DataMgr.GetUsers().Last();
public App()
{
CurrentUser = MasterMgr.CurrentConnectedUser;
AllRecipes = MasterMgr.DataMgr.GetRecipes("All recipes");
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;
MainPage = new Home();
//MainPage = new MyPosts();
}
}
}
InitializeComponent();
UserAppTheme = AppTheme.Light;
MainPage = new Home();
}
}
}

@ -16,12 +16,13 @@
HorizontalOptions="Start" Padding="10, 10, 0, 0"/>
<!-- Header -->
<ImageButton Source="person_default.png" HorizontalOptions="Center"
BackgroundColor="{StaticResource Secondary}"
WidthRequest="100" HeightRequest="100"
CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"
Grid.RowSpan="2"/>
BackgroundColor="{StaticResource Secondary}"
WidthRequest="100" HeightRequest="100"
CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"
Grid.RowSpan="2"
Clicked="ProfileButton_Clicked"/>
</Grid>
<Button Text="Connection" ImageSource="login_icon.png"

@ -17,6 +17,7 @@ public partial class ContainerFlyout : ContentView
}
#region Bindable XAML Properties
// Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty =
BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerFlyout), new Grid());
@ -46,4 +47,10 @@ public partial class ContainerFlyout : ContentView
get => (bool)GetValue(NeedReturnProperty);
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" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:local="clr-namespace:Views"
xmlns:model="clr-namespace:Model;assembly=Model"
x:Class="Views.Home">
<local:ContainerBase
IsNotConnected="True">
<!-- Flyout -->
<local:ContainerBase.MyFlyoutContent>
<VerticalStackLayout Grid.Row="1">
<!-- Research -->
<Button
Text="Recherche"
ImageSource="search_icon.png"
MaximumHeightRequest="20"
Style="{StaticResource button1}"/>
<SearchBar
Placeholder="Mots-clés (ex.: rapide, fromage)"
FontAttributes="Italic" TextColor="Black"
BackgroundColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray300}}"
Margin="15, 10, 15, 40"/>
<!-- Direct research -->
<Button
Text="Entrées"
ImageSource="flatware_icon.png"
Style="{StaticResource button1}"/>
<Button
Text="Plats"
ImageSource="room_service_icon.png"
Style="{StaticResource button1}"/>
<Button
Text="Desserts"
ImageSource="coffee_icon.png"
Style="{StaticResource button1}"/>
</VerticalStackLayout>
</local:ContainerBase.MyFlyoutContent>
<!-- Master -->
<local:ContainerBase.MyContent>
<ScrollView>
<StackLayout BindingContext="{Binding AllRecipes}" MinimumWidthRequest="400">
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:local="clr-namespace:Views"
xmlns:model="clr-namespace:Model;assembly=Model"
x:Class="Views.Home">
<local:ContainerBase
IsNotConnected="True">
<!-- Flyout -->
<local:ContainerBase.MyFlyoutContent>
<VerticalStackLayout Grid.Row="1">
<!-- Research -->
<Button
Text="Recherche"
ImageSource="search_icon.png"
MaximumHeightRequest="20"
Style="{StaticResource button1}"/>
<SearchBar
Placeholder="Mots-clés (ex.: rapide, fromage)"
FontAttributes="Italic" TextColor="Black"
BackgroundColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray300}}"
Margin="15, 10, 15, 40"
SearchButtonPressed="SearchBar_SearchButtonPressed"/>
<!-- Direct research -->
<Button
Text="Entrées"
ImageSource="flatware_icon.png"
Style="{StaticResource button1}"/>
<Button
Text="Plats"
ImageSource="room_service_icon.png"
Style="{StaticResource button1}"/>
<Button
Text="Desserts"
ImageSource="coffee_icon.png"
Style="{StaticResource button1}"/>
</VerticalStackLayout>
</local:ContainerBase.MyFlyoutContent>
<!-- Master -->
<local:ContainerBase.MyContent>
<ScrollView>
<StackLayout BindingContext="{Binding RecipesDisplayed}" MinimumWidthRequest="400">
<!--Modification du prof apportée sur le stacklayout pour empecher l'affichage d'une seule case recipe-->
<Label
Text="{Binding Description}"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
FontSize="24"
Padding="15"/>
<FlexLayout
Margin="0, 15"
Wrap="Wrap"
JustifyContent="Start"
AlignItems="Center"
AlignContent="SpaceEvenly"
<FlexLayout
Margin="0, 15"
Wrap="Wrap"
JustifyContent="Start"
AlignItems="Center"
AlignContent="SpaceEvenly"
HorizontalOptions="Center"
BindableLayout.ItemsSource="{Binding}">
@ -64,9 +65,10 @@
<DataTemplate x:DataType="model:Recipe">
<Border Style="{StaticResource recipeCase}">
<Grid RowDefinitions="*, 40">
<!--<local:RecipeCase
CaseImageSource="room_service_icon.png"
Title="{Binding Title}"/>-->
CaseImageSource="{Binding Image}"
RecipeTitle="{Binding Title}"/>-->
<Image
Grid.Row="0" VerticalOptions="Fill"
@ -75,17 +77,18 @@
<Label
Text="{Binding Title}" FontSize="18"
Grid.Row="1" HorizontalOptions="Center"/>
</Grid>
</Border>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</StackLayout>
</ScrollView>
</local:ContainerBase.MyContent>
</local:ContainerBase>
</ContentPage>
</FlexLayout>
</StackLayout>
</ScrollView>
</local:ContainerBase.MyContent>
</local:ContainerBase>
</ContentPage>

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

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

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

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

@ -1,19 +1,24 @@
namespace Views;
public partial class ReturnButton : ContentView
{
public ReturnButton()
{
InitializeComponent();
}
// bind NeedReturn
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);
public bool NeedReturn
{
get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value);
}
}
namespace Views;
public partial class ReturnButton : ContentView
{
public ReturnButton()
{
InitializeComponent();
}
// bind NeedReturn
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);
public bool NeedReturn
{
get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value);
}
private async void ImageButton_Clicked(object sender, EventArgs e)
{
await Navigation.PopModalAsync();
}
}

Loading…
Cancel
Save