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

Test late load

This commit is contained in:
Yan Maniez 2019-08-30 22:21:30 +02:00
parent 8df998b727
commit b70c46d8bf
4 changed files with 158 additions and 37 deletions

View file

@ -111,6 +111,9 @@
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<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">
<DependentUpon>ItemView.xaml</DependentUpon>
</Compile>

View 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>

View 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");
}
}
}
}

View file

@ -5,73 +5,55 @@
xmlns:pc="clr-namespace:AideDeJeu.Views.PlayerCharacter"
xmlns:library="clr-namespace:AideDeJeu.Views.Library"
x:Class="AideDeJeu.Views.MainShell">
<FlyoutItem Title="Accueil">
<ShellContent>
<ShellContent Title="Accueil">
<local:MainPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Personnages" FlyoutIcon="battle_axe.png">
<ShellContent>
<ShellContent Title="Personnages" >
<pc:PlayerCharacterEditorPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Dés" FlyoutIcon="d20.png">
<ShellContent>
<ShellContent Title="Dés" >
<local:DicesPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Bibliothèque" FlyoutIcon="spell_book.png">
<ShellContent>
<FlyoutItem Title="Bibliothèque" FlyoutIcon="spell_book.png" FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
<ShellContent Title="Héros &amp; Dragons" >
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Héros &amp; Dragons" Shell.BackgroundColor="Blue">
<ShellContent>
<ShellContent Title="Manuel des règles">
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Manuel des règles">
<ShellContent>
<ShellContent Title="Cadre de campagne">
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Cadre de campagne">
<ShellContent>
<ShellContent Title="Créatures et oppositions">
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Créatures et oppositions">
<ShellContent>
<ShellContent Title="Les Cinq Royaumes">
<library:ItemPage/>
</ShellContent>
<ShellContent Title="Livre des monstres">
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Les Cinq Royaumes">
<ShellContent>
<ShellContent Title="Monstrueusement Mignons">
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Livre des monstres">
<ShellContent>
<ShellContent Title="Joan of Arc" >
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<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>
<ShellContent Title="SRD" >
<library:ItemDetailPage/>
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="A propos de..." FlyoutIcon="wooden_sign.png">
<ShellContent>
<ShellContent Title="A propos de..." >
<local:AboutPage/>
</ShellContent>
</FlyoutItem>
@ -82,4 +64,5 @@
</ShellContent>
</ShellSection>
</ShellItem>
</Shell>