mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Test gesture
This commit is contained in:
parent
aa6636ed7f
commit
7a0fd1d454
6 changed files with 3563 additions and 3081 deletions
|
|
@ -65,7 +65,7 @@
|
||||||
<Version>1.60.2</Version>
|
<Version>1.60.2</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Xamarin.Forms">
|
<PackageReference Include="Xamarin.Forms">
|
||||||
<Version>3.1.0.697729</Version>
|
<Version>3.2.0.637442-pre1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
6422
AideDeJeu/AideDeJeu.Android/Resources/Resource.designer.cs
generated
6422
AideDeJeu/AideDeJeu.Android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,7 +11,7 @@
|
||||||
<AssemblyName>AideDeJeu.UWP</AssemblyName>
|
<AssemblyName>AideDeJeu.UWP</AssemblyName>
|
||||||
<DefaultLanguage>fr-FR</DefaultLanguage>
|
<DefaultLanguage>fr-FR</DefaultLanguage>
|
||||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||||
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
|
<TargetPlatformVersion>10.0.17134.0</TargetPlatformVersion>
|
||||||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
||||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||||
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.7" />
|
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.7" />
|
||||||
<PackageReference Include="Xamarin.Forms">
|
<PackageReference Include="Xamarin.Forms">
|
||||||
<Version>3.1.0.697729</Version>
|
<Version>3.2.0.637442-pre1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@
|
||||||
<Version>1.60.2</Version>
|
<Version>1.60.2</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Xamarin.Forms">
|
<PackageReference Include="Xamarin.Forms">
|
||||||
<Version>3.1.0.697729</Version>
|
<Version>3.2.0.637442-pre1</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
<PackageReference Include="Markdig" Version="0.15.1" />
|
<PackageReference Include="Markdig" Version="0.15.1" />
|
||||||
<PackageReference Include="SkiaSharp.Svg" Version="1.60.0" />
|
<PackageReference Include="SkiaSharp.Svg" Version="1.60.0" />
|
||||||
<PackageReference Include="SkiaSharp.Views.Forms" Version="1.60.2" />
|
<PackageReference Include="SkiaSharp.Views.Forms" Version="1.60.2" />
|
||||||
<PackageReference Include="Xamarin.Forms" Version="3.1.0.697729" />
|
<PackageReference Include="Xamarin.Forms" Version="3.2.0.637442-pre1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
using Markdig;
|
using Markdig;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Xamarin.Forms.Internals;
|
||||||
|
|
||||||
public class MarkdownView : ContentView
|
public class MarkdownView : ContentView
|
||||||
{
|
{
|
||||||
|
|
@ -66,7 +67,7 @@
|
||||||
|
|
||||||
private StackLayout stack;
|
private StackLayout stack;
|
||||||
|
|
||||||
private List<KeyValuePair<string, string>> links = new List<KeyValuePair<string, string>>();
|
//private List<KeyValuePair<string, string>> links = new List<KeyValuePair<string, string>>();
|
||||||
|
|
||||||
private void RenderMarkdown()
|
private void RenderMarkdown()
|
||||||
{
|
{
|
||||||
|
|
@ -100,52 +101,59 @@
|
||||||
|
|
||||||
private void AttachLinks(View view)
|
private void AttachLinks(View view)
|
||||||
{
|
{
|
||||||
if (links.Any())
|
//return;
|
||||||
|
//if (links.Any())
|
||||||
|
//{
|
||||||
|
// var blockLinks = links.Distinct().OrderBy(l => l.Value).ToList();
|
||||||
|
// view.GestureRecognizers.Add(new TapGestureRecognizer
|
||||||
|
// {
|
||||||
|
// Command = new Command(async () =>
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// if (blockLinks.Count > 1)
|
||||||
|
// {
|
||||||
|
// var result = await Application.Current.MainPage.DisplayActionSheet("Ouvrir le lien", "Annuler", null, blockLinks.Select(x => x.Key).ToArray());
|
||||||
|
// var link = blockLinks.FirstOrDefault(x => x.Key == result);
|
||||||
|
// //await NavigateToLink(link.Value);
|
||||||
|
// NavigateToLinkCommand?.Execute(link.Value);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //await NavigateToLink(blockLinks.First().Value);
|
||||||
|
// NavigateToLinkCommand?.Execute(blockLinks.First().Value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception) { }
|
||||||
|
// }),
|
||||||
|
// });
|
||||||
|
|
||||||
|
// links = new List<KeyValuePair<string, string>>();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Span AttachLink(Span span, string link)
|
||||||
|
{
|
||||||
|
if (link != null)
|
||||||
{
|
{
|
||||||
var blockLinks = links.Distinct().OrderBy(l => l.Value).ToList();
|
var gestureRecognizer = new TapGestureRecognizer()
|
||||||
view.GestureRecognizers.Add(new TapGestureRecognizer
|
|
||||||
{
|
{
|
||||||
Command = new Command(async () =>
|
Command = new Command(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (blockLinks.Count > 1)
|
NavigateToLinkCommand?.Execute(link);
|
||||||
{
|
}
|
||||||
var result = await Application.Current.MainPage.DisplayActionSheet("Ouvrir le lien", "Annuler", null, blockLinks.Select(x => x.Key).ToArray());
|
catch (Exception)
|
||||||
var link = blockLinks.FirstOrDefault(x => x.Key == result);
|
{
|
||||||
//await NavigateToLink(link.Value);
|
|
||||||
NavigateToLinkCommand?.Execute(link.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//await NavigateToLink(blockLinks.First().Value);
|
|
||||||
NavigateToLinkCommand?.Execute(blockLinks.First().Value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
|
||||||
}),
|
}),
|
||||||
});
|
};
|
||||||
|
span.GestureRecognizers.Add(gestureRecognizer);
|
||||||
links = new List<KeyValuePair<string, string>>();
|
}
|
||||||
}
|
return span;
|
||||||
}
|
|
||||||
|
|
||||||
private void AttachLink(Span span, KeyValuePair<string, string> link)
|
|
||||||
{
|
|
||||||
//span.GestureRecognizers.Add(new TapGestureRecognizer
|
|
||||||
//{
|
|
||||||
// Command = new Command(async () =>
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// await NavigateToLink(link.Value);
|
|
||||||
// }
|
|
||||||
// catch (Exception)
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Rendering blocks
|
#region Rendering blocks
|
||||||
|
|
||||||
|
|
@ -502,43 +510,44 @@
|
||||||
|
|
||||||
foreach (var inline in inlines)
|
foreach (var inline in inlines)
|
||||||
{
|
{
|
||||||
var spans = CreateSpans(inline, family, attributes, foregroundColor, backgroundColor, size);
|
CreateSpans(fs, inline, family, attributes, foregroundColor, backgroundColor, size);
|
||||||
if (spans != null)
|
//if (spans != null)
|
||||||
{
|
//{
|
||||||
foreach (var span in spans)
|
// foreach (var span in spans)
|
||||||
{
|
// {
|
||||||
fs.Spans.Add(span);
|
// fs.Spans.Add(span);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Span[] CreateSpans(Inline inline, string family, FontAttributes attributes, Color foregroundColor, Color backgroundColor, float size)
|
private void CreateSpans(FormattedString fs, Inline inline, string family, FontAttributes attributes, Color foregroundColor, Color backgroundColor, float size, string linkurl = null)
|
||||||
{
|
{
|
||||||
switch (inline)
|
switch (inline)
|
||||||
{
|
{
|
||||||
case LiteralInline literal:
|
case LiteralInline literal:
|
||||||
return new[]
|
fs.Spans.Add(AttachLink(new Span
|
||||||
{
|
{
|
||||||
new Span
|
Text = literal.Content.Text.Substring(literal.Content.Start, literal.Content.Length),
|
||||||
{
|
FontAttributes = attributes,
|
||||||
Text = literal.Content.Text.Substring(literal.Content.Start, literal.Content.Length),
|
ForegroundColor = foregroundColor,
|
||||||
FontAttributes = attributes,
|
BackgroundColor = backgroundColor,
|
||||||
ForegroundColor = foregroundColor,
|
FontSize = size,
|
||||||
BackgroundColor = backgroundColor,
|
FontFamily = family,
|
||||||
FontSize = size,
|
}, linkurl));
|
||||||
FontFamily = family,
|
break;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
case EmphasisInline emphasis:
|
case EmphasisInline emphasis:
|
||||||
var childAttributes = attributes | (emphasis.IsDouble ? FontAttributes.Bold : FontAttributes.Italic);
|
var childAttributes = attributes | (emphasis.IsDouble ? FontAttributes.Bold : FontAttributes.Italic);
|
||||||
return emphasis.SelectMany(x => CreateSpans(x, family, childAttributes, foregroundColor, backgroundColor, size)).ToArray();
|
emphasis.ForEach(x => CreateSpans(fs, x, family, childAttributes, foregroundColor, backgroundColor, size, linkurl));
|
||||||
|
break;
|
||||||
|
|
||||||
case LineBreakInline breakline:
|
case LineBreakInline breakline:
|
||||||
return new[] { new Span { Text = "\n" } };
|
fs.Spans.Add(AttachLink(new Span { Text = "\n" }, linkurl));
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case LinkInline link:
|
case LinkInline link:
|
||||||
|
|
||||||
|
|
@ -563,53 +572,56 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
queuedViews.Add(image);
|
queuedViews.Add(image);
|
||||||
return new Span[0];
|
|
||||||
|
//return new Span[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var spans = link.SelectMany(x => CreateSpans(x, this.Theme.Link.FontFamily ?? family, attributes| this.Theme.Link.Attributes, this.Theme.Link.ForegroundColor, this.Theme.Link.BackgroundColor, size)).ToArray();
|
link.ForEach(x => CreateSpans(fs, x, this.Theme.Link.FontFamily ?? family, attributes| this.Theme.Link.Attributes, this.Theme.Link.ForegroundColor, this.Theme.Link.BackgroundColor, size, url));
|
||||||
var newlink = new KeyValuePair<string, string>(string.Join("", spans.Select(x => x.Text)), url);
|
//var newlink = new KeyValuePair<string, string>(string.Join("", spans.Select(x => x.Text)), url);
|
||||||
foreach (var span in spans)
|
//foreach (var span in spans)
|
||||||
{
|
//{
|
||||||
AttachLink(span, newlink);
|
// AttachLink(span, newlink);
|
||||||
}
|
//}
|
||||||
links.Add(new KeyValuePair<string, string>(string.Join("",spans.Select(x => x.Text)), url));
|
//links.Add(new KeyValuePair<string, string>(string.Join("",spans.Select(x => x.Text)), url));
|
||||||
return spans;
|
//return spans;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case CodeInline code:
|
//case CodeInline code:
|
||||||
return new[]
|
// return new[]
|
||||||
{
|
// {
|
||||||
new Span()
|
// new Span()
|
||||||
{
|
// {
|
||||||
Text="\u2002",
|
// Text="\u2002",
|
||||||
FontSize = size,
|
// FontSize = size,
|
||||||
FontFamily = this.Theme.Code.FontFamily,
|
// FontFamily = this.Theme.Code.FontFamily,
|
||||||
ForegroundColor = this.Theme.Code.ForegroundColor,
|
// ForegroundColor = this.Theme.Code.ForegroundColor,
|
||||||
BackgroundColor = this.Theme.Code.BackgroundColor
|
// BackgroundColor = this.Theme.Code.BackgroundColor
|
||||||
},
|
// },
|
||||||
new Span
|
// new Span
|
||||||
{
|
// {
|
||||||
Text = code.Content,
|
// Text = code.Content,
|
||||||
FontAttributes = this.Theme.Code.Attributes,
|
// FontAttributes = this.Theme.Code.Attributes,
|
||||||
FontSize = size,
|
// FontSize = size,
|
||||||
FontFamily = this.Theme.Code.FontFamily,
|
// FontFamily = this.Theme.Code.FontFamily,
|
||||||
ForegroundColor = this.Theme.Code.ForegroundColor,
|
// ForegroundColor = this.Theme.Code.ForegroundColor,
|
||||||
BackgroundColor = this.Theme.Code.BackgroundColor
|
// BackgroundColor = this.Theme.Code.BackgroundColor
|
||||||
},
|
// },
|
||||||
new Span()
|
// new Span()
|
||||||
{
|
// {
|
||||||
Text="\u2002",
|
// Text="\u2002",
|
||||||
FontSize = size,
|
// FontSize = size,
|
||||||
FontFamily = this.Theme.Code.FontFamily,
|
// FontFamily = this.Theme.Code.FontFamily,
|
||||||
ForegroundColor = this.Theme.Code.ForegroundColor,
|
// ForegroundColor = this.Theme.Code.ForegroundColor,
|
||||||
BackgroundColor = this.Theme.Code.BackgroundColor
|
// BackgroundColor = this.Theme.Code.BackgroundColor
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Debug.WriteLine($"Can't render {inline.GetType()} inlines.");
|
Debug.WriteLine($"Can't render {inline.GetType()} inlines.");
|
||||||
return null;
|
break;
|
||||||
|
//return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue