public static void Configure(this Xamarin.Forms.View view, FigmaFrame child) { Configure(view, (FigmaNode)child); view.Opacity = child.opacity; view.BackgroundColor = child.backgroundColor. MixOpacity(child.opacity).ToFormsColor(); }
public void IsSingleImageViewNode() { var node = new FigmaFrame(); node.name = "!image \"AboutHero\" !file:\"img-about-hero\""; //without nodes Assert.IsTrue(node.IsSingleImageViewNode()); //we add a random node var a11node = new FigmaFrame() { name = "!a11y" }; node.children = new FigmaNode[] { a11node }; Assert.IsTrue(node.IsSingleImageViewNode()); var theme = new FigmaFrame() { name = "!theme:\"Light\"" }; node.children = new FigmaNode[] { a11node, theme }; Assert.IsFalse(node.IsSingleImageViewNode()); }
public void AccessibilityLabelTitleDescription() { var node = new FigmaFrame() { name = "!image" }; var a11node = AddA11Node(node); var label = "hello"; var a11label = new FigmaFrame() { name = CreateParameter(AccessibilityNodeExtensions.a11yLabel, label) }; AddNode(a11label, a11node); Assert.IsTrue(node.TrySearchA11Label(out var outlabel)); Assert.AreEqual(label, outlabel); var help = "this help"; var a11lhelp = new FigmaFrame() { name = CreateParameter(AccessibilityNodeExtensions.a11yHelp, help) }; AddNode(a11lhelp, a11node); Assert.IsTrue(node.TrySearchA11Help(out var outhelp)); Assert.AreEqual(help, outhelp); }
public static void Configure(this NSView view, FigmaFrame child) { Configure(view, (FigmaNode)child); view.AlphaValue = child.opacity; view.Layer.BackgroundColor = child.backgroundColor.MixOpacity(child.opacity).ToCGColor(); }
public static void Configure(this FrameworkElement view, FigmaFrame child) { Configure(view, (FigmaNode)child); view.Opacity = child.opacity; if (view is Panel canvas) { canvas.Background = child.backgroundColor.ToColor(); } }
FigmaFrame AddA11Node(FigmaFrame parentNode) { var a11node = new FigmaFrame() { name = $"{AccessibilityNodeExtensions.a11yNodeName}" }; return(AddNode(a11node, parentNode)); }
public void NodeIsRenderSkipped(string nodeName, bool expectedResult) { var node = new FigmaFrame(); node.name = nodeName; bool result = node.IsRenderSkipped(); Assert.AreEqual(expectedResult, result); }
public void HasNodeImageName() { var node = new FigmaFrame(); node.name = "!image"; Assert.IsTrue(node.HasNodeImageName()); node.name = "image"; Assert.IsTrue(node.HasNodeImageName()); node.name = "imag"; Assert.IsFalse(node.HasNodeImageName()); }
public void HasAccessibilityNode() { var node = new FigmaFrame(); node.name = $"!image"; Assert.IsNull(node.GetA11Node()); //we add a random node var a11node = AddA11Node(node); Assert.AreEqual(a11node, node.GetA11Node()); }
Rectangle GetRectangle(FigmaFrame currentNode) { var content = currentNode.FirstChild(s => s.IsNodeWindowContent()); if (content is IAbsoluteBoundingBox absoluteBounding && currentNode is IAbsoluteBoundingBox parentAbsoluteBoundingBox) { var x = absoluteBounding.absoluteBoundingBox.X - parentAbsoluteBoundingBox.absoluteBoundingBox.X; var parentY = parentAbsoluteBoundingBox.absoluteBoundingBox.Y + parentAbsoluteBoundingBox.absoluteBoundingBox.Height; var actualY = absoluteBounding.absoluteBoundingBox.Y + absoluteBounding.absoluteBoundingBox.Height; var y = parentY - actualY; return(new Rectangle(x, y, absoluteBounding.absoluteBoundingBox.Width, absoluteBounding.absoluteBoundingBox.Height)); } return(default);
public void HasAccessibilityGroup() { var node = new FigmaFrame(); node.name = $"!image"; Assert.IsNull(node.GetA11Node()); //we add a random node var a11node = AddA11Node(node); var roleGroup = new FigmaFrame() { name = CreateParameter(AccessibilityNodeExtensions.a11yRole, AccessibilityNodeExtensions.a11yRoleGroup) }; AddNode(roleGroup, a11node); Assert.IsTrue(node.IsA11Group()); }
public void NodeAttributedValue() { var nodeType = "image"; var nodeName = "AboutHero"; var attribute = "file"; var attributeValue = "img-about-hero"; //whithout children var node = new FigmaFrame(); node.name = $"!{nodeType} \"{nodeName}\" !{attribute}:\"{attributeValue}\""; Assert.IsTrue(node.TryGetAttributeValue(attribute, out var value)); Assert.AreEqual(attributeValue, value); Assert.IsTrue(node.TryGetNodeCustomName(out value)); Assert.AreEqual(nodeName, value); Assert.AreEqual(nodeType, node.GetNodeTypeName()); }
public void IsA11Enabled() { var node = new FigmaFrame(); node.name = "!image"; Assert.IsFalse(node.IsA11Enabled()); //we add a random node var a11node = AddA11Node(node); Assert.AreEqual(a11node, node.GetA11Node()); a11node.visible = true; Assert.IsTrue(node.IsA11Enabled()); a11node.visible = false; Assert.IsFalse(node.IsA11Enabled()); }
public void IsThemedImageViewNode() { var node = new FigmaFrame(); node.name = "!image \"AboutHero\" !file:\"img-about-hero\""; var themeImage = CocoaThemes.Dark; //without nodes var theme = new FigmaFrame() { name = $"!theme:\"{themeImage}\"" }; Assert.IsFalse(theme.IsThemedImageViewNode(out _)); theme.Parent = node; node.children = new FigmaNode[] { theme }; Assert.IsTrue(theme.IsThemedImageViewNode(out var value)); Assert.AreEqual(themeImage, value); var themeImage2 = CocoaThemes.Light; //without nodes var theme2 = new FigmaFrame() { name = $"!theme:\"{themeImage2}\"" }; Assert.IsFalse(theme2.IsThemedImageViewNode(out _)); theme2.Parent = node; node.children = new FigmaNode[] { theme, theme2 }; Assert.IsTrue(theme.IsThemedImageViewNode(out var value2)); Assert.AreEqual(themeImage, value2); Assert.IsTrue(theme2.IsThemedImageViewNode(out var value3)); Assert.AreEqual(themeImage2, value3); }
FigmaFrame AddNode(FigmaFrame node, FigmaFrame parentNode) { parentNode.children = new FigmaNode[] { node }; node.Parent = parentNode; return(node); }