Comments (6)
Yay I got it working!
let imageText = Node(
direction: .Column,
padding: Edges(top: 20, bottom: 20),
size: CGSizeMake(375, CGFloat.NaN), // I just have to make sure I defined the size here, height is important to be Nan
children: strings.map { (text : String) -> Node in
let image = Node(
size: CGSizeMake(100, 100)
)
let text = Node(
flex: 1, // And make sure flex are set
measure: { w in
label.text = text
label.preferredMaxLayoutWidth = w
return label.sizeThatFits(CGSizeMake(w, CGFloat.max))
})
let row = Node(
direction: Direction.Row,
children:[image, text]
)
return row
}
)
println(imageText.layout().frame) // (0.0, 0.0, 375.0, 912.5)
from swiftbox.
Glad you figured it out!
I'm going to re-open this because that does look like something's funny with maxWidth
.
from swiftbox.
Is maxWidth
something inside original Flexbox implementation or no?
from swiftbox.
Yeah it's in FB's flexbox implementation.
from swiftbox.
Then we have to either help to fix facebook's impl or patch it in SwiftBox manually
from swiftbox.
I just ran into a bug with maxWidth
myself (it was setting the width of some flex: 1
children to zero).
To work around it, I just wrapped the root node inside an extra node with its width
set to maxWidth
, and then just grabbed the first child after calling layout()
:
if let maxWidth = maxWidth {
let wrapper = Node(size: CGSize(width: maxWidth, height: .nan), children: [node])
let layout = wrapper.layout()
return layout.children.first!
} else {
return node.layout()
}
from swiftbox.
Related Issues (12)
- Support Swift 2.0 HOT 3
- make available as a CocoaPod or Carthage Package HOT 2
- Using it in TableView HOT 1
- SwiftBox name is allready taken on cocoapods HOT 3
- Swift 3 compatibility HOT 1
- Position: absolute?
- Demo not up to date with Swift
- NodeImpl not recognised
- I am using xcode 8 and it says that this project is developed by using swift 2.x. I think that it has been migrated to swift 3
- Super cool :) HOT 1
- Example in README doesn't produce indicated output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftbox.