question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS][Rendering] Container additional properties aren't exposed to the custom renderer

See original GitHub issue

Platform

What platform is your issue or question related to? (Delete other platforms).

  • iOS

Author or host

Host

Version of SDK

2.4.6

Details

Similar to #5273, additional properties set on a Container element aren’t available in the ACRBaseCardElementRenderer custom renderer subclass.

        acrRegistration.setBaseCardElementRenderer(CustomContainerRenderer(), cardElementType: .container)
class CustomContainerRenderer: ACRBaseCardElementRenderer {
    override func render(
        _ viewGroup: (UIView & ACRIContentHoldingView)!,
        rootView: ACRView!,
        inputs: NSMutableArray!,
        baseCardElement acoElem: ACOBaseCardElement!,
        hostConfig acoConfig: ACOHostConfig!) -> UIView! {
        
        let view = ACRContainerRenderer.getInstance()?.render(
            viewGroup,
            rootView: rootView,
            inputs: inputs,
            baseCardElement: acoElem,
            hostConfig: acoConfig)
        
        // this is always empty!
        if let props = acoElem.additionalProperties {
            if let cornerRadius = props["my.cornerRadius"] as? CGFloat {
                view?.layer.cornerRadius = cornerRadius
            }
        }
        
        return view
    }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jscalocommented, Feb 18, 2021

OK yes, that works. Thanks for the info!

0reactions
jwoo-msftcommented, Feb 12, 2021

@jscalo I tested this use case. Unfortunately, I wasn’t able to reproduce the issue. Here is my test card & custom renderer

 {
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.3",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Test Card",
                    "wrap": true
                }
            ],
            "my.cornerRadius" : 20.0
        }
    ]
}

Test Code Snippet of Custom Container Renderer

    NSData *additionalProperty = acoElem.additionalProperty;
    XCTAssertTrue(additionalProperty != nullptr);
    NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:additionalProperty options:NSJSONReadingMutableLeaves error:nil];
    NSNumber *radius = dictionary[@"my.cornerRadius"];
    XCTAssertTrue([radius floatValue] == 20.0f);

    ACRContainerRenderer *defaultRenderer = [ACRContainerRenderer getInstance];

    UIView *view = [defaultRenderer render:viewGroup rootView:rootView inputs:inputs baseCardElement:acoElem hostConfig:acoConfig];

Swift example

if let props = acoElem.additionalProperty() {
            if let dictionary = try JSONSerialization .jsonObject(with: props, options: JSONSerialization.ReadingOptions.mutableLeaves) as? [NSString: Any]{
                let radius = (dictionary["my.cornerRadius"] as! NSNumber).floatValue
            }
        }

I realized that we need documentation on additional properties for Swift and need additional context. I will update the doc. Meanwhile, additional properties is an NSData, and it has to be deserialized to a dictionary, then it can be queried. I will update the documentation. let me know if you still see this issue. Closing this issue and https://github.com/microsoft/AdaptiveCards/issues/5273. Feel free to re-open it if your issue is not resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unity 2023.2.0b5
Graphics Device Features: Rendering artifacts using Custom Render Texture shader on Sphere Game Object (UUM-43540).
Read more >
ag-Grid Cell Rendering - Custom Props
After looking through the ag-Grid Cell Rendering documentation I don't see a way to add custom properties to the cell renderer via the ......
Read more >
Feature Levels and Rendering Modes
Guide to the Mobile Renderer's modes and feature levels.
Read more >
React Data Grid: Cell Renderer
The example below shows a simple Cell Renderer in action. ... Sometimes the data property in the parameters given to a cell renderer...
Read more >
Untitled
Question - Custom shaders make mesh invisible in URP … Unity - Manual: Mesh Filter component WebApr 7, 2023 · Property: Function: Render...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found