Comments (9)
as luck would have it, I recall reading a blog post a few weeks agothat elaborates on function builders and how one might be able to harness that syntax, though I am not entirely sure if it is possible outside of a SwiftUI context, as I remember seeing a constraint on the syntax that I thought was a bit strange. Nevertheless, I will take a look and let you know what I find and if I can prototype a solution!
thanks,
Harry
from swiftui-grid.
#31 has improvements that address this issue as well.
I feel like we can close this.
from swiftui-grid.
This is related to #8
If anyone figured out how to do this please let me know.
from swiftui-grid.
Looks like this could be relevant:
https://developer.apple.com/documentation/swiftui/viewbuilder
Will investigate further.
from swiftui-grid.
@TilBlechschmidt we were able to init it with function builder in previous release
https://github.com/spacenation/grid/blob/eafea07725c1172fe630d6724bd6edac06bef728/Sources/Grid/Grid.swift#L10-L14
But the difficulty here is to process view builder directly like so:
public init(@ViewBuilder content: () -> Content) { ? }
Grid {
Text("1")
}
from swiftui-grid.
Hi! I would love to take this issue. Any advice on a good place to start?
from swiftui-grid.
@hmerzin Hi! This is as far as I have been able to take it
extension Grid {
public init<Data: RandomAccessCollection, ID, Item: View>(@ViewBuilder content: () -> Content) where Content == ForEach<Data, ID, Item> {
let views = content()
self.items = views.data.map { AnyView(views.content($0)) }
}
}
This allows to init grid like so:
Grid {
ForEach(...)
}
I honestly have no idea how to achieve the behaviour of native elements like List, Group, HStack.
There it is possible to just do this and it works:
HStack {
Text("1")
Text("2")
}
It would be awesome if you can figure this out.
from swiftui-grid.
@hmerzin Looks there is a way to do this (#29). It's not perfect but it's an API we are looking for. Is this something similar to what you wanted to implement? Let me know
from swiftui-grid.
@ay42 using @ViewBuilder was exactly the syntax that I was exploring for implementing this. I think I am pretty close, but basically I have just been fiddling with the initializer for HStack
from swiftui-grid.
Related Issues (20)
- Allow custom styles HOT 1
- Wrapping grid in an explicit frame breaks layout
- more data HOT 3
- Problem with custom scroll view
- Highlight Multiple Grid Items with Preferences? HOT 1
- setting a max number of posts for a Category HOT 4
- Layout breaks when Grid is placed inside a ScrollView that is not within a NavigationView HOT 2
- Layout breaks when you swipe left or right in vertical modular grid
- iPad split view layout fail
- Layout wrong no matter what style I use
- StaggeredGridStyle layout breaks when placed in a scrollview with other view HOT 1
- How to set spacing between the cells?
- Grid always in the center
- Grid Reordering
- Replace demo apps with SwiftUI previews
- Adopt availability API
- Layout breaks on rotation at the bottom of scrollview
- Gridview Layout collapses after opening the view for a second time. HOT 5
- Track.min causes division by zero HOT 1
- Scroll both vertically and horizontally same time HOT 4
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 swiftui-grid.