modification de la recette(ajout image), copie du home xaml et cs, binding profil
continuous-integration/drone/push Build is passing Details

pull/48/head
Roxane ROSSETTO 2 years ago
parent 96954e6c94
commit 924d66dbe2

@ -25,7 +25,7 @@ dataMgr.Serializer = new DataContractXML();
//dataMgr.Import<Recipe>("C:\\Users\\alex6\\Downloads\\recipe2.json");
PasswordManager passwordManager = new PasswordManager();
RecipeCollection rc = new RecipeCollection("All recipes", dataMgr.Data[nameof(Recipe)].Cast<Recipe>().ToArray());
//RecipeCollection rc = new RecipeCollection("All recipes", dataMgr.Data[nameof(Recipe)].Cast<Recipe>().ToArray());
User user = dataMgr.Data[nameof(User)].Cast<User>().Last();

@ -23,14 +23,18 @@ namespace DataPersistence
new List<object>(new[]
{
new Recipe(
title: "Cookies classiques", id: null,
title: "Cookies classiques",
picture : "room_service_icon.png",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Faire cuire."),
new PreparationStep(2, "Manger.")
}),
new Recipe(
title: "Cookies au chocolat", id: null,
title: "Cookies au chocolat",
picture : "",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Moulinez la pâte."),
@ -38,34 +42,39 @@ namespace DataPersistence
new PreparationStep(3, "Sortir du four et mettre dans un plat.")
}),
new Recipe(
title: "Gateau nature", id: null,
title: "Gateau nature",
picture : "dotnet_bot.svg",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Achetez les ingrédients."),
new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."),
new PreparationStep(3, "Pleurez.")
}),
new Recipe(
title: "Gateau au pommes", id: null,
new Recipe(
title: "Gateau nature",
picture : "dotnet_bot.svg",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Achetez les légumes."),
new PreparationStep(2, "Préparez le plat. Ustensiles et préchauffez le four."),
new PreparationStep(3, "Coupez les pommes en morceaux et disposez-les sur le plat."),
new PreparationStep(4, "Mettez enfin le plat au four, puis une fois cuit, dégustez !")
new PreparationStep(1, "Achetez les ingrédients."),
new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."),
new PreparationStep(3, "Pleurez.")
}),
new Recipe(
title: "Gateau au chocolat", id: null,
new Recipe(
title: "Gateau nature",
picture : "dotnet_bot.svg",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Ajouter les oeufs."),
new PreparationStep(2, "Ajouter la farine."),
new PreparationStep(3, "Ajouter 100g de chocolat fondu."),
new PreparationStep(4, "Mélanger le tout."),
new PreparationStep(5, "Faire cuire 45h au four traditionnel.")
new PreparationStep(1, "Achetez les ingrédients."),
new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."),
new PreparationStep(3, "Pleurez.")
}),
new Recipe(
title: "Dinde au jambon", id: null,
title: "Dinde au jambon",
picture : "",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Faire une cuisson bien sec de la dinde à la poêle"),
@ -75,16 +84,15 @@ namespace DataPersistence
new PreparationStep(5, "Présentez sur un plat la dinde et le jambon : Miam !")
}),
new Recipe(
title: "Poulet au curry", id: null,
title: "Gateau nature",
picture : "dotnet_bot.svg",
id: null,
preparationSteps: new[]
{
new PreparationStep(1, "Trouvez des épices de curry."),
new PreparationStep(2, "Trouvez maintenant du poulet."),
new PreparationStep(3, "Coupez la tête du poulet et posez-la dans un plat."),
new PreparationStep(4, "Parsemez d'épices curry la tête de la poule."),
new PreparationStep(5, "Mettre le tout au four traditionnel 30min."),
new PreparationStep(6, "Dégustez en famille !")
})
new PreparationStep(1, "Achetez les ingrédients."),
new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."),
new PreparationStep(3, "Pleurez.")
}),
})
#endregion
},

