mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Test FlyoutHeader dynamique par page
This commit is contained in:
		
							parent
							
								
									7479433922
								
							
						
					
					
						commit
						28b4d60c80
					
				
					 3 changed files with 72 additions and 8 deletions
				
			
		|  | @ -55,13 +55,13 @@ namespace AideDeJeu.Views.Library | ||||||
|             //LoadPageAsync(); |             //LoadPageAsync(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         protected override void OnAppearing() |         //protected override void OnAppearing() | ||||||
|         { |         //{ | ||||||
|             base.OnAppearing(); |         //    base.OnAppearing(); | ||||||
|             LoadPageAsync(); |         //    LoadPageAsync(); | ||||||
|         } |         //} | ||||||
| 
 | 
 | ||||||
|         private string _Path { get; set; } = "index.md"; |         private string _Path { get; set; } = null; //"index.md"; | ||||||
|         public string Path |         public string Path | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|  | @ -77,6 +77,7 @@ namespace AideDeJeu.Views.Library | ||||||
| 
 | 
 | ||||||
|         private async Task LoadPageAsync() |         private async Task LoadPageAsync() | ||||||
|         { |         { | ||||||
|  |             if (Path == null) return; | ||||||
|             var regex = new Regex("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?"); |             var regex = new Regex("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?"); | ||||||
|             var match = regex.Match(Uri.UnescapeDataString(Path)); |             var match = regex.Match(Uri.UnescapeDataString(Path)); | ||||||
|             var file = match.Groups["file"].Value; |             var file = match.Groups["file"].Value; | ||||||
|  |  | ||||||
|  | @ -5,6 +5,9 @@ | ||||||
|        xmlns:pc="clr-namespace:AideDeJeu.Views.PlayerCharacter" |        xmlns:pc="clr-namespace:AideDeJeu.Views.PlayerCharacter" | ||||||
|        xmlns:library="clr-namespace:AideDeJeu.Views.Library" |        xmlns:library="clr-namespace:AideDeJeu.Views.Library" | ||||||
|        x:Class="AideDeJeu.Views.MainShell"> |        x:Class="AideDeJeu.Views.MainShell"> | ||||||
|  |     <Shell.FlyoutHeader> | ||||||
|  |         <Label Text="{Binding HeaderTitle}" /> | ||||||
|  |     </Shell.FlyoutHeader> | ||||||
| 
 | 
 | ||||||
|     <ShellItem Title="Accueil"> |     <ShellItem Title="Accueil"> | ||||||
|         <ShellContent Title="Accueil"  ContentTemplate="{DataTemplate local:MainPage}" /> |         <ShellContent Title="Accueil"  ContentTemplate="{DataTemplate local:MainPage}" /> | ||||||
|  | @ -16,7 +19,19 @@ | ||||||
|         <ShellContent Title="Dés"  ContentTemplate="{DataTemplate local:DicesPage}" /> |         <ShellContent Title="Dés"  ContentTemplate="{DataTemplate local:DicesPage}" /> | ||||||
|     </ShellItem> |     </ShellItem> | ||||||
|     <ShellItem Title="Bibliothèque" FlyoutIcon="spell_book.png"> |     <ShellItem Title="Bibliothèque" FlyoutIcon="spell_book.png"> | ||||||
|         <ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemPage}" /> |         <!--<ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemPage}" />--> | ||||||
|  |         <ShellContent Title="Bibliothèque" Icon="spell_book.png"> | ||||||
|  |             <ShellContent.ContentTemplate> | ||||||
|  |                 <DataTemplate> | ||||||
|  |                     <library:ItemPage> | ||||||
|  |                         <x:Arguments> | ||||||
|  |                             <x:String>index.md</x:String> | ||||||
|  |                         </x:Arguments> | ||||||
|  |                     </library:ItemPage> | ||||||
|  |                 </DataTemplate> | ||||||
|  |             </ShellContent.ContentTemplate> | ||||||
|  |         </ShellContent> | ||||||
|  | 
 | ||||||
|     </ShellItem> |     </ShellItem> | ||||||
|     <!--<FlyoutItem Title="Héros & Dragons"> |     <!--<FlyoutItem Title="Héros & Dragons"> | ||||||
|         <ShellContent Title="Héros & Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" /> |         <ShellContent Title="Héros & Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" /> | ||||||
|  |  | ||||||
|  | @ -1,6 +1,9 @@ | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
|  | using System.ComponentModel; | ||||||
|  | using System.Diagnostics; | ||||||
| using System.Linq; | using System.Linq; | ||||||
|  | using System.Runtime.CompilerServices; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Windows.Input; | using System.Windows.Input; | ||||||
|  | @ -10,7 +13,7 @@ using Xamarin.Forms.Xaml; | ||||||
| namespace AideDeJeu.Views | namespace AideDeJeu.Views | ||||||
| { | { | ||||||
|     [XamlCompilation(XamlCompilationOptions.Compile)] |     [XamlCompilation(XamlCompilationOptions.Compile)] | ||||||
|     public partial class MainShell : Shell |     public partial class MainShell : Shell, INotifyPropertyChanged | ||||||
|     { |     { | ||||||
|         public MainShell() |         public MainShell() | ||||||
|         { |         { | ||||||
|  | @ -29,5 +32,50 @@ namespace AideDeJeu.Views | ||||||
|         { |         { | ||||||
|             await Shell.Current.GoToAsync(path); |             await Shell.Current.GoToAsync(path); | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         private string _HeaderTitle = string.Empty; | ||||||
|  |         public string HeaderTitle | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return _HeaderTitle; | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 SetProperty(ref _HeaderTitle, value); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         protected override void OnNavigated(ShellNavigatedEventArgs args) | ||||||
|  |         { | ||||||
|  |             base.OnNavigated(args); | ||||||
|  |             Debug.WriteLine(this.CurrentItem.CurrentItem.CurrentItem); | ||||||
|  |             HeaderTitle = this.CurrentItem.CurrentItem.CurrentItem.Route; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         protected bool SetProperty<T>(ref T backingStore, T value, | ||||||
|  |     [CallerMemberName]string propertyName = "", | ||||||
|  |     Action onChanged = null) | ||||||
|  |         { | ||||||
|  |             if (EqualityComparer<T>.Default.Equals(backingStore, value)) | ||||||
|  |                 return false; | ||||||
|  | 
 | ||||||
|  |             backingStore = value; | ||||||
|  |             onChanged?.Invoke(); | ||||||
|  |             CallOnPropertyChanged(propertyName); | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         #region INotifyPropertyChanged | ||||||
|  |         public event PropertyChangedEventHandler PropertyChanged; | ||||||
|  |         protected void CallOnPropertyChanged([CallerMemberName] string propertyName = "") | ||||||
|  |         { | ||||||
|  |             var changed = PropertyChanged; | ||||||
|  |             if (changed == null) | ||||||
|  |                 return; | ||||||
|  | 
 | ||||||
|  |             changed.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||||||
|  |         } | ||||||
|  |         #endregion | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez