mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-22 10:03:41 +00:00
Header de liste
This commit is contained in:
parent
209ecba786
commit
e2b65754b2
15 changed files with 51 additions and 54 deletions
|
|
@ -13,11 +13,31 @@ namespace AideDeJeuLib
|
|||
public class Items : Item, IEnumerable<Item>
|
||||
{
|
||||
private IEnumerable<Item> _Items;
|
||||
public override string Markdown => throw new NotImplementedException();
|
||||
|
||||
public Items(IEnumerable<Item> items)
|
||||
{
|
||||
_Items = items;
|
||||
}
|
||||
|
||||
public Items()
|
||||
{
|
||||
_Items = new List<Item>();
|
||||
}
|
||||
|
||||
private string _Markdown = "";
|
||||
public override string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
//return "\n\n# test\n\n";
|
||||
return _Markdown;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator<Item> GetEnumerator()
|
||||
{
|
||||
return _Items.GetEnumerator();
|
||||
return _Items?.GetEnumerator();
|
||||
}
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
|
|
@ -26,18 +46,27 @@ namespace AideDeJeuLib
|
|||
enumerator.MoveNext();
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
if(enumerator.Current.IsNewItem())
|
||||
var block = enumerator.Current;
|
||||
if (block.IsNewItem())
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(enumerator.Current is HeadingBlock)
|
||||
else if(block is HeadingBlock)
|
||||
{
|
||||
var headingBlock = enumerator.Current as HeadingBlock;
|
||||
var headingBlock = block as HeadingBlock;
|
||||
if(headingBlock.Level == 1 && headingBlock.HeaderChar == '#')
|
||||
{
|
||||
this.Name = headingBlock.Inline.ToMarkdownString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_Markdown += headingBlock.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_Markdown += block.ToMarkdownString();
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
|
|
@ -52,7 +81,7 @@ namespace AideDeJeuLib
|
|||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _Items.GetEnumerator();
|
||||
return _Items?.GetEnumerator();
|
||||
}
|
||||
|
||||
public virtual FilterViewModel GetNewFilterViewModel()
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Item> _Items = new List<Item>();
|
||||
public IEnumerable<Item> Items
|
||||
public Items _Items = new Items();
|
||||
public Items Items
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -109,11 +109,11 @@ namespace AideDeJeu.ViewModels
|
|||
if (Filter != null)
|
||||
{
|
||||
var items = await Filter.FilterItems(AllItems, cancellationToken: cancellationToken);
|
||||
Items = items.ToList();
|
||||
Items = new Items(items.ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
Items = AllItems.ToList();
|
||||
Items = AllItems;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
|
|
|
|||
|
|
@ -4,13 +4,23 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local="clr-namespace:AideDeJeu.Views"
|
||||
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||
xmlns:mdview="clr-namespace:Xam.Forms.Markdown"
|
||||
x:Class="AideDeJeu.Views.ItemsPage"
|
||||
x:Name="This"
|
||||
Title="{Binding Title}">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
|
||||
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Name="About" Text="À propos de..." Order="Secondary" Icon="wooden_sign.png" Command="{Binding Main.AboutCommand}" />
|
||||
</ContentPage.ToolbarItems>
|
||||
<ListView BackgroundColor="{StaticResource bgtan}" x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
|
||||
<ListView.Header>
|
||||
<mdview:MarkdownView x:Name="mdMarkdown" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding BindingContext.Items.Markdown, Source={x:Reference This}}" BackgroundColor="Red"/>
|
||||
</ListView.Header>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell AutomationProperties.IsInAccessibleTree="True" AutomationId="machin" AutomationProperties.Name="hop">
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace AideDeJeu.Views
|
|||
InitializeComponent ();
|
||||
|
||||
BindingContext = _ItemsViewModel = itemsViewModel;
|
||||
|
||||
mdMarkdown.NavigateToLink = async (s) => await itemsViewModel.Main.Navigator.NavigateToLinkAsync(s);
|
||||
}
|
||||
public ItemsPage()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue