Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Context data not getting passed #1844

Closed
TakasurAtWork opened this issue Feb 20, 2023 · 3 comments
Closed

Context data not getting passed #1844

TakasurAtWork opened this issue Feb 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@TakasurAtWork
Copy link

Description

When you want to keep reference to server driven components for later use, in some other view, the context data gets lost.

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Construct server driven views inside toView using BeagleView constructor.
  2. Pass them to a UIView class to hold them to pass and manipulate later.

Expected Results

I expect the aView and bView to hold their context data, but nothing of that gets displayed. All I get is empty strings. However if I return the UIStackView containing both aView and bView, then it works, but in case I hide and show the bView, then there are a few constraints that get broken, and it does not show again. I am trying to implement expandable and collapsable list using UITableView, dequeuing different row using different view.

Code example, screenshot, or link to a repository:

func toView(renderer: BeagleRenderer) -> UIView {
        let aView: BeagleView = BeagleView(a)
        let bView: BeagleView = BeagleView(b)
        
//        aView.isHidden = true
//        let stackView = UIStackView(arrangedSubviews: [aView, bView])
//        stackView.axis = .vertical
//        stackView.spacing = 0
//        stackView.alignment = .fill
//        stackView.distribution = .fill
//        stackView.isUserInteractionEnabled = false
//        return stackView
        return ViewDataHolder(
            aView: aView,
            bView: bView
        )
    }

class ViewDataHolder: UIView {
    
    init(
        aView: BeagleView,
        bView: BeagleView,
        showA: Bool = false
    ) {
        self.expandedView = expandedView
        self.collapsedView = collapsedView
        self.isExpanded = isExpanded
        super.init(frame: .zero)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    let aView: BeagleView
    let bView: BeagleView
    var showA = false
}
@TakasurAtWork TakasurAtWork added the bug Something isn't working label Feb 20, 2023
@Tiagoperes
Copy link
Contributor

Hello @TakasurAtWork. What do you mean by "context"? Is this the Android Context or the Context within a Beagle screen (from the JSON)?

@TakasurAtWork
Copy link
Author

from the JSON.

@Tiagoperes
Copy link
Contributor

I'm not able to reproduce the problem with the code given (not enough information). Can you please provide us a sample project with the code that causes this problem in an isolated environment?

From your report, I imagine that there might be something clearing the context information when the view is hidden. Maybe you could try setting the height to zero instead of hiding it?

Another approach would be to control the collapsing via ServerDriven:

- Container - context: isListCollapsed (false)
  - Button - onPress: toggle the value of isListCollapsed 
  - Collapsible (a custom component that can collapse its content) - collapsed: isListCollapsed
    - ListView

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants