From b70c46d8bf1252b6498eb5937a071144c200113c Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Fri, 30 Aug 2019 22:21:30 +0200 Subject: [PATCH] Test late load --- AideDeJeu/AideDeJeu/AideDeJeu.csproj | 3 + .../AideDeJeu/Views/Library/ItemPage.xaml | 48 ++++++++++ .../AideDeJeu/Views/Library/ItemPage.xaml.cs | 87 +++++++++++++++++++ AideDeJeu/AideDeJeu/Views/MainShell.xaml | 57 +++++------- 4 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml create mode 100644 AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml.cs diff --git a/AideDeJeu/AideDeJeu/AideDeJeu.csproj b/AideDeJeu/AideDeJeu/AideDeJeu.csproj index cfc96b3c..fd06308c 100644 --- a/AideDeJeu/AideDeJeu/AideDeJeu.csproj +++ b/AideDeJeu/AideDeJeu/AideDeJeu.csproj @@ -111,6 +111,9 @@ Resource.resx + + ItemPage.xaml + ItemView.xaml diff --git a/AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml b/AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml new file mode 100644 index 00000000..6dfba2f8 --- /dev/null +++ b/AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml.cs b/AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml.cs new file mode 100644 index 00000000..8c640f73 --- /dev/null +++ b/AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml.cs @@ -0,0 +1,87 @@ + +using AideDeJeu.ViewModels; +using AideDeJeu.ViewModels.Library; +using AideDeJeuLib; +using SkiaSharp; +using SkiaSharp.Views.Forms; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace AideDeJeu.Views.Library +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class ItemPage : ContentPage + { + public MainViewModel Main + { + get + { + return DependencyService.Get(); + } + } + + ItemDetailViewModel viewModel; + + public ItemPage() + { + InitializeComponent(); + + BindingContext = this.viewModel = new ItemDetailViewModel(new Item() + { + Name = "Bibliothèque", + Id = "index.md", + Markdown = AideDeJeu.Tools.Helpers.GetResourceString($"AideDeJeu.Data.index.md"), + } + ) { Title = "Bibliothèque" }; + + LoadPageAsync(); + } + + public string Path { get; set; } = "l5r_index_hd.md"; + + private async Task LoadPageAsync() + { + var regex = new Regex("/?(?.*?)(_with_(?.*))?\\.md(#(?.*))?"); + var match = regex.Match(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 ItemDetailViewModel() { Item = items }; + BindingContext = this.viewModel = itemsViewModel; + //SwitchToMainTab(); + //if (filterViewModel == null) + //{ + // await GotoItemsPageAsync(itemsViewModel); + //} + //else + //{ + // await GotoFilteredItemsPageAsync(itemsViewModel); + //} + + } + else + { + //await App.Current.MainPage.DisplayAlert("Lien invalide", s, "OK"); + } + } + } +} \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/Views/MainShell.xaml b/AideDeJeu/AideDeJeu/Views/MainShell.xaml index a0195024..7690823e 100644 --- a/AideDeJeu/AideDeJeu/Views/MainShell.xaml +++ b/AideDeJeu/AideDeJeu/Views/MainShell.xaml @@ -5,73 +5,55 @@ xmlns:pc="clr-namespace:AideDeJeu.Views.PlayerCharacter" xmlns:library="clr-namespace:AideDeJeu.Views.Library" x:Class="AideDeJeu.Views.MainShell"> + - + - + - + - - + + + + - - - + - - - + - - - + - - - + + + + - - - + - - - + - - - - - - - - - - - - - + - + @@ -82,4 +64,5 @@ + \ No newline at end of file