GithubHelp home page GithubHelp logo

Comments (6)

alexdrone avatar alexdrone commented on May 18, 2024

you sure the create block is not called - it works for me :/

from render.

jewilhel avatar jewilhel commented on May 18, 2024

Yeah, I put a print statement in there to check it for sure. I got nothing printed to the console. I reverted the framework to the previous update and it worked as expected. I haven't encountered this issue before the recent update. I will test again in the sample code that I shared with you earlier.

from render.

alexdrone avatar alexdrone commented on May 18, 2024

that's really weird - I'm on HEAD right now and the creation closure seems to be invoked all of the time.

from render.

jewilhel avatar jewilhel commented on May 18, 2024

What is really strange is that it only stopped working in my card component, but it seems to work everywhere else.

import Foundation
import UIKit
import Render

struct CardState: State {
    var id: String = "Card"
    var feature: NodeType = layoutBuilder("")
    var titlebar: NodeType = layoutBuilder("")
    var cardSize: CGFloat = 1
    var layoutAs: String = "layer"
    
}

class CardComponent: ComponentView<CardState> {
    required init() {
        super.init()
        self.state = CardState()
        self.defaultOptions = [.preventViewHierarchyDiff]
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("Not supported")
    }
    
    override func render() -> NodeType {
        
        let card = Node<UIView>(key: state.id,
                                create: {
            let cardView = UIView()
            ComponentAnimation.springOn(view: cardView)
            return cardView
                                    
        }) { (view, layout, size) in
            let componentSize = self.getSize()
            
            // Add shadow
            view.layer.shadowColor = UIColor.black.cgColor
            view.layer.shadowOpacity = 0.5
            view.layer.shadowOffset = CGSize.init(width: 2, height: 2)
            view.layer.shadowRadius = 2
            
            // Perform layout
            layout.width = componentSize.width
            layout.height = componentSize.width * CardSize.Proportion
            configs[self.state.layoutAs]!(layout)
            
            //layout.paddingTop = 6
        }
        
        // A content view that clips its contents
        let content = Node<UIView> { (view, layout, size) in
            let componentSize = self.getSize()
            
            view.isUserInteractionEnabled = true
            view.onTap { _ in mainStore.dispatch(ContextActionRemove(sender: view))}
            view.layer.cornerRadius = componentSize.width * CardSize.CornerRadiusRatio
            view.clipsToBounds = true
            
            layout.percent.width = 100%
            layout.percent.height = 100%
            layout.alignContent = .center
            
        }
        return card.add(children: [ content.add(children: [
            state.feature, state.titlebar
            ])
            ])
    }
    
    private func getSize() -> CGSize {
        let componentWidth = (UIScreen.main.bounds.size.width * self.state.cardSize)
        return CGSize(width: componentWidth, height: componentWidth * CardSize.Proportion)
    }
}

from render.

jewilhel avatar jewilhel commented on May 18, 2024

Well, I tried putting a reuseIdentifer: "card" before the key: and then the card started behaving as usual and called the create: block correctly. If I remove the reuseIdentifer: again it stops calling the create block. I guess I'm still a bit unclear the difference between key: and the reuseIdentifier.

from render.

alexdrone avatar alexdrone commented on May 18, 2024

from render.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.