mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Tests assistant
This commit is contained in:
parent
bf01af25ee
commit
1ecf4afdc6
7 changed files with 147 additions and 45 deletions
|
|
@ -67,7 +67,7 @@ namespace AideDeJeu.Droid
|
|||
string search = Intent.Extras.GetString("search");
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
Xamarin.Forms.Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(search));
|
||||
Xamarin.Forms.Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(search), true);
|
||||
}
|
||||
Intent.RemoveExtra("search");
|
||||
}
|
||||
|
|
@ -157,6 +157,34 @@ namespace AideDeJeu.Droid
|
|||
.Show();
|
||||
}
|
||||
|
||||
public override void OnProvideAssistContent(Android.App.Assist.AssistContent outContent)
|
||||
{
|
||||
base.OnProvideAssistContent(outContent);
|
||||
|
||||
outContent.WebUri = Android.Net.Uri.Parse("https://heros-et-dragons.fr/");
|
||||
// Provide some JSON
|
||||
string structuredJson = new Org.Json.JSONObject()
|
||||
.Put("@type", "Book")
|
||||
.Put("author", "Lewis Carroll")
|
||||
.Put("name", "Alice in Wonderland")
|
||||
.Put("description",
|
||||
"This is an 1865 novel about a girl named Alice, " +
|
||||
"who falls through a rabbit hole and " +
|
||||
"enters a fantasy world."
|
||||
).ToString();
|
||||
//.Put("@type", "MusicRecording")
|
||||
//.Put("@id", "https://example.com/music/recording")
|
||||
//.Put("name", "Album Title")
|
||||
//.ToString();
|
||||
|
||||
outContent.StructuredData = structuredJson;
|
||||
}
|
||||
|
||||
public override void OnProvideAssistData(Bundle data)
|
||||
{
|
||||
base.OnProvideAssistData(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[IntentFilter(new[] { Android.Content.Intent.ActionAssist }, Categories = new[] { Android.Content.Intent.CategoryDefault })]
|
||||
|
|
@ -187,12 +215,12 @@ namespace AideDeJeu.Droid
|
|||
this.FinishActivity(0);
|
||||
}
|
||||
}
|
||||
public class AndroidListener : Java.Lang.Object, Application.IOnProvideAssistDataListener
|
||||
{
|
||||
public void OnProvideAssistData(Android.App.Activity activity, Bundle data)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("OnProvideAssistData");
|
||||
}
|
||||
}
|
||||
//public class AndroidListener : Java.Lang.Object, Application.IOnProvideAssistDataListener
|
||||
//{
|
||||
// public void OnProvideAssistData(Android.App.Activity activity, Bundle data)
|
||||
// {
|
||||
// System.Diagnostics.Debug.WriteLine("OnProvideAssistData");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace AideDeJeu
|
|||
//mainNavigationPage.Navigation.PushAsync(new MainPage());
|
||||
if (search != null)
|
||||
{
|
||||
Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage());
|
||||
Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
|
@ -158,5 +159,50 @@ namespace AideDeJeu.ViewModels.Library
|
|||
await LoadItemsAsync(cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
|
||||
public async Task LoadPageAsync(string path)
|
||||
{
|
||||
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));
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
var filterViewModel = item.GetNewFilterViewModel();
|
||||
Item = item;
|
||||
AllItems = item;
|
||||
Filter = filterViewModel;
|
||||
await ExecuteLoadItemsCommandAsync();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//await App.Current.MainPage.DisplayAlert("Lien invalide", s, "OK");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Main.IsBusy = false;
|
||||
Main.IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ namespace AideDeJeu.ViewModels
|
|||
};
|
||||
|
||||
// Push the page to Navigation Stack
|
||||
await PopupNavigation.Instance.PushAsync(popup);
|
||||
await PopupNavigation.Instance.PushAsync(popup, true);
|
||||
|
||||
// await for the user to enter the text input
|
||||
var result = await popup.PageClosedTask;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace AideDeJeu.Views.Library
|
|||
}
|
||||
}
|
||||
|
||||
private ItemViewModel _Item = null;
|
||||
private ItemViewModel _Item = new ItemViewModel();
|
||||
public ItemViewModel Item
|
||||
{
|
||||
get
|
||||
|
|
@ -71,7 +71,10 @@ namespace AideDeJeu.Views.Library
|
|||
set
|
||||
{
|
||||
_Path = value;
|
||||
LoadPageAsync();
|
||||
if (Path != null)
|
||||
{
|
||||
Item?.LoadPageAsync(Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,19 +29,23 @@
|
|||
</ResourceDictionary>
|
||||
</Shell.Resources>
|
||||
<Shell.FlyoutHeader>
|
||||
<Label Text="{Binding HeaderTitle}" />
|
||||
<StackLayout>
|
||||
<Label Text="{Binding HeaderTitle}" />
|
||||
<Label Text="{Binding CurrentItem.CurrentItem.CurrentItem.Route}" />
|
||||
<Label Text="{Binding CurrentItem.CurrentItem.CurrentItem.Content.BindingContext.Item.Title}" />
|
||||
</StackLayout>
|
||||
</Shell.FlyoutHeader>
|
||||
|
||||
<ShellItem Title="Accueil">
|
||||
<FlyoutItem Title="Accueil">
|
||||
<ShellContent Title="Accueil" ContentTemplate="{DataTemplate local:MainPage}" />
|
||||
</ShellItem>
|
||||
<ShellItem Title="Personnages" FlyoutIcon="battle_axe.png">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Personnages" FlyoutIcon="battle_axe.png">
|
||||
<ShellContent Title="Personnages" ContentTemplate="{DataTemplate pc:PlayerCharacterEditorPage}" />
|
||||
</ShellItem>
|
||||
<ShellItem Title="Dés" FlyoutIcon="d20.png">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Dés" FlyoutIcon="d20.png">
|
||||
<ShellContent Title="Dés" ContentTemplate="{DataTemplate local:DicesPage}" />
|
||||
</ShellItem>
|
||||
<ShellItem Title="Bibliothèque" FlyoutIcon="spell_book.png">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem 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">
|
||||
<ShellContent.ContentTemplate>
|
||||
|
|
@ -55,7 +59,7 @@
|
|||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
|
||||
</ShellItem>
|
||||
</FlyoutItem>
|
||||
<!--<FlyoutItem Title="Héros & Dragons">
|
||||
<ShellContent Title="Héros & Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
|
||||
</FlyoutItem>
|
||||
|
|
@ -83,7 +87,7 @@
|
|||
<FlyoutItem Title="SRD">
|
||||
<ShellContent Title="SRD" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
|
||||
</FlyoutItem>-->
|
||||
<ShellItem Title="Manuel des Règles">
|
||||
<FlyoutItem Title="Manuel des Règles">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -95,8 +99,8 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="Cadre de Campagne">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Cadre de Campagne">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -108,8 +112,8 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="Créatures et Oppositions">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Créatures et Oppositions">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -121,8 +125,8 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="Les Cinq Royaumes">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Les Cinq Royaumes">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -134,8 +138,8 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="Livre des Monstres">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Livre des Monstres">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -147,8 +151,8 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="Monstrueusement Mignons">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Monstrueusement Mignons">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -160,8 +164,8 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="SRD">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="SRD">
|
||||
<ShellContent>
|
||||
<ShellContent.ContentTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -173,19 +177,19 @@
|
|||
</DataTemplate>
|
||||
</ShellContent.ContentTemplate>
|
||||
</ShellContent>
|
||||
</ShellItem>
|
||||
<ShellItem Title="Favoris">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Favoris">
|
||||
<ShellContent Title="Favoris" ContentTemplate="{DataTemplate library:BookmarksPage}" FlyoutIcon="stars_stack.png" />
|
||||
</ShellItem>
|
||||
<ShellItem Title="Recherche">
|
||||
</FlyoutItem>
|
||||
<FlyoutItem Title="Recherche">
|
||||
<ShellContent Title="Recherche" ContentTemplate="{DataTemplate library:DeepSearchPage}" FlyoutIcon="crystal_ball.png" />
|
||||
</ShellItem>
|
||||
</FlyoutItem>
|
||||
<!--Command="{Binding ShellNavigateCommand}"
|
||||
CommandParameter="//data/item?path=l5r_index_hd.md"
|
||||
/>-->
|
||||
<ShellItem Title="A propos de..." FlyoutIcon="wooden_sign.png">
|
||||
<FlyoutItem Title="A propos de..." FlyoutIcon="wooden_sign.png">
|
||||
<ShellContent Title="A propos de..." ContentTemplate="{DataTemplate local:AboutPage}" />
|
||||
</ShellItem>
|
||||
</FlyoutItem>
|
||||
<!--<ShellItem Text="Test">
|
||||
|
||||
</ShellItem>-->
|
||||
|
|
|
|||
|
|
@ -48,13 +48,34 @@ namespace AideDeJeu.Views
|
|||
protected override void OnNavigated(ShellNavigatedEventArgs args)
|
||||
{
|
||||
base.OnNavigated(args);
|
||||
Debug.WriteLine(this.CurrentItem.CurrentItem.CurrentItem);
|
||||
HeaderTitle = this.CurrentItem.CurrentItem.CurrentItem.Route;
|
||||
Debug.WriteLine(this.CurrentItem?.CurrentItem?.CurrentItem);
|
||||
HeaderTitle = this.CurrentItem?.CurrentItem?.CurrentItem?.Route;
|
||||
var content = this.CurrentItem?.CurrentItem?.CurrentItem?.Content;
|
||||
Debug.WriteLine(content);
|
||||
|
||||
this.CurrentItem.CurrentItem.CurrentItem.PropertyChanged += CurrentItem_PropertyChanged;
|
||||
this.CurrentItem.CurrentItem.CurrentItem.Appearing += CurrentItem_Appearing;
|
||||
this.CurrentItem.CurrentItem.CurrentItem.BindingContextChanged += CurrentItem_BindingContextChanged;
|
||||
}
|
||||
|
||||
private void CurrentItem_BindingContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Debug.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
private void CurrentItem_Appearing(object sender, EventArgs e)
|
||||
{
|
||||
Debug.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
private void CurrentItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
Debug.WriteLine(e.PropertyName);
|
||||
}
|
||||
|
||||
protected bool SetProperty<T>(ref T backingStore, T value,
|
||||
[CallerMemberName]string propertyName = "",
|
||||
Action onChanged = null)
|
||||
[CallerMemberName]string propertyName = "",
|
||||
Action onChanged = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(backingStore, value))
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue