mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Sync current page avec shell
This commit is contained in:
parent
1ecf4afdc6
commit
2ebe1c2b25
5 changed files with 88 additions and 53 deletions
|
|
@ -21,6 +21,7 @@ namespace AideDeJeu.ViewModels.Library
|
|||
set
|
||||
{
|
||||
SetProperty(ref _Item, value);
|
||||
Title = _Item?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,5 +213,18 @@ namespace AideDeJeu.ViewModels
|
|||
public MainViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
private Library.ItemViewModel _CurrentItem = null;
|
||||
public Library.ItemViewModel CurrentItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CurrentItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _CurrentItem, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,17 @@ namespace AideDeJeu.Views.Library
|
|||
// LoadPageAsync();
|
||||
//}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
Main.CurrentItem = Item;
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
Main.CurrentItem = null;
|
||||
}
|
||||
private string _Path { get; set; } = null; //"index.md";
|
||||
public string Path
|
||||
{
|
||||
|
|
@ -78,59 +89,59 @@ 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;
|
||||
var anchor = match.Groups["anchor"].Value;
|
||||
var with = match.Groups["with"].Value;
|
||||
Item item = null;
|
||||
try
|
||||
{
|
||||
Main.IsBusy = true;
|
||||
Main.IsLoading = true;
|
||||
item = await Task.Run(async () => await Main.Store.GetItemFromDataAsync(file, anchor));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Main.IsBusy = false;
|
||||
Main.IsLoading = false;
|
||||
}
|
||||
if (item != null)
|
||||
{
|
||||
var items = item; // as Items;
|
||||
var filterViewModel = items.GetNewFilterViewModel();
|
||||
var itemsViewModel = new ItemViewModel() { Item = items, AllItems = items, Filter = filterViewModel };
|
||||
this.Item = itemsViewModel;
|
||||
itemsViewModel.LoadItemsCommand.Execute(null);
|
||||
if (!string.IsNullOrEmpty(with))
|
||||
{
|
||||
var swith = with.Split('_');
|
||||
for (int i = 0; i < swith.Length / 2; i++)
|
||||
{
|
||||
var key = swith[i * 2 + 0];
|
||||
var val = swith[i * 2 + 1];
|
||||
filterViewModel.FilterWith(key, val);
|
||||
}
|
||||
}
|
||||
//SwitchToMainTab();
|
||||
//if (filterViewModel == null)
|
||||
//{
|
||||
// await GotoItemsPageAsync(itemsViewModel);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// await GotoFilteredItemsPageAsync(itemsViewModel);
|
||||
//}
|
||||
//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;
|
||||
// var anchor = match.Groups["anchor"].Value;
|
||||
// var with = match.Groups["with"].Value;
|
||||
// Item item = null;
|
||||
// try
|
||||
// {
|
||||
// Main.IsBusy = true;
|
||||
// Main.IsLoading = true;
|
||||
// item = await Task.Run(async () => await Main.Store.GetItemFromDataAsync(file, anchor));
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// Main.IsBusy = false;
|
||||
// Main.IsLoading = false;
|
||||
// }
|
||||
// if (item != null)
|
||||
// {
|
||||
// var items = item; // as Items;
|
||||
// var filterViewModel = items.GetNewFilterViewModel();
|
||||
// var itemsViewModel = new ItemViewModel() { Item = items, AllItems = items, Filter = filterViewModel };
|
||||
// this.Item = itemsViewModel;
|
||||
// itemsViewModel.LoadItemsCommand.Execute(null);
|
||||
// if (!string.IsNullOrEmpty(with))
|
||||
// {
|
||||
// var swith = with.Split('_');
|
||||
// for (int i = 0; i < swith.Length / 2; i++)
|
||||
// {
|
||||
// var key = swith[i * 2 + 0];
|
||||
// var val = swith[i * 2 + 1];
|
||||
// filterViewModel.FilterWith(key, val);
|
||||
// }
|
||||
// }
|
||||
// //SwitchToMainTab();
|
||||
// //if (filterViewModel == null)
|
||||
// //{
|
||||
// // await GotoItemsPageAsync(itemsViewModel);
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // await GotoFilteredItemsPageAsync(itemsViewModel);
|
||||
// //}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//await App.Current.MainPage.DisplayAlert("Lien invalide", s, "OK");
|
||||
}
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //await App.Current.MainPage.DisplayAlert("Lien invalide", s, "OK");
|
||||
// }
|
||||
//}
|
||||
|
||||
private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
<Label Text="{Binding HeaderTitle}" />
|
||||
<Label Text="{Binding CurrentItem.CurrentItem.CurrentItem.Route}" />
|
||||
<Label Text="{Binding CurrentItem.CurrentItem.CurrentItem.Content.BindingContext.Item.Title}" />
|
||||
<Label Text="{Binding Main.CurrentItem.Item.Name}" />
|
||||
</StackLayout>
|
||||
</Shell.FlyoutHeader>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using AideDeJeu.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -21,6 +22,14 @@ namespace AideDeJeu.Views
|
|||
BindingContext = this;
|
||||
}
|
||||
|
||||
public MainViewModel Main
|
||||
{
|
||||
get
|
||||
{
|
||||
return DependencyService.Get<MainViewModel>();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ShellNavigateCommand
|
||||
{
|
||||
get
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue