From f2de173e59e42d15900ca6551d5b499d53b6ba63 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Mon, 5 Jun 2023 17:42:04 +0200 Subject: [PATCH] fixed problem after merge --- MCTG/Views/App.xaml.cs | 2 +- MCTG/Views/ContentPages/AddRecipe.xaml.cs | 5 +-- MCTG/Views/ContentPages/MyProfil.xaml.cs | 47 ++++++++++++++++++++--- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/MCTG/Views/App.xaml.cs b/MCTG/Views/App.xaml.cs index d0d0bb4..f4a8489 100644 --- a/MCTG/Views/App.xaml.cs +++ b/MCTG/Views/App.xaml.cs @@ -55,7 +55,7 @@ namespace Views InitializeComponent(); UserAppTheme = AppTheme.Light; - MainPage = new Home(); + MainPage = new MyProfil(); //MainPage = new MyPosts(); } diff --git a/MCTG/Views/ContentPages/AddRecipe.xaml.cs b/MCTG/Views/ContentPages/AddRecipe.xaml.cs index 2a8af24..dc5f1c4 100644 --- a/MCTG/Views/ContentPages/AddRecipe.xaml.cs +++ b/MCTG/Views/ContentPages/AddRecipe.xaml.cs @@ -1,5 +1,4 @@ using Model; -using Model.Managers; using System.Diagnostics; using Microsoft.Maui.Media; @@ -7,8 +6,8 @@ namespace Views { public partial class AddRecipe : ContentPage { - public MasterManager Master => (Application.Current as App).Master; - + public MasterManager Master => (Application.Current as App).Master; + public List UnitList { get; set; } = new List { Unit.unit, Unit.kG, Unit.mG, Unit.G, Unit.L, Unit.cL, Unit.mL }; public bool IsCaptureSupported => throw new NotImplementedException(); diff --git a/MCTG/Views/ContentPages/MyProfil.xaml.cs b/MCTG/Views/ContentPages/MyProfil.xaml.cs index cbf0463..aec0544 100644 --- a/MCTG/Views/ContentPages/MyProfil.xaml.cs +++ b/MCTG/Views/ContentPages/MyProfil.xaml.cs @@ -1,16 +1,51 @@ +using CommunityToolkit.Maui.Behaviors; +using DataPersistence; using Model; +using System.Collections.ObjectModel; +using System.Diagnostics; + namespace Views; public partial class MyProfil : ContentPage { - public MasterManager Master => (Application.Current as App).Master; - public User user => Master.User.CurrentConnected; + public MasterManager Master => (App.Current as App).Master; + public User CurrentUser => Master.User.CurrentConnected; + + + + public MyProfil() + { + InitializeComponent(); + + BindingContext = this; + } + public ObservableCollection PriorityList { get; private set; } = new ObservableCollection() + { Priority.Economic, Priority.Fast, Priority.Easy, Priority.Light, Priority.Gourmet }; + void DragGestureRecognizer_DragStarting2(System.Object sender, Microsoft.Maui.Controls.DragStartingEventArgs e) + { + e.Data.Properties["value"] = (sender as Element).Parent.BindingContext; + } + + void DropGestureRecognizer_Drop2(System.Object sender, Microsoft.Maui.Controls.DropEventArgs e) + { + var receivingElement = (Priority)((sender as Element).Parent.BindingContext); + + var draggedElement = (Priority)e.Data.Properties["value"]; + int draggedIndex = PriorityList.IndexOf(draggedElement); + PriorityList.RemoveAt(draggedIndex); - public MyProfil() - { - InitializeComponent(); + int receivingIndex = PriorityList.IndexOf(receivingElement); + PriorityList.Insert(receivingIndex + 1, draggedElement); + } + + private void OnMyRecipeClicked(object sender, EventArgs e) + { + Navigation.PushModalAsync(new MyPosts()); + } - BindingContext = this; + private void OnAddRecipeClicked(object sender, EventArgs e) + { + Navigation.PushModalAsync(new AddRecipe()); } } \ No newline at end of file