mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 22:45:44 +00:00
Test late load
This commit is contained in:
parent
8df998b727
commit
b70c46d8bf
4 changed files with 158 additions and 37 deletions
|
|
@ -111,6 +111,9 @@
|
||||||
<DependentUpon>Resource.resx</DependentUpon>
|
<DependentUpon>Resource.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Views\AboutPage.xaml.cs" />
|
<Compile Update="Views\AboutPage.xaml.cs" />
|
||||||
|
<Compile Update="Views\Library\ItemPage.xaml.cs">
|
||||||
|
<DependentUpon>ItemPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Views\Pickers\ItemView.xaml.cs">
|
<Compile Update="Views\Pickers\ItemView.xaml.cs">
|
||||||
<DependentUpon>ItemView.xaml</DependentUpon>
|
<DependentUpon>ItemView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
||||||
48
AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml
Normal file
48
AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||||
|
xmlns:mdview="clr-namespace:Xam.Forms.Markdown"
|
||||||
|
x:Class="AideDeJeu.Views.Library.ItemPage"
|
||||||
|
Title="{Binding Title}"
|
||||||
|
Icon="spell_book.png"
|
||||||
|
x:Name="This">
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
|
||||||
|
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<ToolbarItem Name="AddToFavorites" Text="Ajouter aux favoris" Order="Primary" Icon="round_star.png" Command="{Binding Main.Navigator.AddToFavoritesCommand}" />
|
||||||
|
<ToolbarItem Name="Print" Text="Générer un PDF" Order="Primary" Icon="scroll_unfurled.png" Command="{Binding Main.Navigator.GeneratePDFCommand}" CommandParameter="{Binding Item.Markdown}" />
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
|
<Grid>
|
||||||
|
<ScrollView Orientation="Vertical" BackgroundColor="{StaticResource HDWhite}">
|
||||||
|
<mdview:MarkdownView
|
||||||
|
Theme="{StaticResource MonsterMarkdownTheme}"
|
||||||
|
Markdown="{Binding Item.Markdown}"
|
||||||
|
NavigateToLinkCommand="{Binding BindingContext.Main.Navigator.NavigateToLinkCommand, Source={x:Reference This}}"
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
|
<ActivityIndicator
|
||||||
|
VerticalOptions="StartAndExpand"
|
||||||
|
HorizontalOptions="End"
|
||||||
|
Color="{StaticResource HDRed}"
|
||||||
|
IsRunning="{Binding BindingContext.Main.IsLoading, Source={x:Reference This}}"
|
||||||
|
IsVisible="{Binding BindingContext.Main.IsLoading, Source={x:Reference This}}">
|
||||||
|
<ActivityIndicator.WidthRequest>
|
||||||
|
<OnPlatform x:TypeArguments="x:Double">
|
||||||
|
<On Platform="UWP" Value="400" />
|
||||||
|
<On Platform="iOS, Android" Value="50" />
|
||||||
|
</OnPlatform>
|
||||||
|
</ActivityIndicator.WidthRequest>
|
||||||
|
<ActivityIndicator.HeightRequest>
|
||||||
|
<OnPlatform x:TypeArguments="x:Double">
|
||||||
|
<On Platform="UWP" Value="10" />
|
||||||
|
<On Platform="iOS, Android" Value="50" />
|
||||||
|
</OnPlatform>
|
||||||
|
</ActivityIndicator.HeightRequest>
|
||||||
|
</ActivityIndicator>
|
||||||
|
</Grid>
|
||||||
|
</ContentPage>
|
||||||
87
AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml.cs
Normal file
87
AideDeJeu/AideDeJeu/Views/Library/ItemPage.xaml.cs
Normal file
|
|
@ -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<MainViewModel>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?");
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,73 +5,55 @@
|
||||||
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">
|
||||||
|
|
||||||
<FlyoutItem Title="Accueil">
|
<FlyoutItem Title="Accueil">
|
||||||
<ShellContent>
|
<ShellContent Title="Accueil">
|
||||||
<local:MainPage/>
|
<local:MainPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
</FlyoutItem>
|
||||||
<FlyoutItem Title="Personnages" FlyoutIcon="battle_axe.png">
|
<FlyoutItem Title="Personnages" FlyoutIcon="battle_axe.png">
|
||||||
<ShellContent>
|
<ShellContent Title="Personnages" >
|
||||||
<pc:PlayerCharacterEditorPage/>
|
<pc:PlayerCharacterEditorPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
</FlyoutItem>
|
||||||
<FlyoutItem Title="Dés" FlyoutIcon="d20.png">
|
<FlyoutItem Title="Dés" FlyoutIcon="d20.png">
|
||||||
<ShellContent>
|
<ShellContent Title="Dés" >
|
||||||
<local:DicesPage/>
|
<local:DicesPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
</FlyoutItem>
|
||||||
<FlyoutItem Title="Bibliothèque" FlyoutIcon="spell_book.png">
|
<FlyoutItem Title="Bibliothèque" FlyoutIcon="spell_book.png" FlyoutDisplayOptions="AsMultipleItems">
|
||||||
<ShellContent>
|
<ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
|
||||||
|
|
||||||
|
<ShellContent Title="Héros & Dragons" >
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="Manuel des règles">
|
||||||
<FlyoutItem Title="Héros & Dragons" Shell.BackgroundColor="Blue">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="Cadre de campagne">
|
||||||
<FlyoutItem Title="Manuel des règles">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="Créatures et oppositions">
|
||||||
<FlyoutItem Title="Cadre de campagne">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="Les Cinq Royaumes">
|
||||||
<FlyoutItem Title="Créatures et oppositions">
|
<library:ItemPage/>
|
||||||
<ShellContent>
|
</ShellContent>
|
||||||
|
<ShellContent Title="Livre des monstres">
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="Monstrueusement Mignons">
|
||||||
<FlyoutItem Title="Les Cinq Royaumes">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="Joan of Arc" >
|
||||||
<FlyoutItem Title="Livre des monstres">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
<ShellContent Title="SRD" >
|
||||||
<FlyoutItem Title="Monstrueusement Mignons" Shell.BackgroundColor="Blue">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
|
||||||
</ShellContent>
|
|
||||||
</FlyoutItem>
|
|
||||||
<FlyoutItem Title="Joan of Arc" Shell.BackgroundColor="Blue">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
|
||||||
</ShellContent>
|
|
||||||
</FlyoutItem>
|
|
||||||
<FlyoutItem Title="SRD" Shell.BackgroundColor="Blue">
|
|
||||||
<ShellContent>
|
|
||||||
<library:ItemDetailPage/>
|
<library:ItemDetailPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
</FlyoutItem>
|
||||||
<FlyoutItem Title="A propos de..." FlyoutIcon="wooden_sign.png">
|
<FlyoutItem Title="A propos de..." FlyoutIcon="wooden_sign.png">
|
||||||
<ShellContent>
|
<ShellContent Title="A propos de..." >
|
||||||
<local:AboutPage/>
|
<local:AboutPage/>
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</FlyoutItem>
|
</FlyoutItem>
|
||||||
|
|
@ -82,4 +64,5 @@
|
||||||
</ShellContent>
|
</ShellContent>
|
||||||
</ShellSection>
|
</ShellSection>
|
||||||
</ShellItem>
|
</ShellItem>
|
||||||
|
|
||||||
</Shell>
|
</Shell>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue