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

@ -13,43 +13,31 @@ 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; }
/// <summary>
/// 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; }
//const int WindowWidth = 1200;
//const int WindowHeight = 800;
public App()
{
CurrentUser = MasterMgr.DataMgr.GetUsers().Last();
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();
}
}
}

@ -21,7 +21,8 @@
CornerRadius="50" Margin="0, 30, 0, 10"
BorderWidth="5" BorderColor="Black"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"
Grid.RowSpan="2"/>
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());
}
}

@ -22,7 +22,8 @@
Placeholder="Mots-clés (ex.: rapide, fromage)"
FontAttributes="Italic" TextColor="Black"
BackgroundColor="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray300}}"
Margin="15, 10, 15, 40"/>
Margin="15, 10, 15, 40"
SearchButtonPressed="SearchBar_SearchButtonPressed"/>
<!-- Direct research -->
<Button
@ -43,7 +44,7 @@
<!-- Master -->
<local:ContainerBase.MyContent>
<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-->
<Label
Text="{Binding Description}"
@ -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,6 +77,7 @@
<Label
Text="{Binding Title}" FontSize="18"
Grid.Row="1" HorizontalOptions="Center"/>
</Grid>
</Border>
</DataTemplate>

@ -1,22 +1,29 @@
using DataPersistence;
using Model;
using Model.Managers;
using System.ComponentModel;
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 RecipesDisplayed { get; private set; }
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());
RecipesDisplayed = AllRecipe;
InitializeComponent();
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"
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>

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

Loading…
Cancel
Save