@ -16,6 +16,9 @@ namespace Model
#region Attributes
[DataMember(Name = "title")]
private string _title = "";
[DataMember(Name = "image")]
private string _image = "";
#endregion
#region Properties
@ -47,6 +50,21 @@ namespace Model
}
}
/// <summary>
/// The image of the recipe. <br/>
/// Set to "room_service_icon.png" when the value passed is null, empty or contain white space.
/// </summary>
public string Image
{
get => _image;
set
{
if (!string.IsNullOrWhiteSpace(value))
_image = "room_service_icon.png";
_image = value;
}
}
/// <summary>
/// The steps of the preparation. See: <see cref="PreparationStep"/>.
/// </summary>
@ -61,11 +79,12 @@ namespace Model
/// <param name="title">The title of the recipe</param>
/// <param name="id">The id of the recipe. If not given, get a new id.</param>
/// <param name="preparationSteps">The steps of the preparation of the meal</param>
public Recipe(string title, int? id,
public Recipe(string title, string picture, int? id,
List<Review> reviews,
params PreparationStep[] preparationSteps)
{
Title = title;
Image = picture;
PreparationSteps = new List<PreparationStep>(preparationSteps);
Reviews = reviews;
@ -83,8 +102,8 @@ namespace Model
/// <inheritdoc cref="Recipe.Recipe(string, int?, List{Review}, PreparationStep[])"/>
/// </summary>
/// <param name="title">The title of the recipe.</param>
public Recipe(string title)
: this(title, null, new List<Review>())
public Recipe(string title, string picture)
: this(title, picture, null, new List<Review>())
{
}
@ -94,7 +113,7 @@ namespace Model
/// <param name="title">The title of the recipe.</param>
/// <param name="preparationSteps">The steps of the preparation of the meal.</param>
public Recipe(string title, params PreparationStep[] preparationSteps)
: this(title, null, new List<Review>(), preparationSteps)
: this(title, picture : null, null, new List<Review>(), preparationSteps)
{
}
@ -104,8 +123,8 @@ namespace Model
/// <param name="title">The title of the recipe.</param>
/// <param name="id">The id of the recipe. If not given, get a new id.</param>
/// <param name="preparationSteps">The steps of the preparation of the meal.</param>
public Recipe(string title, int? id, params PreparationStep[] preparationSteps)
: this(title, id, new List<Review>(), preparationSteps)
public Recipe(string title, string picture, int? id, params PreparationStep[] preparationSteps)
: this(title, picture, id, new List<Review>(), preparationSteps)
{
}
#endregion

@ -4,10 +4,10 @@
x:Class="Views.AddRecipe"
Title="AddRecipe"
xmlns:local="clr-namespace:Views">
<VerticalStackLayout>
<local:MiniHeader
TitleMini="Ajouter une recette"
NeedReturn="True"
<VerticalStackLayout>
<local:MiniHeader
TitleMini="Ajouter une recette"
NeedReturn="True"
HeightRequest="100"/>
<Grid ColumnDefinitions="auto, *"
RowDefinitions="auto,auto,auto,auto,auto,auto, auto, auto, auto"
@ -25,34 +25,34 @@
<Label Text="Dessert" Grid.Row="3" Margin="185,20"/>
<Label Text="Type de priorité" Grid.Row="4"/>
<Grid BackgroundColor="#D1E8E2"
MinimumHeightRequest="100"
MaximumWidthRequest="300"
Padding="20"
Grid.Row="5">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Recettes économiques" Grid.Row="0" Padding="5,0,0,0"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="1" />
<Label Text="Recettes rapides" Grid.Row="2"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="3" />
<Label Text="Recettes simples" Grid.Row="4"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="5" />
<Label Text="Recettes légères" Grid.Row="6"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="7" />
<Label Text="Recettes gourmandes" Grid.Row="8"/>
<Grid BackgroundColor="#D1E8E2"
MinimumHeightRequest="100"
MaximumWidthRequest="300"
Padding="20"
Grid.Row="5">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Recettes économiques" Grid.Row="0" Padding="5,0,0,0"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="1" />
<Label Text="Recettes rapides" Grid.Row="2"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="3" />
<Label Text="Recettes simples" Grid.Row="4"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="5" />
<Label Text="Recettes légères" Grid.Row="6"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="7" />
<Label Text="Recettes gourmandes" Grid.Row="8"/>
</Grid>
<Label Text="Saisir les étapes de la recette " Grid.Row="6" Margin="0,15"/>
<Entry Placeholder="Etape de la recette" Grid.Row="7" Margin="12,0"/>
@ -62,15 +62,15 @@
</HorizontalStackLayout>
<Label Text="Saisir les ingrédients de la recette" Grid.Row="6" Grid.Column="1" Margin="50,15"/>
<HorizontalStackLayout Grid.Row="7" Grid.Column="1">
<Entry Placeholder="Nom de l'ingrédient" Margin="12,0,50,0" WidthRequest="500"/>
<Picker Title="Unité" >
<Entry Placeholder="Nom de l'ingrédient" Margin="12,0,50,0" WidthRequest="500"/>
<Picker Title="Unité">
</Picker>
</HorizontalStackLayout>
<HorizontalStackLayout Grid.Row="8" Grid.Column="1" Margin="20">
<Button WidthRequest="100" Text="Précédent" TextColor="Black" Margin="20,0,20,0"/>
<Button WidthRequest="100" Text="Ajouter" TextColor="Black" Margin="20,0"/>
</HorizontalStackLayout>
</HorizontalStackLayout>

@ -8,7 +8,6 @@ namespace Views
public partial class AddRecipe : ContentPage
{
public DataManager DataMgr => (App.Current as App).DataMgr;
public Ingredient ingredient;
public AddRecipe()
{

@ -1,7 +1,7 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Vue"
xmlns:local="clr-namespace:Views"
x:Class="Views.App">
<Application.Resources>
<ResourceDictionary>

@ -6,38 +6,49 @@ using Windows.Graphics;
using DataPersistence;
using Model;
using System.Collections.ObjectModel;
namespace Views
{
public partial class App : Application
{
{
//Point d'entrée de l'application
public DataManager DataMgr { get; private set; } = new DataManager(new Stubs());
public User user { get; set; }
//L'utilisateur courant de l'application
public User CurrentUser { get; set; }
//collection de recette de l'application
public RecipeCollection AllRecipes { get; set; }
const int WindowWidth = 1200;
const int WindowHeight = 800;
public App()
{
user = DataMgr.Data[nameof(User)].Cast<User>().Last();
CurrentUser = DataMgr.Data[nameof(User)].Cast<User>().Last();
AllRecipes = DataMgr.Data[nameof(RecipeCollection)]
.Cast<RecipeCollection>()
.ToArray();
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
});
// 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 AddRecipe();
MainPage = new MyProfil();
//MainPage = new MyPosts();
}
}

@ -1,66 +1,107 @@
<?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"
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>
<Label Text="Suggestions" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
FontSize="24" Padding="15"/>
<FlexLayout
Margin="0, 15"
Wrap="Wrap"
JustifyContent="Start"
AlignItems="Center"
AlignContent="SpaceEvenly"
HorizontalOptions="Center">
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
</FlexLayout>
</StackLayout>
</ScrollView>
</local:ContainerBase.MyContent>
</local:ContainerBase>
</ContentPage>
<?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">
<!--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"
HorizontalOptions="Center"
BindableLayout.ItemsSource="{Binding}">
<BindableLayout.ItemTemplate>
<DataTemplate x:DataType="model:Recipe">
<Border Style="{StaticResource recipeCase}">
<Grid RowDefinitions="*, 40" BindingContext="{Binding AllRecipes}">
<!--<local:RecipeCase
CaseImageSource="room_service_icon.png"
Title="{Binding Title}"/>-->
<Image
Grid.Row="0" VerticalOptions="Fill"
Source="{Binding AllRecipe.Image}"/>
<Label
Text="{Binding Title}" FontSize="18"
Grid.Row="1" HorizontalOptions="Center"/>
</Grid>
</Border>
</DataTemplate>
</BindableLayout.ItemTemplate>
<!--<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>
<local:RecipeCase CaseImageSource="room_service_icon.png"/>-->
</FlexLayout>
</StackLayout>
</ScrollView>
</local:ContainerBase.MyContent>
</local:ContainerBase>
</ContentPage>

@ -1,10 +1,21 @@
namespace Views
using DataPersistence;
using Model;
namespace Views
{
public partial class Home : ContentPage
{
{
public DataManager DataMgr => (App.Current as App).DataMgr;
public User user => (App.Current as App).CurrentUser;
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());
InitializeComponent();
BindingContext = this;
}
}
}
}

@ -38,26 +38,20 @@
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"
Text="{Binding userBis.Name}"/>
Text="{Binding CurrentUser.Name}"/>
<Label Text="Prénom :"
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"
Text="{Binding userBis.Surname} "/>
Text="{Binding CurrentUser.Surname} "/>
<Label Text="Mail :"
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"
IsEnabled="False"
Text="{Binding user.Mail}"/>
<Button BackgroundColor="#bdf5bd"
Text="Modifier"
Margin="40,0,0,0"
TextColor="Black"
MaximumWidthRequest="100"
Clicked="Validation_Click"/>
Text="{Binding CurrentUser.Mail}"/>
<!--liste drag and drop-->
</VerticalStackLayout>
<VerticalStackLayout Padding="100,0,0,0">

@ -8,24 +8,12 @@ namespace Views;
public partial class MyProfil : ContentPage
{
public DataManager DataMgr => (App.Current as App).DataMgr;
public User user => (App.Current as App).user;
public User userBis {get; set; }
public User user => (App.Current as App).CurrentUser;
public MyProfil()
{
userBis = new User(user);
InitializeComponent();
BindingContext = this;
}
public void Validation_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(userBis.Name) || String.IsNullOrEmpty(userBis.Surname)){
return;
}
user.Name = userBis.Name;
user.Surname = userBis.Surname;
}
}
Loading…
Cancel
Save