From bd44ed2135ee3bd80e55f535275b9d45dc95f8d3 Mon Sep 17 00:00:00 2001 From: Alexandre Agostinho Date: Fri, 26 May 2023 10:03:26 +0200 Subject: [PATCH] start home binding --- MCTG/Model/Recipes/RecipeCollection.cs | 3 + MCTG/Views/App.xaml.cs | 72 ++++++------- MCTG/Views/ContainerFlyout.xaml | 13 +-- MCTG/Views/ContainerFlyout.xaml.cs | 7 ++ MCTG/Views/Home.xaml | 133 +++++++++++++------------ MCTG/Views/Home.xaml.cs | 33 +++--- MCTG/Views/RecipeCase.xaml | 7 +- MCTG/Views/RecipeCase.xaml.cs | 10 +- MCTG/Views/ReturnButton.xaml | 3 +- MCTG/Views/ReturnButton.xaml.cs | 43 ++++---- 10 files changed, 170 insertions(+), 154 deletions(-) diff --git a/MCTG/Model/Recipes/RecipeCollection.cs b/MCTG/Model/Recipes/RecipeCollection.cs index ac7d17a..051d37c 100644 --- a/MCTG/Model/Recipes/RecipeCollection.cs +++ b/MCTG/Model/Recipes/RecipeCollection.cs @@ -68,6 +68,9 @@ namespace Model /// A collection of Recipe where their Title contain the string. 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()); diff --git a/MCTG/Views/App.xaml.cs b/MCTG/Views/App.xaml.cs index 8366f1e..705c354 100644 --- a/MCTG/Views/App.xaml.cs +++ b/MCTG/Views/App.xaml.cs @@ -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 + /// + /// Master manager - access to the Model. + /// 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 + /// + /// Get the current connected user. + /// + public User? CurrentUser { get; private set; } + + /// + /// Get all the recipes loaded. + /// 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(); + } + } +} diff --git a/MCTG/Views/ContainerFlyout.xaml b/MCTG/Views/ContainerFlyout.xaml index 07193e3..30a2e47 100644 --- a/MCTG/Views/ContainerFlyout.xaml +++ b/MCTG/Views/ContainerFlyout.xaml @@ -16,12 +16,13 @@ HorizontalOptions="Start" Padding="10, 10, 0, 0"/> + 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"/>