1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Test FlyoutHeader dynamique par page

This commit is contained in:
Yan Maniez 2019-09-28 03:57:39 +02:00
parent 7479433922
commit 28b4d60c80
3 changed files with 72 additions and 8 deletions

View file

@ -55,13 +55,13 @@ namespace AideDeJeu.Views.Library
//LoadPageAsync();
}
protected override void OnAppearing()
{
base.OnAppearing();
LoadPageAsync();
}
//protected override void OnAppearing()
//{
// base.OnAppearing();
// LoadPageAsync();
//}
private string _Path { get; set; } = "index.md";
private string _Path { get; set; } = null; //"index.md";
public string Path
{
get
@ -77,6 +77,7 @@ namespace AideDeJeu.Views.Library
private async Task LoadPageAsync()
{
if (Path == null) return;
var regex = new Regex("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?");
var match = regex.Match(Uri.UnescapeDataString(Path));
var file = match.Groups["file"].Value;

View file

@ -5,6 +5,9 @@
xmlns:pc="clr-namespace:AideDeJeu.Views.PlayerCharacter"
xmlns:library="clr-namespace:AideDeJeu.Views.Library"
x:Class="AideDeJeu.Views.MainShell">
<Shell.FlyoutHeader>
<Label Text="{Binding HeaderTitle}" />
</Shell.FlyoutHeader>
<ShellItem Title="Accueil">
<ShellContent Title="Accueil" ContentTemplate="{DataTemplate local:MainPage}" />
@ -16,7 +19,19 @@
<ShellContent Title="Dés" ContentTemplate="{DataTemplate local:DicesPage}" />
</ShellItem>
<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>
<!--<FlyoutItem Title="Héros &amp; Dragons">
<ShellContent Title="Héros &amp; Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" />

View file

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
@ -10,7 +13,7 @@ using Xamarin.Forms.Xaml;
namespace AideDeJeu.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainShell : Shell
public partial class MainShell : Shell, INotifyPropertyChanged
{
public MainShell()
{
@ -29,5 +32,50 @@ namespace AideDeJeu.Views
{
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
}
}