diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/CustomRenderers/QueryEditorRenderer.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/CustomRenderers/QueryEditorRenderer.cs index c1525ab..8f6c783 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/CustomRenderers/QueryEditorRenderer.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/CustomRenderers/QueryEditorRenderer.cs @@ -125,8 +125,8 @@ namespace Xamarin.Neo4j.iOS.CustomRenderers // Apply text color formatting for text inside double quotes. ApplyQuoteTextColorFormatting(text, attributedText, "\"(.*?)\"", Color.FromHex("#ae8b2d").ToUIColor()); - attributedText.AddAttribute(UIStringAttributeKey.Font, UIFont.SystemFontOfSize((nfloat) Element.FontSize), new NSRange(0, attributedText.Length)); - + attributedText.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("Roboto Mono", (nfloat) Element.FontSize), new NSRange(0, attributedText.Length)); + Control.AttributedText = attributedText; } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist index 3e8d158..b64498d 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist @@ -41,6 +41,8 @@ iconize-fontawesome-regular.ttf iconize-fontawesome-solid.ttf iconize-fontawesome-brands.ttf + iconize-fontawesome-brands.ttf + roboto-mono-regular.ttf diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Properties/AssemblyInfo.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Properties/AssemblyInfo.cs index c22be1a..93266ac 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Properties/AssemblyInfo.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Properties/AssemblyInfo.cs @@ -28,5 +28,3 @@ using Xamarin.Forms; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: ExportFont("RobotoMono-Regular.ttf", Alias = "RobotoMonoRegular")] diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Assets/Fonts/RobotoMono-Regular.ttf b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Resources/roboto-mono-regular.ttf similarity index 100% rename from Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Assets/Fonts/RobotoMono-Regular.ttf rename to Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Resources/roboto-mono-regular.ttf diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj index 2afcca3..368e7c2 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj @@ -151,5 +151,8 @@ + + + \ No newline at end of file diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryEditor.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryEditor.cs index 34f9afd..341b723 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryEditor.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Controls/QueryEditor.cs @@ -17,11 +17,6 @@ namespace Xamarin.Neo4j.Controls public double MaxHeight { get; set; } public event EventHandler ExecuteClicked; - - public QueryEditor() - { - FontFamily = "RobotoMonoRegular"; - } protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint) { diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/SessionPage.xaml b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/SessionPage.xaml index 85d91d2..2bb6f4a 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/SessionPage.xaml +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/SessionPage.xaml @@ -43,7 +43,7 @@ - + diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs index bf8e540..76c9ee4 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Services/Neo4jService.cs @@ -153,7 +153,7 @@ namespace Xamarin.Neo4j.Services Success = true, CanDisplayGraph = canDisplayGraph, Query = query, - DisplayQuery = QueryHelper.TransformQuery(query), + DisplayQuery = QueryHelper.ToDisplayQuery(query), ConnectionString = connectionString, Results = results }; diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Utilities/QueryHelper.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Utilities/QueryHelper.cs index 5ac132e..7fc925d 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Utilities/QueryHelper.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Utilities/QueryHelper.cs @@ -15,51 +15,51 @@ namespace Xamarin.Neo4j.Utilities { public static class QueryHelper { - public static string TransformQuery(string query) + public static string ToDisplayQuery(string query) { // Check if there is a return statement, if not return the original query if (query.IndexOf("RETURN ", StringComparison.OrdinalIgnoreCase) <= 0) return query; - - // This pattern is designed to match relationships with and without labels. - // It captures the relationship direction and type, but not the existing label (if any). - const string pattern = @"-\[:?(\w+)?\]->"; - var matches = Regex.Matches(query, pattern); - // Keep track of unique relationships to ensure they are returned + // Adjusted pattern to match relationships with and without labels/types. + const string pattern = @"-\[(\w*:?(\w+)?)\]->"; + var matches = Regex.Matches(query, pattern); + var relationships = new List(); var relationshipCounter = 1; - + var transformedQuery = query; - + foreach (Match match in matches) { var newLabel = $"display_variable_{relationshipCounter++}"; // Generate a unique label for the relationship - - // Replace the first occurrence of this match in the query with the new labeled version + + // Determine the correct new pattern based on whether the original had a type/label var oldPattern = match.Value; - var newPattern = oldPattern.Replace("[:", $"[{newLabel}:").Replace("]->", "]->"); + var newPattern = !string.IsNullOrEmpty(match.Groups[1].Value) ? + oldPattern.Replace("[:", $"[{newLabel}:").Replace("]->", "]->") : // For labeled/types + oldPattern.Replace("[]", $"[{newLabel}]"); // For unlabeled + var idx = transformedQuery.IndexOf(oldPattern); - + if (idx != -1) { transformedQuery = transformedQuery.Substring(0, idx) + newPattern + transformedQuery.Substring(idx + oldPattern.Length); } - + relationships.Add(newLabel); } - + // Construct the new RETURN clause with the added relationships. if (relationships.Count > 0) { - // Assuming there's always a RETURN statement to append to. var returnIndex = transformedQuery.LastIndexOf("RETURN ", StringComparison.OrdinalIgnoreCase); var returnClause = transformedQuery.Substring(returnIndex + "RETURN ".Length); var newReturnClause = string.Join(", ", relationships) + ", " + returnClause; - + transformedQuery = transformedQuery.Substring(0, returnIndex) + "RETURN " + newReturnClause; } - + return transformedQuery; } } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj index 6e3a40d..1dd8c6e 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.csproj @@ -24,6 +24,5 @@ - \ No newline at end of file